SortedSet<String> logQueue = new TreeSet<>(); listOfOps.add(ZKUtilOp.createAndFailSilent(newQueueNode, HConstants.EMPTY_BYTE_ARRAY)); LOG.debug("Creating {} with data {}", wal, Bytes.toStringBinary(logOffset)); String newWalNode = getFileNode(newQueueNode, wal); listOfOps.add(ZKUtilOp.createAndFailSilent(newWalNode, logOffset)); listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldWalNode)); logQueue.add(wal); listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldQueueNode));
ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); ZKUtil.multiOrSequential(zkw, ops, false); String pathW = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureW"); ops = new LinkedList<>(); ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); // fail -- already exists ops.add(ZKUtilOp.setData(pathY, Bytes.toBytes(pathY))); // fail -- doesn't exist ops.add(ZKUtilOp.deleteNodeFailSilent(pathZ)); // fail -- doesn't exist ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathV))); // pass ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathW))); // pass boolean caughtNodeExists = false; try { ops.add(ZKUtilOp.setData(pathY, Bytes.toBytes(pathY))); // fail -- doesn't exist ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); // fail -- exists boolean caughtNoNode = false; try {
List<String> wals = ZKUtil.listChildrenNoWatch(this.zookeeper, oldClusterZnode); if (wals == null || wals.size() == 0) { listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldClusterZnode)); continue; // empty log queue. ZKUtilOp op = ZKUtilOp.createAndFailSilent(newPeerZnode, HConstants.EMPTY_BYTE_ARRAY); listOfOps.add(op); LOG.debug("Creating " + wal + " with data " + Bytes.toString(logOffset)); String newLogZnode = ZKUtil.joinZNode(newPeerZnode, wal); listOfOps.add(ZKUtilOp.createAndFailSilent(newLogZnode, logOffset)); listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldWalZnode)); logQueue.add(wal); listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldClusterZnode)); listOfOps.add(ZKUtilOp.deleteNodeFailSilent(deadRSZnodePath)); if (LOG.isTraceEnabled()) LOG.trace(" The multi list size is: " + listOfOps.size()); ZKUtil.multiOrSequential(this.zookeeper, listOfOps, false);
ops.add(ZKUtilOp.deleteNodeFailSilent(children.get(i))); ops.add(ZKUtilOp.deleteNodeFailSilent(eachRoot));
ops.add(ZKUtilOp.deleteNodeFailSilent(children.get(i)));
ops.add(ZKUtilOp.deleteNodeFailSilent(children.get(i))); ops.add(ZKUtilOp.deleteNodeFailSilent(eachRoot));
ZKUtilOp op = ZKUtilOp.createAndFailSilent(newPeerZnode, HConstants.EMPTY_BYTE_ARRAY); listOfOps.add(op); LOG.debug("Creating " + hlog + " with data " + Bytes.toString(logOffset)); String newLogZnode = ZKUtil.joinZNode(newPeerZnode, hlog); listOfOps.add(ZKUtilOp.createAndFailSilent(newLogZnode, logOffset)); listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldHlogZnode)); logQueue.add(hlog); listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldClusterZnode)); listOfOps.add(ZKUtilOp.deleteNodeFailSilent(deadRSZnodePath)); LOG.debug(" The multi list size is: " + listOfOps.size()); ZKUtil.multiOrSequential(this.zookeeper, listOfOps, false);
SortedSet<String> logQueue = new TreeSet<>(); listOfOps.add(ZKUtilOp.createAndFailSilent(newQueueNode, HConstants.EMPTY_BYTE_ARRAY)); LOG.debug("Creating {} with data {}", wal, Bytes.toStringBinary(logOffset)); String newWalNode = getFileNode(newQueueNode, wal); listOfOps.add(ZKUtilOp.createAndFailSilent(newWalNode, logOffset)); listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldWalNode)); logQueue.add(wal); listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldQueueNode));
ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); ZKUtil.multiOrSequential(zkw, ops, false); String pathW = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testMultiFailureW"); ops = new LinkedList<>(); ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); // fail -- already exists ops.add(ZKUtilOp.setData(pathY, Bytes.toBytes(pathY))); // fail -- doesn't exist ops.add(ZKUtilOp.deleteNodeFailSilent(pathZ)); // fail -- doesn't exist ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathV))); // pass ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathW))); // pass boolean caughtNodeExists = false; try { ops.add(ZKUtilOp.setData(pathY, Bytes.toBytes(pathY))); // fail -- doesn't exist ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); // fail -- exists boolean caughtNoNode = false; try {
if(!newGroupMap.containsKey(groupName)) { String znode = ZNodePaths.joinZNode(groupBasePath, groupName); zkOps.add(ZKUtil.ZKUtilOp.deleteNodeFailSilent(znode)); LOG.debug("Updating znode: "+znode); ZKUtil.createAndFailSilent(watcher, znode); zkOps.add(ZKUtil.ZKUtilOp.deleteNodeFailSilent(znode)); zkOps.add(ZKUtil.ZKUtilOp.createAndFailSilent(znode, ProtobufUtil.prependPBMagic(proto.toByteArray())));
ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); ZKUtil.multiOrSequential(zkw, ops, false); String pathW = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testMultiFailureW"); ops = new LinkedList<>(); ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); // fail -- already exists ops.add(ZKUtilOp.setData(pathY, Bytes.toBytes(pathY))); // fail -- doesn't exist ops.add(ZKUtilOp.deleteNodeFailSilent(pathZ)); // fail -- doesn't exist ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathV))); // pass ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathW))); // pass boolean caughtNodeExists = false; try { ops.add(ZKUtilOp.setData(pathY, Bytes.toBytes(pathY))); // fail -- doesn't exist ops.add(ZKUtilOp.createAndFailSilent(pathX, Bytes.toBytes(pathX))); // fail -- exists boolean caughtNoNode = false; try {
ops.add(ZKUtilOp.deleteNodeFailSilent(children.get(i)));
if(!newGroupMap.containsKey(groupName)) { String znode = ZNodePaths.joinZNode(groupBasePath, groupName); zkOps.add(ZKUtil.ZKUtilOp.deleteNodeFailSilent(znode)); LOG.debug("Updating znode: "+znode); ZKUtil.createAndFailSilent(watcher, znode); zkOps.add(ZKUtil.ZKUtilOp.deleteNodeFailSilent(znode)); zkOps.add(ZKUtil.ZKUtilOp.createAndFailSilent(znode, ProtobufUtil.prependPBMagic(proto.toByteArray())));
create4Nodes.add(ZKUtilOp.createAndFailSilent(path1, Bytes.toBytes(path1))); create4Nodes.add(ZKUtilOp.createAndFailSilent(path2, Bytes.toBytes(path2))); create4Nodes.add(ZKUtilOp.createAndFailSilent(path3, Bytes.toBytes(path3))); create4Nodes.add(ZKUtilOp.createAndFailSilent(path4, Bytes.toBytes(path4))); ZKUtil.multiOrSequential(zkw, create4Nodes, false); assertTrue(Bytes.equals(ZKUtil.getData(zkw, path1), Bytes.toBytes(path1))); ops.add(ZKUtilOp.setData(path1, Bytes.add(Bytes.toBytes(path1), Bytes.toBytes(path1)))); ops.add(ZKUtilOp.setData(path2, Bytes.add(Bytes.toBytes(path2), Bytes.toBytes(path2)))); ops.add(ZKUtilOp.deleteNodeFailSilent(path3)); ops.add(ZKUtilOp.deleteNodeFailSilent(path4)); ops.add(ZKUtilOp.createAndFailSilent(path5, Bytes.toBytes(path5))); ops.add(ZKUtilOp.createAndFailSilent(path6, Bytes.toBytes(path6))); ZKUtil.multiOrSequential(zkw, ops, false); assertTrue(Bytes.equals(ZKUtil.getData(zkw, path1),
create4Nodes.add(ZKUtilOp.createAndFailSilent(path1, Bytes.toBytes(path1))); create4Nodes.add(ZKUtilOp.createAndFailSilent(path2, Bytes.toBytes(path2))); create4Nodes.add(ZKUtilOp.createAndFailSilent(path3, Bytes.toBytes(path3))); create4Nodes.add(ZKUtilOp.createAndFailSilent(path4, Bytes.toBytes(path4))); ZKUtil.multiOrSequential(zkw, create4Nodes, false); assertTrue(Bytes.equals(ZKUtil.getData(zkw, path1), Bytes.toBytes(path1))); ops.add(ZKUtilOp.setData(path1, Bytes.add(Bytes.toBytes(path1), Bytes.toBytes(path1)))); ops.add(ZKUtilOp.setData(path2, Bytes.add(Bytes.toBytes(path2), Bytes.toBytes(path2)))); ops.add(ZKUtilOp.deleteNodeFailSilent(path3)); ops.add(ZKUtilOp.deleteNodeFailSilent(path4)); ops.add(ZKUtilOp.createAndFailSilent(path5, Bytes.toBytes(path5))); ops.add(ZKUtilOp.createAndFailSilent(path6, Bytes.toBytes(path6))); ZKUtil.multiOrSequential(zkw, ops, false); assertTrue(Bytes.equals(ZKUtil.getData(zkw, path1),
ZKUtilOp op1 = ZKUtilOp.createAndFailSilent(ZKUtil.joinZNode(this.peersZNode, id), toByteArray(peerConfig)); ZKUtilOp op2 = ZKUtilOp.createAndFailSilent(getPeerStateNode(id), ENABLED_ZNODE_BYTES); String tableCFsStr = (tableCFs == null) ? "" : tableCFs; ZKUtilOp op3 = ZKUtilOp.createAndFailSilent(getTableCFsNode(id), Bytes.toBytes(tableCFsStr)); listOfOps.add(op1); listOfOps.add(op2);
List<ZKUtilOp> ops = new LinkedList<ZKUtilOp>(); if (settingToEnabled) { ops.add(ZKUtilOp.deleteNodeFailSilent(znode92)); ops.add(ZKUtilOp.setData(znode92, Bytes.toBytes(state.toString()))); ops.add(ZKUtilOp.setData(znode, Bytes.toBytes(state.toString()))); ZKUtil.multiOrSequential(this.watcher, ops, true); this.cache.put(tableName, state);
String path = ZNodePaths.joinZNode(zkw.znodePaths.baseZNode, "testSingleFailureZ"); LinkedList<ZKUtilOp> ops = new LinkedList<>(); ops.add(ZKUtilOp.deleteNodeFailSilent(path)); try { ZKUtil.multiOrSequential(zkw, ops, false); ops.add(ZKUtilOp.setData(path, Bytes.toBytes(path))); try { ZKUtil.multiOrSequential(zkw, ops, false); ops.add(ZKUtilOp.createAndFailSilent(path, Bytes.toBytes(path))); ZKUtil.multiOrSequential(zkw, ops, false); try {
@Override public void setWALPosition(ServerName serverName, String queueId, String fileName, long position, Map<String, Long> lastSeqIds) throws ReplicationException { try { for (int retry = 0;; retry++) { List<ZKUtilOp> listOfOps = new ArrayList<>(); if (position > 0) { listOfOps.add(ZKUtilOp.setData(getFileNode(serverName, queueId, fileName), ZKUtil.positionToByteArray(position))); } // Persist the max sequence id(s) of regions for serial replication atomically. addLastSeqIdsToOps(queueId, lastSeqIds, listOfOps); if (listOfOps.isEmpty()) { return; } try { ZKUtil.multiOrSequential(zookeeper, listOfOps, false); return; } catch (KeeperException.BadVersionException | KeeperException.NodeExistsException e) { LOG.warn( "Bad version(or node exist) when persist the last pushed sequence id to zookeeper storage, " + "Retry = " + retry + ", serverName=" + serverName + ", queueId=" + queueId + ", fileName=" + fileName); } } } catch (KeeperException e) { throw new ReplicationException("Failed to set log position (serverName=" + serverName + ", queueId=" + queueId + ", fileName=" + fileName + ", position=" + position + ")", e); } }
String path = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSingleFailureZ"); LinkedList<ZKUtilOp> ops = new LinkedList<>(); ops.add(ZKUtilOp.deleteNodeFailSilent(path)); try { ZKUtil.multiOrSequential(zkw, ops, false); ops.add(ZKUtilOp.setData(path, Bytes.toBytes(path))); try { ZKUtil.multiOrSequential(zkw, ops, false); ops.add(ZKUtilOp.createAndFailSilent(path, Bytes.toBytes(path))); ZKUtil.multiOrSequential(zkw, ops, false); try {