@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)); }
private DeploymentGroup getDeploymentGroup(final ZooKeeperClient client, final String name) throws DeploymentGroupDoesNotExistException { try { final byte[] data = client.getData(Paths.configDeploymentGroup(name)); return Json.read(data, DeploymentGroup.class); } catch (NoNodeException e) { throw new DeploymentGroupDoesNotExistException(name); } catch (KeeperException | IOException e) { throw new HeliosRuntimeException("getting deployment-group " + name + " failed", e); } }
throw new DeploymentGroupDoesNotExistException(deploymentGroupName); } else { throw new HeliosRuntimeException(
throw new DeploymentGroupDoesNotExistException(name); } catch (final KeeperException e) { throw new HeliosRuntimeException("removing deployment-group " + name + " failed", e);
deploymentGroup.getName(), jobId); } catch (final NoNodeException e) { throw new DeploymentGroupDoesNotExistException(deploymentGroup.getName()); } catch (final KeeperException e) { throw new HeliosRuntimeException(
+ "processed by another master: name={}", groupName); } catch (NoNodeException e) { throw new DeploymentGroupDoesNotExistException(groupName, e); } catch (KeeperException | IOException e) { throw new HeliosRuntimeException("updating deployment group hosts failed", e);
private DeploymentGroup getDeploymentGroup(final ZooKeeperClient client, final String name) throws DeploymentGroupDoesNotExistException { try { final byte[] data = client.getData(Paths.configDeploymentGroup(name)); return Json.read(data, DeploymentGroup.class); } catch (NoNodeException e) { throw new DeploymentGroupDoesNotExistException(name); } catch (KeeperException | IOException e) { throw new HeliosRuntimeException("getting deployment-group " + name + " failed", e); } }
@Override public void updateDeploymentGroupHosts(String name, List<String> hosts) throws DeploymentGroupDoesNotExistException { log.debug("updating deployment-group hosts: name={}", name); final ZooKeeperClient client = provider.get("updateDeploymentGroupHosts"); try { client.setData(Paths.statusDeploymentGroupHosts(name), Json.asBytes(hosts)); } catch (NoNodeException e) { throw new DeploymentGroupDoesNotExistException(name, e); } catch (KeeperException | IOException e) { throw new HeliosRuntimeException("updating deployment group hosts failed", e); } }
@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(); }
@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); } }
@Override public void removeDeploymentGroup(final String name) throws DeploymentGroupDoesNotExistException { log.info("removing deployment-group: name={}", name); final ZooKeeperClient client = provider.get("removeDeploymentGroup"); try { client.ensurePath(Paths.configDeploymentGroups()); client.delete(Paths.configDeploymentGroup(name)); if (client.exists(Paths.statusDeploymentGroupHosts(name)) != null) { client.delete(Paths.statusDeploymentGroupHosts(name)); } if (client.exists(Paths.statusDeploymentGroup(name)) != null) { client.delete(Paths.statusDeploymentGroup(name)); } } catch (final NoNodeException e) { throw new DeploymentGroupDoesNotExistException(name); } catch (final KeeperException e) { throw new HeliosRuntimeException("removing deployment-group " + name + " failed", e); } }
throw new DeploymentGroupDoesNotExistException(deploymentGroup.getName()); } catch (final KeeperException e) { throw new HeliosRuntimeException(