本文整理了Java中com.liveramp.hank.zookeeper.ZooKeeperPlus.delete()
方法的一些代码示例,展示了ZooKeeperPlus.delete()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperPlus.delete()
方法的具体详情如下:
包路径:com.liveramp.hank.zookeeper.ZooKeeperPlus
类名称:ZooKeeperPlus
方法名:delete
暂无
代码示例来源:origin: LiveRamp/hank
public boolean delete() throws IOException {
try {
zk.delete(path, -1);
return true;
} catch (Exception e) {
throw new IOException(e);
}
}
}
代码示例来源:origin: LiveRamp/hank
public void deleteNodeRecursively(String path) throws InterruptedException, KeeperException {
try {
delete(path, -1);
} catch (KeeperException.NotEmptyException e) {
List<String> children = getChildren(path, null);
for (String child : children) {
deleteNodeRecursively(ZkPath.append(path, child));
}
delete(path, -1);
} catch (KeeperException.NoNodeException e) {
// Silently return if the node has already been deleted.
return;
}
}
代码示例来源:origin: LiveRamp/hank
public void deleteIfExists(String path) throws KeeperException, InterruptedException {
if (exists(path, false) != null) {
delete(path, -1);
}
}
代码示例来源:origin: LiveRamp/hank
@Override
public void releaseRingGroupConductor() throws IOException {
try {
if (zk.exists(ringGroupConductorOnlinePath, false) != null) {
zk.delete(ringGroupConductorOnlinePath, -1);
return;
}
throw new IllegalStateException(
"Can't release the ring group conductor lock when it's not currently set!");
} catch (Exception e) {
throw new IOException(e);
}
}
代码示例来源:origin: LiveRamp/hank
@Override
public void clearCommandQueue() throws IOException {
try {
List<String> children = zk.getChildren(ZkPath.append(path, COMMAND_QUEUE_PATH), false);
for (String child : children) {
zk.delete(ZkPath.append(path, COMMAND_QUEUE_PATH, child), 0);
}
} catch (Exception e) {
throw new IOException(e);
}
}
代码示例来源:origin: LiveRamp/hank
@Override
public HostCommand nextCommand() throws IOException {
try {
// get the queue and sort so we have correct ordering
List<String> children = zk.getChildren(ZkPath.append(path, COMMAND_QUEUE_PATH), false);
Collections.sort(children);
// if there are no children, the queue is empty.
if (children.size() == 0) {
currentCommand.set(null);
return null;
}
// parse out the actual command
String headOfQueuePath = ZkPath.append(path, COMMAND_QUEUE_PATH, children.get(0));
HostCommand nextCommand = HostCommand.valueOf(zk.getString(headOfQueuePath));
// set the current command first (modifying the queue will call the queue listeners)
currentCommand.set(nextCommand);
// delete the head of the queue
zk.delete(headOfQueuePath, -1);
return nextCommand;
} catch (Exception e) {
throw new IOException(e);
}
}
代码示例来源:origin: LiveRamp/hank
@Test
public void testDeletion() throws Exception {
getZk().create(ZkPath.append(getRoot(), "map"), null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
getZk().create(ZkPath.append(getRoot(), "map/1"), "2".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
final WatchedMap<String> m = new WatchedMap<>(getZk(), ZkPath.append(getRoot(), "map"), new StringElementLoader());
assertEquals(new HashMap<String, String>() {{
put("1", "2");
}}, m);
getZk().delete(ZkPath.append(getRoot(), "map/1"), 0);
WaitUntil.orDie(() -> Collections.EMPTY_MAP.equals(m));
assertEquals(Collections.EMPTY_MAP, m);
}
}
代码示例来源:origin: LiveRamp/hank
@Test
public void testClaimRingGroupConductor() throws Exception {
ZkDomainGroup dg = ZkDomainGroup.create(getZk(), null, dg_root, "blah");
dg.setDomainVersions(Collections.emptyMap());
final RingGroup rg = ZkRingGroup.create(getZk(), ring_group, dg, coordinator);
create(ZkPath.append(ring_group, ZkRingGroup.RING_GROUP_CONDUCTOR_ONLINE_PATH));
assertFalse(rg.claimRingGroupConductor(RingGroupConductorMode.ACTIVE));
getZk().delete(ZkPath.append(ring_group, ZkRingGroup.RING_GROUP_CONDUCTOR_ONLINE_PATH), -1);
assertTrue(rg.claimRingGroupConductor(RingGroupConductorMode.ACTIVE));
assertFalse(rg.claimRingGroupConductor(RingGroupConductorMode.ACTIVE));
rg.releaseRingGroupConductor();
assertTrue(rg.claimRingGroupConductor(RingGroupConductorMode.ACTIVE));
WaitUntil.orDie(() -> {
try {
return RingGroupConductorMode.ACTIVE.equals(rg.getRingGroupConductorMode());
} catch (IOException e) {
throw new RuntimeException(e);
}
});
assertEquals(RingGroupConductorMode.ACTIVE, rg.getRingGroupConductorMode());
}
内容来源于网络,如有侵权,请联系作者删除!