Git Product home page Git Product logo

hdfs-java-api's Introduction

Java API Example for reading & writing files into HDFS

Step1: Download the Project

Goto any specific folder and download the project using git clone.

git clone https://github.com/rangareddy/hdfs-java-api.git

Step2: Build the Project

mvn clean package

Step3: Run the Project

java -jar target/hdfs-java-api-1.0-SNAPSHOT.jar hdfs://localhost:8020

Step4: Verify the output

2020-03-31 15:29:55 INFO  HDFSClient:59 - Configuration object built successfully with the params {fs.defaultFS=hdfs://localhost:8020} \
2020-03-31 15:29:55 WARN  NativeCodeLoader:60 - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable \
2020-03-31 15:29:56 INFO  HDFSJavaAPIDemo:33 - Creating a hdfs dir /ranga/hdfs/data/ \
2020-03-31 15:29:56 INFO  HDFSClient:53 - HDFS directory  created successfully. \
2020-03-31 15:29:56 INFO  HDFSJavaAPIDemo:36 - Creating a file /ranga/hdfs/data/README.md in hdfs. \
2020-03-31 15:29:57 INFO  HDFSClient:36 - HDFS directory  deleted successfully. \
2020-03-31 15:29:59 INFO  HDFSFileWriter:78 - Data is successfully written to hdfsPath  \
2020-03-31 15:29:59 INFO  HDFSJavaAPIDemo:45 - File  created successfully \
2020-03-31 15:29:59 INFO  HDFSJavaAPIDemo:47 - Reading data from hdfs file  \
2020-03-31 15:30:00 INFO  HDFSJavaAPIDemo:49 - File content \
2020-03-31 15:30:00 INFO  HDFSJavaAPIDemo:51 - Renaming a file \
2020-03-31 15:30:00 INFO  HDFSClient:67 - HDFS File /ranga/hdfs/data/README.md is successfully renamed to /ranga/hdfs/data/README_1.md \
2020-03-31 15:30:00 INFO  HDFSJavaAPIDemo:54 - Listing file(s) under  directory. \
2020-03-31 15:30:00 INFO  HDFSJavaAPIDemo:58 - hdfs://localhost:8020/ranga/hdfs/data/README_1.md \
2020-03-31 15:30:00 INFO  HDFSJavaAPIDemo:61 - Deleting a hdfs dir  \
2020-03-31 15:30:01 INFO  HDFSClient:36 - HDFS directory  deleted successfully. \

Note

If u want to use this code in production remove the following two lines from ConfigUtils.java file

System.setProperty("hadoop.home.dir", "/");
System.setProperty("HADOOP_USER_NAME", "hdfs");

hdfs-java-api's People

Contributors

rangareddy avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.