switch (h.getType()) { case ZooDefs.OpCode.create: CreateResponse cr = new CreateResponse(); cr.deserialize(archive, tag); results.add(new OpResult.CreateResult(cr.getPath())); break;
public void write(java.io.DataOutput out) throws java.io.IOException { BinaryOutputArchive archive = new BinaryOutputArchive(out); serialize(archive, ""); } public void readFields(java.io.DataInput in) throws java.io.IOException {
h.setType(createMode.isContainer() ? ZooDefs.OpCode.createContainer : ZooDefs.OpCode.create); CreateRequest request = new CreateRequest(); CreateResponse response = new CreateResponse(); request.setData(data); request.setFlags(createMode.toFlag()); return response.getPath(); } else { return response.getPath().substring(cnxn.chrootPath.length());
/** * The asynchronous version of create. * * @see #create(String, byte[], List, CreateMode) */ public void create(final String path, byte data[], List<ACL> acl, CreateMode createMode, StringCallback cb, Object ctx) { final String clientPath = path; PathUtils.validatePath(clientPath, createMode.isSequential()); EphemeralType.validateTTL(createMode, -1); final String serverPath = prependChroot(clientPath); RequestHeader h = new RequestHeader(); h.setType(createMode.isContainer() ? ZooDefs.OpCode.createContainer : ZooDefs.OpCode.create); CreateRequest request = new CreateRequest(); CreateResponse response = new CreateResponse(); ReplyHeader r = new ReplyHeader(); request.setData(data); request.setFlags(createMode.toFlag()); request.setPath(serverPath); request.setAcl(acl); cnxn.queuePacket(h, r, request, response, cb, clientPath, serverPath, ctx, null); }
new CreateResponse(((OpResult.CreateResult) result).getPath()).serialize(archive, tag); break; case ZooDefs.OpCode.create2:
public void readFields(java.io.DataInput in) throws java.io.IOException { BinaryInputArchive archive = new BinaryInputArchive(in); deserialize(archive, ""); } public int compareTo (Object peer_) throws ClassCastException {
h.setType(ZooDefs.OpCode.create); CreateRequest request = new CreateRequest(); CreateResponse response = new CreateResponse(); request.setData(data); request.setFlags(createMode.toFlag()); return response.getPath(); } else { return response.getPath().substring(cnxn.chrootPath.length());
/** * The asynchronous version of create. * * @see #create(String, byte[], List, CreateMode) */ public void create(final String path, byte data[], List<ACL> acl, CreateMode createMode, StringCallback cb, Object ctx) { final String clientPath = path; PathUtils.validatePath(clientPath, createMode.isSequential()); final String serverPath = prependChroot(clientPath); RequestHeader h = new RequestHeader(); h.setType(ZooDefs.OpCode.create); CreateRequest request = new CreateRequest(); CreateResponse response = new CreateResponse(); ReplyHeader r = new ReplyHeader(); request.setData(data); request.setFlags(createMode.toFlag()); request.setPath(serverPath); request.setAcl(acl); cnxn.queuePacket(h, r, request, response, cb, clientPath, serverPath, ctx, null); }
@Override public void serialize(OutputArchive archive, String tag) throws IOException { archive.startRecord(this, tag); int index = 0; for (OpResult result : results) { int err = result.getType() == ZooDefs.OpCode.error ? ((OpResult.ErrorResult)result).getErr() : 0; new MultiHeader(result.getType(), false, err).serialize(archive, tag); switch (result.getType()) { case ZooDefs.OpCode.create: new CreateResponse(((OpResult.CreateResult) result).getPath()).serialize(archive, tag); break; case ZooDefs.OpCode.delete: case ZooDefs.OpCode.check: break; case ZooDefs.OpCode.setData: new SetDataResponse(((OpResult.SetDataResult) result).getStat()).serialize(archive, tag); break; case ZooDefs.OpCode.error: new ErrorResponse(((OpResult.ErrorResult) result).getErr()).serialize(archive, tag); break; default: throw new IOException("Invalid type " + result.getType() + " in MultiResponse"); } } new MultiHeader(-1, true, -1).serialize(archive, tag); archive.endRecord(this, tag); }
public void readFields(java.io.DataInput in) throws java.io.IOException { BinaryInputArchive archive = new BinaryInputArchive(in); deserialize(archive, ""); } public int compareTo (Object peer_) throws ClassCastException {
switch (h.getType()) { case ZooDefs.OpCode.create: CreateResponse cr = new CreateResponse(); cr.deserialize(archive, tag); results.add(new OpResult.CreateResult(cr.getPath())); break;
h.setType(ZooDefs.OpCode.create); CreateRequest request = new CreateRequest(); CreateResponse response = new CreateResponse(); request.setData(data); request.setFlags(createMode.toFlag()); return response.getPath(); } else { return response.getPath().substring(cnxn.chrootPath.length());
@Test public void testMaxTTLs() throws InterruptedException, KeeperException { RequestHeader h = new RequestHeader(1, ZooDefs.OpCode.createTTL); String path = "/bad_ttl"; CreateTTLRequest request = new CreateTTLRequest(path, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_WITH_TTL.toFlag(), EphemeralType.TTL.maxValue()); CreateResponse response = new CreateResponse(); ReplyHeader r = zk.submitRequest(h, request, response, null); Assert.assertEquals("EphemeralType.getMaxTTL() should succeed", r.getErr(), Code.OK.intValue()); Assert.assertNotNull("Node should exist", zk.exists(path, false)); }
public void readFields(java.io.DataInput in) throws java.io.IOException { BinaryInputArchive archive = new BinaryInputArchive(in); deserialize(archive, ""); } public int compareTo (Object peer_) throws ClassCastException {
public void write(java.io.DataOutput out) throws java.io.IOException { BinaryOutputArchive archive = new BinaryOutputArchive(out); serialize(archive, ""); } public void readFields(java.io.DataInput in) throws java.io.IOException {
@Test public void testBadTTLs() throws InterruptedException, KeeperException { RequestHeader h = new RequestHeader(1, ZooDefs.OpCode.createTTL); String path = "/bad_ttl"; CreateTTLRequest request = new CreateTTLRequest(path, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_WITH_TTL.toFlag(), -100); CreateResponse response = new CreateResponse(); ReplyHeader r = zk.submitRequest(h, request, response, null); Assert.assertEquals("An invalid CreateTTLRequest should throw BadArguments", r.getErr(), Code.BADARGUMENTS.intValue()); Assert.assertNull("An invalid CreateTTLRequest should not result in znode creation", zk.exists(path, false)); request = new CreateTTLRequest(path, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_WITH_TTL.toFlag(), EphemeralType.TTL.maxValue() + 1); response = new CreateResponse(); r = zk.submitRequest(h, request, response, null); Assert.assertEquals("An invalid CreateTTLRequest should throw BadArguments", r.getErr(), Code.BADARGUMENTS.intValue()); Assert.assertNull("An invalid CreateTTLRequest should not result in znode creation", zk.exists(path, false)); }
public void write(java.io.DataOutput out) throws java.io.IOException { BinaryOutputArchive archive = new BinaryOutputArchive(out); serialize(archive, ""); } public void readFields(java.io.DataInput in) throws java.io.IOException {