/** * Convert Iterable of {@link org.apache.zookeeper.Op} we got into the ZooKeeper.Op * instances to actually pass to multi (need to do this in order to appendMetaData). */ private Iterable<Op> prepareZKMulti(Iterable<Op> ops) throws UnsupportedOperationException { if(ops == null) { return null; } List<Op> preparedOps = new LinkedList<>(); for (Op op : ops) { if (op.getType() == ZooDefs.OpCode.create) { CreateRequest create = (CreateRequest)op.toRequestRecord(); preparedOps.add(Op.create(create.getPath(), ZKMetadata.appendMetaData(id, create.getData()), create.getAcl(), create.getFlags())); } else if (op.getType() == ZooDefs.OpCode.delete) { // no need to appendMetaData for delete preparedOps.add(op); } else if (op.getType() == ZooDefs.OpCode.setData) { SetDataRequest setData = (SetDataRequest)op.toRequestRecord(); preparedOps.add(Op.setData(setData.getPath(), ZKMetadata.appendMetaData(id, setData.getData()), setData.getVersion())); } else { throw new UnsupportedOperationException("Unexpected ZKOp type: " + op.getClass().getName()); } } return preparedOps; }
private static void createAndFailSilent(ZKWatcher zkw, CreateAndFailSilent cafs) throws KeeperException { CreateRequest create = (CreateRequest)toZooKeeperOp(zkw, cafs).toRequestRecord(); String znode = create.getPath(); try { RecoverableZooKeeper zk = zkw.getRecoverableZooKeeper(); if (zk.exists(znode, false) == null) { zk.create(znode, create.getData(), create.getAcl(), CreateMode.fromFlag(create.getFlags())); } } catch(KeeperException.NodeExistsException nee) { } catch(KeeperException.NoAuthException nee){ try { if (null == zkw.getRecoverableZooKeeper().exists(znode, false)) { // If we failed to create the file and it does not already exist. throw(nee); } } catch (InterruptedException ie) { zkw.interruptedException(ie); } } catch(InterruptedException ie) { zkw.interruptedException(ie); } }
throw new KeeperException.BadArgumentsException(path); List<ACL> listACL = removeDuplicates(createRequest.getAcl()); if (!fixupACL(request.authInfo, listACL)) { throw new KeeperException.InvalidACLException(path);
CreateRequest cr = new CreateRequest(); cr.deserialize(archive, tag); add(Op.create(cr.getPath(), cr.getData(), cr.getAcl(), cr.getFlags())); break; case ZooDefs.OpCode.delete:
CreateRequest cr = new CreateRequest(); cr.deserialize(archive, tag); add(Op.create(cr.getPath(), cr.getData(), cr.getAcl(), cr.getFlags())); break; case ZooDefs.OpCode.createTTL:
flags = createRequest.getFlags(); path = createRequest.getPath(); acl = createRequest.getAcl(); data = createRequest.getData(); ttl = -1;
schema.validateCreate(createMode, createRequest.getPath(), createRequest.getData(), createRequest.getAcl());
/** * Convert Iterable of {@link ZKOp} we got into the ZooKeeper.Op * instances to actually pass to multi (need to do this in order to appendMetaData). */ private Iterable<Op> prepareZKMulti(Iterable<Op> ops) throws UnsupportedOperationException { if (ops == null) return null; List<Op> preparedOps = new LinkedList<Op>(); for (Op op : ops) { if (op.getType() == ZooDefs.OpCode.create) { CreateRequest create = (CreateRequest) op.toRequestRecord(); preparedOps.add(Op.create(create.getPath(), appendMetaData(create.getData()), create.getAcl(), create.getFlags())); } else if (op.getType() == ZooDefs.OpCode.delete) { // no need to appendMetaData for delete preparedOps.add(op); } else if (op.getType() == ZooDefs.OpCode.setData) { SetDataRequest setData = (SetDataRequest) op.toRequestRecord(); preparedOps.add(Op.setData(setData.getPath(), appendMetaData(setData.getData()), setData.getVersion())); } else { throw new UnsupportedOperationException("Unexpected ZKOp type: " + op.getClass().getName()); } } return preparedOps; }
/** * Convert Iterable of {@link ZKOp} we got into the ZooKeeper.Op * instances to actually pass to multi (need to do this in order to appendMetaData). */ private Iterable<Op> prepareZKMulti(Iterable<Op> ops) throws UnsupportedOperationException { if(ops == null) return null; List<Op> preparedOps = new LinkedList<Op>(); for (Op op : ops) { if (op.getType() == ZooDefs.OpCode.create) { CreateRequest create = (CreateRequest)op.toRequestRecord(); preparedOps.add(Op.create(create.getPath(), appendMetaData(create.getData()), create.getAcl(), create.getFlags())); } else if (op.getType() == ZooDefs.OpCode.delete) { // no need to appendMetaData for delete preparedOps.add(op); } else if (op.getType() == ZooDefs.OpCode.setData) { SetDataRequest setData = (SetDataRequest)op.toRequestRecord(); preparedOps.add(Op.setData(setData.getPath(), appendMetaData(setData.getData()), setData.getVersion())); } else { throw new UnsupportedOperationException("Unexpected ZKOp type: " + op.getClass().getName()); } } return preparedOps; }
/** * Convert Iterable of {@link org.apache.zookeeper.Op} we got into the ZooKeeper.Op * instances to actually pass to multi (need to do this in order to appendMetaData). */ private Iterable<Op> prepareZKMulti(Iterable<Op> ops) throws UnsupportedOperationException { if(ops == null) { return null; } List<Op> preparedOps = new LinkedList<>(); for (Op op : ops) { if (op.getType() == ZooDefs.OpCode.create) { CreateRequest create = (CreateRequest)op.toRequestRecord(); preparedOps.add(Op.create(create.getPath(), ZKMetadata.appendMetaData(id, create.getData()), create.getAcl(), create.getFlags())); } else if (op.getType() == ZooDefs.OpCode.delete) { // no need to appendMetaData for delete preparedOps.add(op); } else if (op.getType() == ZooDefs.OpCode.setData) { SetDataRequest setData = (SetDataRequest)op.toRequestRecord(); preparedOps.add(Op.setData(setData.getPath(), ZKMetadata.appendMetaData(id, setData.getData()), setData.getVersion())); } else { throw new UnsupportedOperationException("Unexpected ZKOp type: " + op.getClass().getName()); } } return preparedOps; }
/** * Convert Iterable of {@link ZKOp} we got into the ZooKeeper.Op * instances to actually pass to multi (need to do this in order to appendMetaData). */ private Iterable<Op> prepareZKMulti(Iterable<Op> ops) throws UnsupportedOperationException { if(ops == null) return null; List<Op> preparedOps = new LinkedList<Op>(); for (Op op : ops) { if (op.getType() == ZooDefs.OpCode.create) { CreateRequest create = (CreateRequest)op.toRequestRecord(); preparedOps.add(Op.create(create.getPath(), appendMetaData(create.getData()), create.getAcl(), create.getFlags())); } else if (op.getType() == ZooDefs.OpCode.delete) { // no need to appendMetaData for delete preparedOps.add(op); } else if (op.getType() == ZooDefs.OpCode.setData) { SetDataRequest setData = (SetDataRequest)op.toRequestRecord(); preparedOps.add(Op.setData(setData.getPath(), appendMetaData(setData.getData()), setData.getVersion())); } else { throw new UnsupportedOperationException("Unexpected ZKOp type: " + op.getClass().getName()); } } return preparedOps; }
private static void createAndFailSilent(ZooKeeperWatcher zkw, CreateAndFailSilent cafs) throws KeeperException { CreateRequest create = (CreateRequest)toZooKeeperOp(zkw, cafs).toRequestRecord(); String znode = create.getPath(); try { RecoverableZooKeeper2 zk = zkw.getRecoverableZooKeeper2(); if (zk.exists(znode, false) == null) { zk.create(znode, create.getData(), create.getAcl(), CreateMode.fromFlag(create.getFlags())); } } catch(KeeperException.NodeExistsException nee) { } catch(KeeperException.NoAuthException nee){ try { if (null == zkw.getRecoverableZooKeeper2().exists(znode, false)) { // If we failed to create the file and it does not already exist. throw(nee); } } catch (InterruptedException ie) { zkw.interruptedException(ie); } } catch(InterruptedException ie) { zkw.interruptedException(ie); } }
private static void createAndFailSilent(ZKWatcher zkw, CreateAndFailSilent cafs) throws KeeperException { CreateRequest create = (CreateRequest)toZooKeeperOp(zkw, cafs).toRequestRecord(); String znode = create.getPath(); try { RecoverableZooKeeper zk = zkw.getRecoverableZooKeeper(); if (zk.exists(znode, false) == null) { zk.create(znode, create.getData(), create.getAcl(), CreateMode.fromFlag(create.getFlags())); } } catch(KeeperException.NodeExistsException nee) { } catch(KeeperException.NoAuthException nee){ try { if (null == zkw.getRecoverableZooKeeper().exists(znode, false)) { // If we failed to create the file and it does not already exist. throw(nee); } } catch (InterruptedException ie) { zkw.interruptedException(ie); } } catch(InterruptedException ie) { zkw.interruptedException(ie); } }
private static void createAndFailSilent(ZooKeeperWatcher zkw, CreateAndFailSilent cafs) throws KeeperException { CreateRequest create = (CreateRequest)toZooKeeperOp(zkw, cafs).toRequestRecord(); String znode = create.getPath(); try { RecoverableZooKeeper zk = zkw.getRecoverableZooKeeper(); if (zk.exists(znode, false) == null) { zk.create(znode, create.getData(), create.getAcl(), CreateMode.fromFlag(create.getFlags())); } } catch(KeeperException.NodeExistsException nee) { } catch(KeeperException.NoAuthException nee){ try { if (null == zkw.getRecoverableZooKeeper().exists(znode, false)) { // If we failed to create the file and it does not already exist. throw(nee); } } catch (InterruptedException ie) { zkw.interruptedException(ie); } } catch(InterruptedException ie) { zkw.interruptedException(ie); } }
private static void createAndFailSilent(ZooKeeperWatcher zkw, CreateAndFailSilent cafs) throws KeeperException { CreateRequest create = (CreateRequest)toZooKeeperOp(zkw, cafs).toRequestRecord(); String znode = create.getPath(); try { RecoverableZooKeeper zk = zkw.getRecoverableZooKeeper(); if (zk.exists(znode, false) == null) { zk.create(znode, create.getData(), create.getAcl(), CreateMode.fromFlag(create.getFlags())); } } catch(KeeperException.NodeExistsException nee) { } catch(KeeperException.NoAuthException nee){ try { if (null == zkw.getRecoverableZooKeeper().exists(znode, false)) { // If we failed to create the file and it does not already exist. throw(nee); } } catch (InterruptedException ie) { zkw.interruptedException(ie); } } catch(InterruptedException ie) { zkw.interruptedException(ie); } }
throw new KeeperException.BadArgumentsException(path); if (!fixupACL(request.authInfo, createRequest.getAcl())) { throw new KeeperException.InvalidACLException(path); createRequest.getAcl(), createMode.isEphemeral()); StatPersisted s = new StatPersisted(); addChangeRecord(parentRecord); addChangeRecord(new ChangeRecord(txnHeader.getZxid(), path, s, 0, createRequest.getAcl()));