Accessing OBS
Function Description
The OBS access process is as follows:
- Set fs.obs.access.key and fs.obs.secret.key.
For MRS 1.8.10 and earlier versions, MRS does not support to access OBS bucket using obs, and therefore, you need to set fs.s3a.access.key and fs.s3a.secret.key.
- Use the FileSystem instance to read, add, and delete various resources.
The appending operation is not supported.
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);
}
For MRS 1.8.10 and earlier versions, MRS does not support to access OBS bucket using obs. Change the last line of the code to fSystem = FileSystem.get(URI.create("s3a://[BuketName]"),conf);.
Last Article: Setting Storage Policies
Next Article: Application Commissioning
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.