gpt4 book ai didi

com.liveramp.hank.zookeeper.ZooKeeperPlus.exists()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:22:44 27 4
gpt4 key购买 nike

本文整理了Java中com.liveramp.hank.zookeeper.ZooKeeperPlus.exists()方法的一些代码示例,展示了ZooKeeperPlus.exists()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperPlus.exists()方法的具体详情如下:
包路径:com.liveramp.hank.zookeeper.ZooKeeperPlus
类名称:ZooKeeperPlus
方法名:exists

ZooKeeperPlus.exists介绍

暂无

代码示例

代码示例来源:origin: LiveRamp/hank

@Override
public boolean isRingGroupConductorOnline() throws IOException {
 try {
  return zk.exists(ringGroupConductorOnlinePath, false) != null;
 } catch (Exception e) {
  throw new IOException(e);
 }
}

代码示例来源:origin: LiveRamp/hank

public synchronized void block(int timeoutMS) throws InterruptedException, KeeperException {
 // Wait only if it doesn't exist
 if (waiting && zk.exists(nodePath, this) == null) {
  if (LOG.isDebugEnabled()) {
   LOG.debug("Wait for creation of node " + nodePath);
  }
  if (timeoutMS != 0) {
   this.wait(timeoutMS);
  } else {
   this.wait();
  }
 }
}

代码示例来源:origin: LiveRamp/hank

public Long getLongOrNull(String path) throws KeeperException, InterruptedException {
 if (exists(path, false) == null) {
  return null;
 } else {
  return Long.parseLong(new String(getData(path, false, new Stat())));
 }
}

代码示例来源:origin: LiveRamp/hank

public void deleteIfExists(String path) throws KeeperException, InterruptedException {
 if (exists(path, false) != null) {
  delete(path, -1);
 }
}

代码示例来源:origin: LiveRamp/hank

private void watchForCreation() throws InterruptedException, KeeperException {
 synchronized (this) {
  value = null;
  stat = new Stat();
 }
 if (zk.exists(nodePath, watcher) != null) {
  watchForData();
 }
}

代码示例来源: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

protected void createNodeRecursively(String path)
  throws Exception {
 String[] toks = path.split("/");
 String newPath = "/";
 for (int i = 0; i < toks.length; i++) {
  newPath += toks[i];
  if (zk.exists(newPath, false) == null) {
   zk.create(newPath, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
  }
  if (i != 0) {
   newPath += "/";
  }
 }
}

代码示例来源:origin: LiveRamp/hank

public void setOrCreate(String path, String value, CreateMode createMode) throws KeeperException, InterruptedException {
 if (exists(path, false) == null) {
  create(path, value.getBytes(), DEFAULT_ACL, createMode);
 } else {
  setData(path, value.getBytes(), -1);
 }
}

代码示例来源: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 boolean claimRingGroupConductor(RingGroupConductorMode mode) throws IOException {
 try {
  if (zk.exists(ringGroupConductorOnlinePath, false) == null) {
   zk.create(ringGroupConductorOnlinePath, BytesUtils.stringToBytes(mode.toString()), CreateMode.EPHEMERAL);
   return true;
  }
  return false;
 } catch (Exception e) {
  throw new IOException(e);
 }
}

代码示例来源:origin: LiveRamp/hank

private int getNextDomainId() throws KeeperException, InterruptedException {
 final String domainIdCounterPath = ZkPath.append(domainsRoot, KEY_DOMAIN_ID_COUNTER);
 if (zk.exists(domainIdCounterPath, false) == null) {
  zk.create(domainIdCounterPath, Integer.toString(1).getBytes());
  return 1;
 }
 while (true) {
  final Stat stat = new Stat();
  final byte[] data = zk.getData(domainIdCounterPath, false, stat);
  int lastVersionNumber = Integer.parseInt(new String(data));
  try {
   lastVersionNumber++;
   zk.setData(domainIdCounterPath, Integer.toString(lastVersionNumber).getBytes(), stat.getVersion());
   return lastVersionNumber;
  } catch (KeeperException.BadVersionException e) {
   if (LOG.isDebugEnabled()) {
    LOG.debug("Tried to set the domain id counter to " + lastVersionNumber + " but was preempted by another writer. Retrying.");
   }
  }
 }
}

代码示例来源:origin: LiveRamp/hank

@Override
public Long getUpSince() throws IOException {
 if (getState() == HostState.OFFLINE) {
  return null;
 }
 try {
  Stat stat = zk.exists(state.getPath(), false);
  if (stat == null) {
   return null;
  } else {
   return stat.getCtime();
  }
 } catch (Exception e) {
  throw new IOException(e);
 }
}

代码示例来源:origin: LiveRamp/hank

@Override
 public void detectCompletion(ZooKeeperPlus zk, String basePath, String relPath, CompletionAwaiter awaiter) throws KeeperException, InterruptedException {
  if (zk.exists(ZkPath.append(basePath, relPath, NODE_NAME), new CreationWatcher(relPath, awaiter)) != null) {
   awaiter.completed(relPath);
  }
 }
}

代码示例来源:origin: LiveRamp/hank

private void assertExists(String path, ZooKeeperPlus zkp) throws KeeperException, InterruptedException {
 assertTrue(zkp.exists(path, false) != null);
}

代码示例来源:origin: LiveRamp/hank

@Test
 public void testDelete() throws Exception {
  ZkDomain dc = ZkDomain.create(getZk(), getRoot(), "domain0", 1, ConstantStorageEngine.Factory.class.getName(), "---", Murmur64Partitioner.class.getName(), 0, Collections.<String>emptyList());
  assertNotNull(getZk().exists(ZkPath.append(getRoot(), "domain0"), false));
  assertTrue(dc.delete());
  WaitUntil.orDie(() -> {
   try {
    return getZk().exists(ZkPath.append(getRoot(), "domain0"), false) == null;
   } catch (KeeperException e) {
    throw new RuntimeException(e);
   } catch (InterruptedException e) {
    throw new RuntimeException(e);
   }
  });
  assertNull(getZk().exists(ZkPath.append(getRoot(), "domain0"), false));
 }
}

代码示例来源:origin: LiveRamp/hank

public static ZkPartitionProperties create(ZooKeeperPlus zk, String partsRoot, int partNum, long numBytes, long numRecords) throws KeeperException, InterruptedException {
 String partPath = ZkPath.append(partsRoot, nodeName(partNum));
 // if the node already exists, then don't try to create a new one
 if (zk.exists(partPath, false) == null) {
  zk.create(partPath, null);
  zk.createLong(ZkPath.append(partPath, "num_bytes"), numBytes);
  zk.createLong(ZkPath.append(partPath, "num_records"), numRecords);
  zk.create(ZkPath.append(partPath, DotComplete.NODE_NAME), null);
 }
 return new ZkPartitionProperties(zk, partPath);
}

代码示例来源:origin: LiveRamp/hank

@Test
public void testDelete() throws Exception {
 ZkDomainGroup dg = ZkDomainGroup.create(getZk(), null, dg_root, "blah");
 assertNotNull(getZk().exists(ZkPath.append(dg_root, "blah"), false));
 assertTrue(dg.delete());
 assertNull(getZk().exists(ZkPath.append(dg_root, "blah"), false));
}

代码示例来源:origin: LiveRamp/hank

@Test
 public void testDelete() throws Exception {
  ZkDomainGroup dg = ZkDomainGroup.create(getZk(), null, domainGroupsRoot, "dg");
  assertNotNull(getZk().exists(dg.getPath(), false));
  assertTrue(dg.delete());
  assertNull(getZk().exists(dg.getPath(), false));
 }
}

代码示例来源:origin: LiveRamp/hank

@Test
 public void testDelete() throws Exception {
  ZkRing ring = ZkRing.create(getZk(), coordinator, ZkPath.append(getRoot(), "ring-group-one"), 1, null, null);
  ring.delete();
  assertTrue(getZk().exists(ZkPath.append(getRoot(), "ring-group-one/ring-1"), null) == null);
 }
}

代码示例来源:origin: LiveRamp/hank

@Test
public void testCancelVersion() throws Exception {
 DomainVersion dv = ZkDomainVersion.create(getZk(), getRoot(), 1, null, null);
 assertEquals(1, dv.getVersionNumber());
 assertNull(dv.getClosedAt());
 assertFalse(DomainVersions.isClosed(dv));
 dv.cancel();
 assertNull(getZk().exists(ZkPath.append(getRoot(), "v/1"), false));
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com