@Override public Node getNode(String path) throws KeeperException { return reporter.time(tag, "getNode", () -> client.getNode(path)); }
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); } }
final String path = Paths.statusDeploymentGroupTasks(name); try { final Node node = client.getNode(path); final byte[] data = node.getBytes(); final int version = node.getStat().getVersion();
@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); } }
private boolean isRolloutTimedOut(final ZooKeeperClient client, final DeploymentGroup deploymentGroup) { final String groupName = deploymentGroup.getName(); final RolloutOptions defaultOptions = RolloutOptions.getDefault(); final long groupTimeoutSetting = deploymentGroup.getRolloutOptions() == null ? defaultOptions.getTimeout() : deploymentGroup.getRolloutOptions().withFallback(defaultOptions).getTimeout(); final long secondsSinceDeploy; try { final String statusPath = Paths.statusDeploymentGroupTasks(groupName); secondsSinceDeploy = MILLISECONDS.toSeconds( System.currentTimeMillis() - client.getNode(statusPath).getStat().getMtime()); } catch (KeeperException e) { // statusPath doesn't exist or some other ZK issue. probably this deployment group // was removed. log.warn("error determining deployment group modification time: name={}", groupName, e); return false; } if (secondsSinceDeploy > groupTimeoutSetting) { log.info("rolling-update on deployment-group name={} has timed out after " + "{} seconds (rolloutOptions.timeout={})", groupName, secondsSinceDeploy, groupTimeoutSetting); return true; } return false; }
client.getNode(taskPath);
ops.add(set(Paths.statusDeploymentGroupRemovedHosts(groupName), Json.asBytes(removedHosts))); final Node dgn = client.getNode(Paths.configDeploymentGroup(groupName)); final Integer deploymentGroupVersion = dgn.getStat().getVersion(); DeploymentGroup deploymentGroup = Json.read(dgn.getBytes(), DeploymentGroup.class);
final String host) { try { final Node node = client.getNode( Paths.statusDeploymentGroupRemovedHosts(deploymentGroup.getName())); final int version = node.getStat().getVersion();
client.getNode(taskPath);
@Override public Node getNode(String path) throws KeeperException { try { return client.getNode(path); } catch (KeeperException e) { reporter.checkException(e, tag, "getNode"); throw e; } }
private boolean isRolloutTimedOut(final DeploymentGroup deploymentGroup, final ZooKeeperClient client) { try { final String statusPath = Paths.statusDeploymentGroup(deploymentGroup.getName()); final long secondsSinceDeploy = MILLISECONDS.toSeconds( System.currentTimeMillis() - client.getNode(statusPath).getStat().getMtime()); return secondsSinceDeploy > deploymentGroup.getRolloutOptions().getTimeout(); } catch (KeeperException e) { // statusPath doesn't exist or some other ZK issue. probably this deployment group // was removed. log.warn("error determining deployment group modification time: {} - {}", deploymentGroup.getName(), e); return false; } }
@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); } }
client.getNode(taskPath);
client.getNode(taskPath);