private List<String> getHosts(final ZooKeeperClient client, final String path) { try { return Json.read(client.getNode(path).getBytes(), STRING_LIST_TYPE); } catch (JsonMappingException | JsonParseException | NoNodeException e) { return emptyList(); } catch (KeeperException | IOException e) { throw new HeliosRuntimeException("failed to read deployment group hosts from " + path, e); } }
try { final Node node = client.getNode(path); final byte[] data = node.getBytes(); final int version = node.getStat().getVersion(); if (data.length == 0) {
@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); } }
DeploymentGroup deploymentGroup = Json.read(dgn.getBytes(), DeploymentGroup.class);
Paths.statusDeploymentGroupRemovedHosts(deploymentGroup.getName())); final int version = node.getStat().getVersion(); final List<String> hostsToUndeploy = Json.read(node.getBytes(), STRING_LIST_TYPE);
@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); } }