private static void checkForPortConflicts(final ZooKeeperClient client, final String host, final int port, final JobId jobId) throws JobPortAllocationConflictException { try { final String path = Paths.configHostPort(host, port); if (client.stat(path) == null) { return; } final byte[] b = client.getData(path); final JobId existingJobId = parse(b, JobId.class); throw new JobPortAllocationConflictException(jobId, existingJobId, host, port); } catch (KeeperException | IOException ex) { throw new HeliosRuntimeException("checking port allocations failed", ex); } }
operations.add(delete(Paths.configHostPort(host, Integer.valueOf(port))));
nodes.add(Paths.configHostPort(host, port));
operations.add(delete(Paths.configHostPort(host, Integer.valueOf(port))));
nodes.add(Paths.configHostPort(host, port));
final byte[] idJson = id.toJsonBytes(); for (final int port : staticPorts) { final String path = Paths.configHostPort(host, port); portNodes.put(path, idJson);
final byte[] idJson = id.toJsonBytes(); for (final int port : staticPorts) { final String path = Paths.configHostPort(host, port); portNodes.put(path, idJson);
private List<ZooKeeperOperation> getUndeployOperations(final ZooKeeperClient client, final String host, final JobId jobId, final String token) throws HostNotFoundException, JobNotDeployedException, TokenVerificationException { assertHostExists(client, host); final Deployment deployment = getDeployment(host, jobId); if (deployment == null) { throw new JobNotDeployedException(host, jobId); } final Job job = getJob(client, jobId); verifyToken(token, job); final String configHostJobPath = Paths.configHostJob(host, jobId); try { // use listRecursive to remove both job node and its child creation node final List<String> nodes = newArrayList(reverse(client.listRecursive(configHostJobPath))); nodes.add(Paths.configJobHost(jobId, host)); final List<Integer> staticPorts = staticPorts(job); for (int port : staticPorts) { nodes.add(Paths.configHostPort(host, port)); } return ImmutableList.of(delete(nodes)); } catch (NoNodeException e) { // This method is racy since it's possible someone undeployed the job after we called // getDeployment and checked the job exists. If we now discover the job is undeployed, // throw an exception and handle it the same as if we discovered this earlier. throw new JobNotDeployedException(host, jobId); } catch (KeeperException e) { throw new HeliosRuntimeException("calculating undeploy operations failed", e); } }
nodes.add(Paths.configHostPort(host, port));
final byte[] idJson = id.toJsonBytes(); for (final int port : staticPorts) { final String path = Paths.configHostPort(host, port); portNodes.put(path, idJson);
final byte[] idJson = id.toJsonBytes(); for (final int port : staticPorts) { final String path = Paths.configHostPort(host, port); portNodes.put(path, idJson); final String path = Paths.configHostPort(host, port); try { if (client.stat(path) == null) {