java - How to store a list of strings in a single ZooKeeper znode using Curator -
for example, there znode path a/b/c/d
. i'd store list of strings on znode. obviously, use join list of strings single string , serialize byte array this:
curator.create() .creatingparentcontainersifneeded() .forpath(path, value.getbytes(standardcharsets.utf_8));
but looks not convenient. there other approach?
the easiest/best way use apacheutils:
byte[] input = serializationutils.serialize(yourlist); curator.create() .creatingparentcontainersifneeded() .forpath(path, input);
and out:
byte[] output = curator.getdata().forpath(path); list<string> newlist = (list<string>)serializationutils.deserialize(output);
this rather general aproach work java objects.
Comments
Post a Comment