HDFS Client in Java

Java client for working Hadoop Distributed File System

License

License

MIT
Categories

Categories

Java Languages CLI User Interface
GroupId

GroupId

com.github.chen0040
ArtifactId

ArtifactId

java-hdfs-client
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

HDFS Client in Java
Java client for working Hadoop Distributed File System
Project URL

Project URL

https://github.com/chen0040/java-hdfs-client
Source Code Management

Source Code Management

https://github.com/chen0040/java-hdfs-client

Download java-hdfs-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.chen0040/java-hdfs-client/ -->
<dependency>
    <groupId>com.github.chen0040</groupId>
    <artifactId>java-hdfs-client</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.chen0040/java-hdfs-client/
implementation 'com.github.chen0040:java-hdfs-client:1.0.1'
// https://jarcasting.com/artifacts/com.github.chen0040/java-hdfs-client/
implementation ("com.github.chen0040:java-hdfs-client:1.0.1")
'com.github.chen0040:java-hdfs-client:jar:1.0.1'
<dependency org="com.github.chen0040" name="java-hdfs-client" rev="1.0.1">
  <artifact name="java-hdfs-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.chen0040', module='java-hdfs-client', version='1.0.1')
)
libraryDependencies += "com.github.chen0040" % "java-hdfs-client" % "1.0.1"
[com.github.chen0040/java-hdfs-client "1.0.1"]

Dependencies

compile (5)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.20
org.slf4j : slf4j-log4j12 jar 1.7.20
org.apache.hadoop : hadoop-hdfs jar 2.6.0
org.apache.hadoop : hadoop-client jar 2.6.0
net.lingala.zip4j : zip4j jar 1.3.2

test (10)

Group / Artifact Type Version
org.testng : testng jar 6.9.10
org.hamcrest : hamcrest-core jar 1.3
org.hamcrest : hamcrest-library jar 1.3
org.assertj : assertj-core jar 3.5.2
org.powermock : powermock-core jar 1.6.5
org.powermock : powermock-api-mockito jar 1.6.5
org.powermock : powermock-module-junit4 jar 1.6.5
org.powermock : powermock-module-testng jar 1.6.5
org.mockito : mockito-core jar 2.0.2-beta
org.mockito : mockito-all jar 2.0.2-beta

Project Modules

There are no modules declared in this project.

java-hdfs-client

Java hadoop client that provides convenients api for file management and interaction with hadoop file system

Install

Add the following dependency to your pom file:

<dependency>
    <groupId>com.github.chen0040</groupId>
    <artifactId>java-hdfs-client</artifactId>
    <version>1.0.1</version>
</dependency>

Usage

To copy local file to hdfs:

String hdfsUri = "hdfs://10.0.1.23:9000/";
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("/tmp/test.txt")));
writer.write("Hello World");
writer.close();

HadoopProperties properties = new HadoopProperties();
properties.setUri(hdfsUri);
properties.setUsername("hadoop");

HadoopFileUtils.copyFromLocalToHdfs(properties, "/tmp/test.txt", "/tmp/test.txt");

To copy a file from hdfs to local disk:

HadoopProperties properties = new HadoopProperties();
properties.setUri(hdfsUri);
properties.setUsername("hadoop");

HadoopFileUtils.copyFromHdfsToLocal(properties, "/tmp/test.txt", "/tmp/test.txt");

To check if a file exists in hdfs

HadoopProperties properties = new HadoopProperties();
properties.setUri(hdfsUri);
properties.setUsername("hadoop");

boolean exists = HadoopFileUtils.pathExistsOnHdfs(properties, "/tmp/test.txt");

To delete a file in hdfs:

String hdfsUri = "hdfs://10.0.1.23:9000/";
HadoopProperties properties = new HadoopProperties();
properties.setUri(hdfsUri);
properties.setUsername("hadoop");

HadoopFileUtils.deleteHdfsFile(properties, "/tmp/test.txt");

Versions

Version
1.0.1