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

x33g5p2x  于2022-02-05 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(93)

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

ZooKeeperClient.getChildren介绍

暂无

代码示例

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

private static List<String> safeGetChildren(final ZooKeeperClient client, final String path) {
 try {
  return client.getChildren(path);
 } catch (KeeperException ignore) {
  return ImmutableList.of();
 }
}

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

@Override
Iterable<String> collectItems() {
 final String path = Paths.historyJobs();
 List<String> jobIds = Collections.emptyList();
 try {
  jobIds = client.getChildren(path);
 } catch (KeeperException e) {
  log.warn("Failed to get children of znode {}", path, e);
 }
 return jobIds;
}

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

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

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

private List<JobId> listHostJobs(final ZooKeeperClient client, final String host) {
 final List<String> jobIdStrings;
 final String folder = Paths.statusHostJobs(host);
 try {
  jobIdStrings = client.getChildren(folder);
 } catch (KeeperException.NoNodeException e) {
  return null;
 } catch (KeeperException e) {
  throw new HeliosRuntimeException("List tasks for host failed: " + host, e);
 }
 final ImmutableList.Builder<JobId> jobIds = ImmutableList.builder();
 for (final String jobIdString : jobIdStrings) {
  jobIds.add(JobId.fromString(jobIdString));
 }
 return jobIds.build();
}

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

/**
 * Returns a list of the hosts/agents that have been registered.
 */
@Override
public List<String> listHosts() {
 try {
  // TODO (dano): only return hosts whose agents completed registration (i.e. has id nodes)
  return provider.get("listHosts").getChildren(Paths.configHosts());
 } catch (KeeperException.NoNodeException e) {
  return emptyList();
 } catch (KeeperException e) {
  throw new HeliosRuntimeException("listing hosts failed", e);
 }
}

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

static void initializeAclRecursive(final ZooKeeperClient client, final String path,
                   final ACLProvider aclProvider)
   throws KeeperException {
  try {
   final List<ACL> expected = aclProvider.getAclForPath(path);
   final List<ACL> actual = client.getAcl(path);

   if (newHashSet(expected).equals(newHashSet(actual))) {
    // actual ACL matches expected
   } else {
    client.setAcl(path, expected);
   }

   for (final String child : client.getChildren(path)) {
    initializeAclRecursive(client, path.replaceAll("/$", "") + "/" + child, aclProvider);
   }
  } catch (Exception e) {
   throwIfInstanceOf(e, KeeperException.class);
   throw new RuntimeException(e);
  }
 }
}

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

private List<String> listJobHosts(final ZooKeeperClient client, final JobId jobId)
  throws JobDoesNotExistException {
 final List<String> hosts;
 try {
  hosts = client.getChildren(Paths.configJobHosts(jobId));
 } catch (NoNodeException e) {
  throw new JobDoesNotExistException(jobId);
 } catch (KeeperException e) {
  throw new HeliosRuntimeException("failed to list hosts for job: " + jobId, e);
 }
 return hosts;
}

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

private UUID getJobCreation(final ZooKeeperClient client, final JobId id)
  throws KeeperException {
 final String parent = Paths.configHostJobCreationParent(id);
 final List<String> children = client.getChildren(parent);
 for (final String child : children) {
  if (Paths.isConfigJobCreation(child)) {
   return Paths.configJobCreationId(child);
  }
 }
 return null;
}

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

private void syncChecked() throws KeeperException {
 final ZooKeeperClient client = client("sync");
 final List<String> nodes = client.getChildren(path);
 final Map<String, byte[]> snapshot = entries.get();

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

/**
 * Returns a list of the host names of the currently running masters.
 */
@Override
public List<String> getRunningMasters() {
 final ZooKeeperClient client = provider.get("getRunningMasters");
 try {
  final List<String> masters = client.getChildren(Paths.statusMaster());
  final ImmutableList.Builder<String> upMasters = ImmutableList.builder();
  for (final String master : masters) {
   if (client.exists(Paths.statusMasterUp(master)) != null) {
    upMasters.add(master);
   }
  }
  return upMasters.build();
 } catch (KeeperException e) {
  throw new HeliosRuntimeException("listing masters failed", e);
 }
}

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

client.getChildren(Paths.historyJobHosts(jobId));
} catch (NoNodeException e) {
 return emptyList();
 final List<String> events;
 try {
  events = client.getChildren(Paths.historyJobHostEvents(jobId, h));
 } catch (NoNodeException e) {
  continue;

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

final List<String> names;
try {
 names = client.getChildren(folder);
} catch (NoNodeException e) {
 return Maps.newHashMap();

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

final List<String> ids;
try {
 ids = client.getChildren(folder);
} catch (NoNodeException e) {
 return Maps.newHashMap();

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

final List<String> names;
try {
 names = client.getChildren(folder);
} catch (NoNodeException e) {
 return Collections.emptyMap();

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

private Map<JobId, Deployment> getTasks(final ZooKeeperClient client, final String host) {
 final Map<JobId, Deployment> jobs = Maps.newHashMap();
 try {
  final String folder = Paths.configHostJobs(host);
  final List<String> jobIds;
  try {
   jobIds = client.getChildren(folder);
  } catch (KeeperException.NoNodeException e) {
   log.warn("Unable to get deployment config for {}", host, e);
   return ImmutableMap.of();
  }
  for (final String jobIdString : jobIds) {
   final JobId jobId = JobId.fromString(jobIdString);
   final String containerPath = Paths.configHostJob(host, jobId);
   try {
    final byte[] data = client.getData(containerPath);
    final Task task = parse(data, Task.class);
    jobs.put(jobId, Deployment.of(jobId, task.getGoal(), task.getDeployerUser(),
      task.getDeployerMaster(), task.getDeploymentGroupName()));
   } catch (KeeperException.NoNodeException ignored) {
    log.debug("deployment config node disappeared: {}", jobIdString);
   }
  }
 } catch (KeeperException | IOException e) {
  throw new HeliosRuntimeException("getting deployment config failed", e);
 }
 return jobs;
}

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

final List<String> events = client.getChildren(Paths.historyJobHostEvents(jobId, hostname));
if (events.size() > MAX_NUMBER_STATUS_EVENTS_TO_RETAIN) {
 trimStatusEvents(events, jobId);

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

private List<String> safeGetChildren(final ZooKeeperClient client, final String path) {
 try {
  return client.getChildren(path);
 } catch (KeeperException ignore) {
  return ImmutableList.of();
 }
}

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

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

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

private List<String> listJobHosts(final ZooKeeperClient client, final JobId jobId)
  throws JobDoesNotExistException {
 final List<String> hosts;
 try {
  hosts = client.getChildren(Paths.configJobHosts(jobId));
 } catch (NoNodeException e) {
  throw new JobDoesNotExistException(jobId);
 } catch (KeeperException e) {
  throw new HeliosRuntimeException("failed to list hosts for job: " + jobId, e);
 }
 return hosts;
}

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

private UUID getJobCreation(final ZooKeeperClient client, final JobId id)
  throws KeeperException {
 final String parent = Paths.configHostJobCreationParent(id);
 final List<String> children = client.getChildren(parent);
 for (final String child : children) {
  if (Paths.isConfigJobCreation(id, parent, child)) {
   return Paths.configJobCreationId(id, parent, child);
  }
 }
 return null;
}

相关文章