Code Monkey home page Code Monkey logo

hdfs's Introduction

hdfs

Golang wrapper for WebHDFS client

Usage

go get -u github.com/juragan360/hdfs

Connect to HDFS

h, e := NewHdfs(NewHdfsConfig("http://localhost:50070", "hadoopuser")) 
h, e := NewHdfs(NewHdfsConfig("http://localhost:50070", ""))  //--- automatically pass username from OS Context

Make a HDFS dir

es := h.MakeDirs([]string{"/user/ariefdarmawan/inbox", "/user/ariefdarmawan/inbox/temp", "user/ariefdarmawan/outbox", "user/ariefdarmawan/done"}, 0)
	
if es != nil {
	for k, v := range es {
		fmt.Printf("Error when create %v : %v \n", k, v)
	}
}

Put single file

err = h.Put("/users/ariefdarmawan/Temp/config.json", "/user/ariefdarmawan/inbox/temp/config.json", 0, map[string]string{"overwrite": "true"})

Put multiple files

fmt.Println(">>>> TEST PUT FILE<<<<")
es = h.Puts([]string{
	"/users/ariefdarmawan/Temp/config.json",
	"/users/ariefdarmawan/Temp/ecis_test.js",
}, "/user/ariefdarmawan/inbox/temp/", 0, nil)
if es != nil {
	for k, v := range es {
		t.Error(fmt.Sprintf("Error when write %v : %v \n", k, v))
	}
}

Read HDFS Status

hdata, _ := h.List("/user/ariefdarmawan")
fmt.Printf("Data:\n%v\n", hdata.FileStatuses.FileStatus)

hdfs's People

Contributors

ariefdarmawan avatar

Watchers

 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.