Skip to content

gruzovator/webhdfs-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ WebHDFS Client

Simple libcurl wrapper to access HDFS via REST API.

Build requirements

Build

To build static lib and demo application (webhdfs-client) run next commands:

mkdir build
cd build
cmake ..
make

Lib usage example

#include <iostream>
#include "WebHdfsClient.h"

int main(int argc, char** argv) {
    // print remote file to stdout
    WebHDFS::Client client("hd0-dev", 
                            WebHDFS::ClientOptions().setConnectTimeout(10).setUserName("alex"));
    client.readFile("/tmp/test.txt", std::cout);
    return 0;
}

Demo application webhdfs-client

Copy local file to hdfs:

./webhdfs-client cp /tmp/test.txt hdfs://hd0-dev/tmp/test.txt

Copy file from hdfs:

./webhdfs-client cp hdfs://hd0-dev/tmp/test.txt /tmp/test-copy.txt

List hdfs dir:

./webhdfs-client ls hdfs://hd0-dev/

Print hdfs file to stdout:

./webhdfs-client cat hdfs://hd0-dev/tmp/test.txt