Using HDFS to Access OBS
Function Description
The OBS access process is as follows:
- Set fs.obs.access.key and fs.obs.secret.key.
- Use the FileSystem instance to read, add, and delete various resources.
The appending operation is not supported.
Prerequisites
Before interconnecting with OBS, create related directories in OBS, and ensure you have the permission to access and operate the the directories.
Sample Code
The following provides code snippets for instantiating the FileSystem. For complete codes, see the HdfsMain class in com.huawei.bigdata.hdfs.examples.
/** * * Add configuration file if the application run on the linux ,then need make * the path of the core-site.xml and hdfs-site.xml to in the linux client file * */ private void confLoad() throws IOException { conf = new Configuration(); // conf file conf.addResource(new Path(PATH_TO_HDFS_SITE_XML)); conf.addResource(new Path(PATH_TO_CORE_SITE_XML)); conf.set("fs.obs.access.key","*** Provide your Access Key ***"); conf.set("fs.obs.secret.key","*** Provide your Secret Key ***"); } /** * build HDFS instance */ private void instanceBuild() throws IOException { // get filesystem // fSystem = FileSystem.get(conf); fSystem = FileSystem.get(URI.create("obs://[BuketName]"),conf); }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot