本文整理了Java中com.liveramp.hank.zookeeper.ZooKeeperPlus.ensureCreated()
方法的一些代码示例,展示了ZooKeeperPlus.ensureCreated()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperPlus.ensureCreated()
方法的具体详情如下:
包路径:com.liveramp.hank.zookeeper.ZooKeeperPlus
类名称:ZooKeeperPlus
方法名:ensureCreated
暂无
代码示例来源:origin: LiveRamp/hank
public void ensureCreated(String path, byte[] value) throws InterruptedException, KeeperException {
ensureCreated(path, value, DEFAULT_CREATE_MODE);
}
代码示例来源:origin: LiveRamp/hank
public void ensureCreated(CreateMode createMode) throws InterruptedException, KeeperException {
zk.ensureCreated(nodePath, encode(initialValue), createMode);
}
}
代码示例来源:origin: LiveRamp/hank
public void ensureCreated(String path, byte[] value, CreateMode createMode) throws InterruptedException, KeeperException {
if (!path.isEmpty() && exists(path, false) == null) {
ensureCreated(new File(path).getParent(), null, createMode);
create(path, value, DEFAULT_ACL, createMode);
NodeCreationBarrier.block(ZooKeeperPlus.this, path);
}
}
代码示例来源:origin: LiveRamp/hank
@Override
public List<ConnectedServerMetadata> getLiveServers(){
if (servers == null) {
// TODO this is a kinda temporary hack. ring groups in prod haven't created the servers path so we can't rely
// on it being there. prolly sweep after migrating.
try {
zk.ensureCreated(ZkPath.append(ringGroupPath, SERVERS_PATH), null);
} catch (Exception e) {
LOG.error("Error creating server path!", e);
}
servers = new WatchedMap<WatchedThriftNode<ConnectedServerMetadata>>(zk, ZkPath.append(ringGroupPath, SERVER_NODE), new ElementLoader<WatchedThriftNode<ConnectedServerMetadata>>() {
@Override
public WatchedThriftNode<ConnectedServerMetadata> load(ZooKeeperPlus zk, String basePath, String relPath) throws KeeperException, InterruptedException, IOException {
return new WatchedThriftNode<>(zk, ZkPath.append(basePath, relPath), true, null, null, emptyConnectedServerMetadata);
}
});
}
ArrayList<ConnectedServerMetadata> result = Lists.newArrayList();
for (WatchedThriftNode<ConnectedServerMetadata> host : servers.values()) {
result.add(host.get());
}
return result;
}
代码示例来源:origin: LiveRamp/hank
zk.ensureCreated(domainsRoot, null);
domains = new WatchedMap<ZkDomain>(zk, domainsRoot, new WatchedMap.ElementLoader<ZkDomain>() {
@Override
zk.ensureCreated(domainGroupsRoot, null);
domainGroups = new WatchedMap<ZkDomainGroup>(zk, domainGroupsRoot, new WatchedMap.ElementLoader<ZkDomainGroup>() {
@Override
zk.ensureCreated(ringGroupsRoot, null);
ringGroups = new WatchedMap<ZkRingGroup>(zk, ringGroupsRoot, new WatchedMap.ElementLoader<ZkRingGroup>() {
@Override
代码示例来源:origin: LiveRamp/hank
@Test
public void testIt() throws Exception {
final ZooKeeperPlus zk = getZk();
zk.ensureCreated("/", null, CreateMode.PERSISTENT);
assertExists("/", zk);
zk.ensureCreated("/simple", "1".getBytes(), CreateMode.PERSISTENT);
assertExists("/simple", zk);
zk.ensureCreated("/simple", "2".getBytes(), CreateMode.PERSISTENT);
assertExists("/simple", zk);
assertTrue(Arrays.equals(zk.getData("/simple", false, null), "1".getBytes()));
zk.ensureCreated("/deeper/file", null, CreateMode.PERSISTENT);
assertExists("/deeper/file", zk);
assertExists("/deeper", zk);
zk.ensureCreated("/simple/even/deeper", "3".getBytes(), CreateMode.PERSISTENT);
assertTrue(Arrays.equals(zk.getData("/simple", false, null), "1".getBytes()));
}
代码示例来源:origin: LiveRamp/hank
public ZkDomain(ZooKeeperPlus zk, String path, boolean create, DomainMetadata initialMetadata) throws KeeperException, InterruptedException {
this.zk = zk;
this.path = path;
this.name = ZkPath.getFilename(path);
metadata = new WatchedThriftNode<DomainMetadata>(zk, path, true, create ? CreateMode.PERSISTENT : null, initialMetadata, new DomainMetadata());
if (create) {
zk.ensureCreated(ZkPath.append(path, VERSIONS_PATH), null);
}
this.versions = new WatchedMap<ZkDomainVersion>(zk, ZkPath.append(path, VERSIONS_PATH),
new WatchedMap.ElementLoader<ZkDomainVersion>() {
@Override
public ZkDomainVersion load(ZooKeeperPlus zk, String basePath, String relPath) throws KeeperException, InterruptedException {
return new ZkDomainVersion(zk, ZkPath.append(basePath, relPath), getDomainVersionPropertiesSerialization());
}
}
);
}
内容来源于网络,如有侵权,请联系作者删除!