com.spotify.helios.master.ZooKeeperMasterModel.getDeploymentGroup()方法的使用及代码示例

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

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

ZooKeeperMasterModel.getDeploymentGroup介绍

[英]Returns a Map of deployment group name to DeploymentGroup objects for all of the deployment groups known.
[中]返回部署组名称到所有已知部署组的DeploymentGroup对象的映射。

代码示例

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

@Override
public DeploymentGroup getDeploymentGroup(final String name)
  throws DeploymentGroupDoesNotExistException {
 log.debug("getting deployment-group: {}", name);
 final ZooKeeperClient client = provider.get("getDeploymentGroup");
 return getDeploymentGroup(client, name);
}

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

@Override
public List<String> getDeploymentGroupHosts(final String name)
  throws DeploymentGroupDoesNotExistException {
 log.debug("getting deployment group hosts: {}", name);
 final ZooKeeperClient client = provider.get("getDeploymentGroupHosts");
 final DeploymentGroup deploymentGroup = getDeploymentGroup(client, name);
 if (deploymentGroup == null) {
  throw new DeploymentGroupDoesNotExistException(name);
 }
 return getHosts(client, Paths.statusDeploymentGroupHosts(name));
}

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

@Override
public DeploymentGroupStatus getDeploymentGroupStatus(final String name)
  throws DeploymentGroupDoesNotExistException {
 log.debug("getting deployment group status: {}", name);
 final ZooKeeperClient client = provider.get("getDeploymentGroupStatus");
 final DeploymentGroup deploymentGroup = getDeploymentGroup(client, name);
 if (deploymentGroup == null) {
  return null;
 }
 try {
  final Node node = client.getNode(Paths.statusDeploymentGroup(name));
  final byte[] bytes = node.getBytes();
  if (bytes.length == 0) {
   return null;
  }
  return Json.read(bytes, DeploymentGroupStatus.class);
 } catch (NoNodeException e) {
  return null;
 } catch (KeeperException | IOException e) {
  throw new HeliosRuntimeException("getting deployment group status " + name + " failed", e);
 }
}

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

@Override
public DeploymentGroup getDeploymentGroup(final String name)
  throws DeploymentGroupDoesNotExistException {
 log.debug("getting deployment-group: {}", name);
 final ZooKeeperClient client = provider.get("getDeploymentGroup");
 return getDeploymentGroup(client, name);
}

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

@Override
public List<String> getDeploymentGroupHosts(final String name)
  throws DeploymentGroupDoesNotExistException {
 log.debug("getting deployment group hosts: {}", name);
 final ZooKeeperClient client = provider.get("getDeploymentGroupHosts");
 final DeploymentGroup deploymentGroup = getDeploymentGroup(client, name);
 if (deploymentGroup == null) {
  throw new DeploymentGroupDoesNotExistException(name);
 }
 try {
  final byte[] data = client.getData(Paths.statusDeploymentGroupHosts(name));
  if (data.length > 0) {
   return Json.read(data, STRING_LIST_TYPE);
  }
 } catch (NoNodeException e) {
  // not fatal
 } catch (KeeperException | IOException e) {
  throw new HeliosRuntimeException("reading deployment group hosts failed: " + name, e);
 }
 return emptyList();
}

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

@Override
public void stopDeploymentGroup(final String deploymentGroupName)
  throws DeploymentGroupDoesNotExistException {
 checkNotNull(deploymentGroupName, "name");
 log.info("stop deployment-group: name={}", deploymentGroupName);
 final ZooKeeperClient client = provider.get("stopDeploymentGroup");
 final DeploymentGroup deploymentGroup = getDeploymentGroup(deploymentGroupName);
 final String statusPath = Paths.statusDeploymentGroup(deploymentGroupName);
 final DeploymentGroupStatus status = DeploymentGroupStatus.newBuilder()
   .setDeploymentGroup(deploymentGroup)
   .setState(FAILED)
   .setError("Stopped by user")
   .build();
 try {
  client.ensurePath(statusPath);
  client.transaction(set(statusPath, status));
 } catch (final NoNodeException e) {
  throw new DeploymentGroupDoesNotExistException(deploymentGroupName);
 } catch (final KeeperException e) {
  throw new HeliosRuntimeException(
    "stop deployment-group " + deploymentGroupName + " failed", e);
 }
}

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

@Override
public DeploymentGroupStatus getDeploymentGroupStatus(final String name)
  throws DeploymentGroupDoesNotExistException {
 log.debug("getting deployment group status: {}", name);
 final ZooKeeperClient client = provider.get("getDeploymentGroupStatus");
 final DeploymentGroup deploymentGroup = getDeploymentGroup(client, name);
 if (deploymentGroup == null) {
  return null;
 }
 try {
  final Node node = client.getNode(Paths.statusDeploymentGroup(name));
  final byte[] bytes = node.getBytes();
  if (bytes.length == 0) {
   return null;
  }
  final DeploymentGroupStatus status = Json.read(bytes, DeploymentGroupStatus.class);
  return status.toBuilder()
    .setVersion(node.getStat().getVersion())
    .build();
 } catch (NoNodeException e) {
  return null;
 } catch (KeeperException | IOException e) {
  throw new HeliosRuntimeException("getting deployment group status " + name + " failed", e);
 }
}

相关文章