Zookeeper, mail # user - Re: newbie question: how to save a file using zookeeper - 2014-05-19, 21:53
 Search Hadoop and all its subprojects:

Switch to Threaded View
Copy link to this message
-
Re: newbie question: how to save a file using zookeeper
via zkCli.sh you can easily save a string as a value using the create
command.

create /testdir "this is a string"

As far as loading a file into a zNode, it's just a matter of reading the
file into an array of bytes and then creating the zNode with that array of
bytes. I haven't used the native zookeeper client, but it's simple enough
with Apache Curator.

CuratorFramework curator = ... //Initialise your client

byte[] fileContents = readFileContent();

curator.create().forPath("/testdir", fileContents);

To read the data out

byte[] fileContents = curator.getData().forPath("/testdir");

cheers
On Mon, May 19, 2014 at 4:17 PM, xytd <[EMAIL PROTECTED]> wrote:
 
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB