This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15082|Reply: 0

[Source] API operations for Hadoop - HDFS

[Copy link]
Posted on 7/5/2019 4:33:58 PM | | |
1. Introduce dependence

Note: If you need to manually import the jar package, the HDFS jar package ---- the Hadoop installation directory under share

2. Description of development under window

It is recommended to develop Hadoop applications under Linux, and there will be no compatibility issues. If you want to develop a client application on Windows, you need to set up the following environment:

A. Unzip a Hadoop installation package in a directory in Windows

B. Replace the lib and bin directories under the installation package with the local libraries compiled for the corresponding Windows version of the platform

C. Configure the HADOOP_HOME in the window system to point to the installation package you unzipped

D. Add Hadoop's bin directory to the path variable of Windows system


To operate HDFS in Java, you first need to get a client instance




Our operation target is HDFS, so the obtained fs object should be an instance of DistributedFileSystem.

Get method: Where does the specific instance client class come from?

- Judging from the configuration value of one of the parameters fs.defaultFS in conf;

If we do not specify fs.defaultFS in our code, and there is no corresponding configuration given under the project classpath, the default value in conf comes from the core-default.xml in the hadoop jar package, and the default value is: file:///, then the acquisition will not be an instance of DistributedFileSystem, but a client object of the local file system;


Addition, deletion, modification and inspection of documents

Access HDFS via stream







Previous:Hadoop HDFS Shell command rollup
Next:C# Http request Upload form file (additional parameters can be added)
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com