zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cameron McKenzie <mckenzie....@gmail.com>
Subject Re: newbie question: how to save a file using zookeeper
Date Mon, 19 May 2014 21:52:33 GMT
via zkCli.sh you can easily save a string as a value using the create

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");


On Mon, May 19, 2014 at 4:17 PM, xytd <yang.xiang@teradata.com> wrote:

> How do I serialize the contents of a file word by word to znodes?  I don't
> see a way using zkCli or kazoo to save a string as value in a znode such as
> set /testdir  "this is a string"
> Even better, is there a way to quickly dump a file by serializing into
> znode
> and vice versa? I don't like the idea of traversing through children and
> get
> the value and concat them.
> I understand hdfs might be a better solution for that purpose. but my file
> is under 1K and I would like to get the high performance out of zookeeper
> if
> I can.
> Thanks in advance,
> Yang
> --
> View this message in context:
> http://zookeeper-user.578899.n2.nabble.com/newbie-question-how-to-save-a-file-using-zookeeper-tp7579915.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message