Hi folks,
I needed some help regarding creating default ZNode on Zookeeper server bootup.
I want to create a ZNode at some default path whenever zookeeper server boots
up. I tried couple of things but didn't work.
1. I tried to create using createNode API of DataTree but that didn't
reflect into actual ZNode creation.
2. I tried to create znode in DataTree constructor but that got overwritten
after snapshot restore while loading zkDatabase.
3. I tried to create Request using both supported ways but didn’t work. Here
are the code snippet and results:
* CreateRequest createRequest = new CreateRequest(rootPath, new byte[0],
ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT.toFlag());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
org.apache.jute.BinaryOutputArchive boa =
org.apache.jute.BinaryOutputArchive.getArchive(baos);
createRequest.serialize(boa, "request");
ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
Request request = new Request(null, 0, zks.getLastProcessedZxid(),
ZooDefs.OpCode.create, bb, new ArrayList<org.apache.zookeeper.data.Id>());
<Resulted into session time out error>
b. Request request = new Request(1, 1, ZooDefs.OpCode.create,
new org.apache.zookeeper.txn.TxnHeader(1, 1, zks.getZxid(), 1,
ZooDefs.OpCode.create),
new org.apache.zookeeper.txn.CreateTxn("/zookeeper/uri-domain-map", new
byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, false, 0), zks.getZxid());
// Submit request directly to leader
zks.submitRequest(request);
<Didn’t create any ZNode.>
Is there any recommended way to create ZNode by zookeeper server itself. Any
help/pointers would be much appreciated.
Thanks,
Rahul Rane