Help Center/
MapReduce Service/
Developer Guide (Normal_Earlier Than 3.x)/
Alluxio Development Guide/
Developing an Alluxio Application/
Initializing Alluxio
Updated on 2024-08-16 GMT+08:00
Initializing Alluxio
Function Description
Before using APIs provided by Alluxio, you need to initialize Alluxio. The process is as follows:
- Load the HDFS service configuration file.
- Instantiate Filesystem.
- Use HDFS APIs.
Sample Code
The following provides code snippets. For complete codes, see the ExampleClient class.
/** * load configurations from alluxio-site.properties * @throws IOException */ private void loadConf() throws IOException { InputStream fileInputStream = null; alluxioConf = new Properties(); File propertiesFile = new File(PATH_TO_ALLUXIO_SITE_PROPERTIES); try { fileInputStream = new FileInputStream(propertiesFile); alluxioConf.load(fileInputStream); } catch (FileNotFoundException e) { System.out.println(PATH_TO_ALLUXIO_SITE_PROPERTIES + "does not exist. Exception: " + e); } catch (IOException e) { System.out.println("Failed to load configuration file. Exception: " + e); } finally{ close(fileInputStream); } } /** * build Alluxio instance */ private void instanceBuild() throws IOException { // get filesystem InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults()); conf.set(PropertyKey.MASTER_RPC_ADDRESSES, alluxioConf.get("alluxio.master.rpc.addresses")); FileSystemContext fsContext = FileSystemContext.create(conf); fSystem = FileSystem.Factory.create(fsContext); }
Parent topic: Developing an Alluxio Application
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.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot