A native go client for HDFS
Перейти к файлу
Colin Marc 1406bb3801 update usage for rm -f 2014-11-04 00:40:15 +01:00
cmd/hdfs update usage for rm -f 2014-11-04 00:40:15 +01:00
protocol it works!!! 2014-10-06 03:33:48 +02:00
rpc use io.ReadFull when reading a response from the namenode 2014-10-26 18:27:51 +01:00
.gitignore ls and completion sort of working 2014-10-24 23:43:51 +02:00
.travis.yml attempt to fix travis 2014-10-31 20:15:04 +01:00
Makefile remove GOCMD nonsense 2014-11-01 19:43:24 +01:00
README.md use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00
client.go use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00
client_test.go use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00
exceptions.go improve exception handling by switching on the exception class name 2014-10-13 12:05:22 +02:00
filereader.go refactor out caching in cmd/hdfs 2014-10-31 20:46:22 +01:00
filereader_test.go use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00
hdfs.go log doesn't make sense for examples 2014-10-14 16:15:18 +02:00
mkdir.go use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00
mkdir_test.go Handle the directory bit of os.FileMode correctly 2014-10-28 14:37:31 +01:00
perms.go use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00
perms_test.go properly interpret exceptions in remove 2014-10-31 18:43:20 +01:00
readdir.go use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00
readdir_test.go use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00
remove.go properly interpret exceptions in remove 2014-10-31 18:43:20 +01:00
remove_test.go use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00
rename.go use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00
rename_test.go use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00
setup_test_env.sh give the minicluster more time to start up in tests 2014-10-13 17:25:46 +02:00
stat.go Handle the directory bit of os.FileMode correctly 2014-10-28 14:37:31 +01:00
stat_test.go use os.PathError ~everywhere 2014-10-28 13:49:30 +01:00

README.md

HDFS for Go

build

hdfs is a native go client for hdfs, using the protocol buffers interface the namenode provides. It implements protocol version 9, which means it supports Hadoop 2.0.0 and up (including CDH5).

It tries to be idiomatic by aping the stdlib os package where possible. This includes implementing os.FileInfo for file status, and returning errors of type os.PathErrors for missing files, for example.

The best place to get started is the Godoc.


client, _ := hdfs.New("namenode:8020")

file, _ := client.Open("/mobydick.txt")

buf := make([]byte, 59)
file.ReadAt(buf, 48847)

fmt.Println(string(buf))
// => Abominable are the tumblers into which he pours his poison.

The hdfs Binary

The library also ships with a command line client for hdfs. Like the library, its primary aim is to be idiomatic, by enabling your favorite unix verbs:

$ hdfs --help
Usage: ./hdfs COMMAND
The flags available are a subset of the POSIX ones, but should behave similarly.

Valid commands:
  ls [-la] [FILE]...
  rm [-r] FILE...
  mv [-fT] SOURCE... DEST
  mkdir [-p] FILE...
  touch [-amc] FILE...
  chmod [-R] OCTAL-MODE FILE...
  chown [-R] OWNER[:GROUP] FILE...
  cat SOURCE...
  head [-n LINES | -c BYTES] SOURCE...
  tail [-n LINES | -c BYTES] SOURCE...
  get SOURCE [DEST]
  getmerge SOURCE DEST

It's also pretty fast compared to hadoop -fs, and, best of all, comes with bash tab completion!

You can install it with go get github.com/colinmarc/hdfs, or by cloning and running make install. Alternatively, running make will create a binary in the source directory, so you can install it where you want.

To enable tab completion, source cmd/hdfs/bash_completion, or drop it into the bash completion directory for your platform (on linux, this is usually /etc/bash_completion.d).

Acknowledgements

This library is heavily indebted to snakebite.