gpt4 book ai didi

com.spotify.helios.servicescommon.coordination.ZooKeeperClient.stat()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 03:31:31 26 4
gpt4 key购买 nike

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

ZooKeeperClient.stat介绍

暂无

代码示例

代码示例来源:origin: spotify/helios

@Override
public Stat stat(String path) throws KeeperException {
 return reporter.time(tag, "stat", () -> client.stat(path));
}

代码示例来源:origin: spotify/helios

private void delete(final String node) throws KeeperException {
 final ZooKeeperClient client = client("delete");
 final String nodePath = ZKPaths.makePath(path, node);
 if (client.stat(nodePath) != null) {
  log.debug("deleting node: {}", nodePath);
  client.delete(nodePath);
 }
}

代码示例来源:origin: spotify/helios

private void write(final String node, final byte[] data) throws KeeperException {
 final ZooKeeperClient client = client("write");
 final String nodePath = ZKPaths.makePath(path, node);
 if (client.stat(nodePath) != null) {
  log.debug("setting node: {}", nodePath);
  client.setData(nodePath, data);
 } else {
  log.debug("creating node: {}", nodePath);
  client.createAndSetData(nodePath, data);
 }
}

代码示例来源:origin: spotify/helios

final Write write = entry.getValue();
try {
 if (client.stat(path) == null) {
  client.createAndSetData(path, write.data);
 } else {

代码示例来源:origin: spotify/helios

@Override
 public boolean update(final byte[] bytes) {
  final String parent = ZKPaths.getPathAndNode(path).getPath();
  try {
   if (zooKeeperClient.stat(parent) == null) {
    return false;
   }
   if (zooKeeperClient.stat(path) == null) {
    zooKeeperClient.createAndSetData(path, bytes);
   } else {
    zooKeeperClient.setData(path, bytes);
   }
   return true;
  } catch (KeeperException.NodeExistsException ignore) {
   // Conflict due to curator retry or losing a race. We're done here.
   return true;
  } catch (KeeperException.ConnectionLossException e) {
   log.warn("ZooKeeper connection lost while updating node: {}", path);
   return false;
  } catch (KeeperException e) {
   log.error("failed to update node: {}", path, e);
   return false;
  }
 }
}

代码示例来源:origin: spotify/helios

private void assertJobExists(final ZooKeeperClient client, final JobId id)
  throws JobDoesNotExistException {
 try {
  final String path = Paths.configJob(id);
  if (client.stat(path) == null) {
   throw new JobDoesNotExistException(id);
  }
 } catch (KeeperException e) {
  throw new HeliosRuntimeException("checking job existence failed", e);
 }
}

代码示例来源:origin: spotify/helios

final String existingId = bytes == null ? "" : new String(bytes, UTF_8);
if (!id.equals(existingId)) {
 final Stat hostInfoStat = client.stat(hostInfoPath);
 if (hostInfoStat != null) {
  final long mtime = hostInfoStat.getMtime();

代码示例来源:origin: spotify/helios

private static void checkForPortConflicts(final ZooKeeperClient client,
                     final String host,
                     final int port,
                     final JobId jobId)
  throws JobPortAllocationConflictException {
 try {
  final String path = Paths.configHostPort(host, port);
  if (client.stat(path) == null) {
   return;
  }
  final byte[] b = client.getData(path);
  final JobId existingJobId = parse(b, JobId.class);
  throw new JobPortAllocationConflictException(jobId, existingJobId, host, port);
 } catch (KeeperException | IOException ex) {
  throw new HeliosRuntimeException("checking port allocations failed", ex);
 }
}

代码示例来源:origin: spotify/helios

@Test
 public void testRemoveJobDeletesHistory() throws Exception {
  startDefaultAgent(testHost());
  awaitHostStatus(testHost(), UP, LONG_WAIT_SECONDS, SECONDS);

  final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, IDLE_COMMAND);

  deployJob(jobId, testHost());
  awaitJobState(
    defaultClient(), testHost(), jobId, TaskStatus.State.RUNNING, LONG_WAIT_SECONDS, SECONDS);
  undeployJob(jobId, testHost());
  awaitJobUndeployed(defaultClient(), testHost(), jobId, LONG_WAIT_SECONDS, SECONDS);

  final ZooKeeperClient zkClient = new ZooKeeperClientProvider(
    new DefaultZooKeeperClient(zk().curatorWithSuperAuth()), ZooKeeperModelReporter.noop())
    .get("test-client");

  // Check that there's some history events
  assertNotNull(zkClient.stat(Paths.historyJob(jobId)));

  // Remove job
  final JobDeleteResponse response =
    defaultClient().deleteJob(jobId).get(WAIT_TIMEOUT_SECONDS, SECONDS);
  assertEquals(JobDeleteResponse.Status.OK, response.getStatus());

  // Verify that history is gone
  assertNull(zkClient.stat(Paths.historyJob(jobId)));
 }
}

代码示例来源:origin: spotify/helios

if (client.stat(taskPath) != null) {
 throw new JobAlreadyDeployedException(host, id);

代码示例来源:origin: at.molindo/helios-services

@Override
public Stat stat(String path) throws KeeperException {
 try {
  return client.stat(path);
 } catch (KeeperException e) {
  reporter.checkException(e, tag, "stat");
  throw e;
 }
}

代码示例来源:origin: at.molindo/helios-services

private void delete(final String node) throws KeeperException {
 final ZooKeeperClient client = client("delete");
 final String nodePath = ZKPaths.makePath(path, node);
  if (client.stat(nodePath) != null) {
   log.debug("deleting node: {}", nodePath);
   client.delete(nodePath);
  }
}

代码示例来源:origin: at.molindo/helios-services

private void write(final String node, final byte[] data) throws KeeperException {
 final ZooKeeperClient client = client("write");
 final String nodePath = ZKPaths.makePath(path, node);
  if (client.stat(nodePath) != null) {
   log.debug("setting node: {}", nodePath);
   client.setData(nodePath, data);
  } else {
   log.debug("creating node: {}", nodePath);
   client.createAndSetData(nodePath, data);
  }
}

代码示例来源:origin: at.molindo/helios-services

final Write write = entry.getValue();
try {
 if (client.stat(path) == null) {
  client.createAndSetData(path, write.data);
 } else {

代码示例来源:origin: at.molindo/helios-services

@Override
 public boolean update(final byte[] bytes) {
  final String parent = ZKPaths.getPathAndNode(path).getPath();
  try {
   if (zooKeeperClient.stat(parent) == null) {
    return false;
   }
   if (zooKeeperClient.stat(path) == null) {
    zooKeeperClient.createAndSetData(path, bytes);
   } else {
    zooKeeperClient.setData(path, bytes);
   }
   return true;
  } catch (KeeperException.NodeExistsException ignore) {
   // Conflict due to curator retry or losing a race. We're done here.
   return true;
  } catch (KeeperException.ConnectionLossException e) {
   log.warn("ZooKeeper connection lost while updating node: {}", path);
   return false;
  } catch (KeeperException e) {
   log.error("failed to update node: {}", path, e);
   return false;
  }
 }
}

代码示例来源:origin: at.molindo/helios-services

private void assertJobExists(final ZooKeeperClient client, final JobId id)
  throws JobDoesNotExistException {
 try {
  final String path = Paths.configJob(id);
  if (client.stat(path) == null) {
   throw new JobDoesNotExistException(id);
  }
 } catch (KeeperException e) {
  throw new HeliosRuntimeException("checking job existence failed", e);
 }
}

代码示例来源:origin: at.molindo/helios-services

if (client.stat(taskPath) != null) {
 throw new JobAlreadyDeployedException(host, id);
final String path = Paths.configHostPort(host, port);
try {
 if (client.stat(path) == null) {
  continue;

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