operations.add(check(Paths.configHost(host))); operations.add(delete(node)); operations.add(create(Paths.statusHost(host))); operations.add(create(Paths.statusHostJobs(host))); operations.add(delete(Paths.configHostId(host))); operations.add(create(Paths.configHostId(host), hostId.getBytes(UTF_8)));
final UUID jobCreationOperationId = getJobCreation(client, id); if (jobCreationOperationId != null) { operations.add(delete(Paths.configJobCreation(id, jobCreationOperationId))); operations.add(delete(Paths.configJobHosts(id)), delete(Paths.configJobRefShort(id)), delete(Paths.configJob(id)), set(Paths.configJobs(), UUID.randomUUID().toString().getBytes())); client.transaction(operations.build()); } catch (final NoNodeException e) {
try { client.ensurePath(Paths.historyJob(id)); client.transaction(create(Paths.configJob(id), job), create(Paths.configJobRefShort(id), id), create(Paths.configJobHosts(id)), create(creationPath), set(Paths.configJobs(), UUID.randomUUID().toString().getBytes())); } catch (final NodeExistsException e) { if (client.exists(creationPath) != null) {
deployment.getDeployerMaster(), deployment.getDeploymentGroupName()); final List<ZooKeeperOperation> operations = Lists.newArrayList( check(jobPath), create(portNodes), create(Paths.configJobHost(id, host))); checkForPortConflicts(client, host, port, id); operations.add(create(taskPath, task)); operations.add(create(taskCreationPath)); } catch (KeeperException e) { throw new HeliosRuntimeException("reading existing task description failed", e);
ops.add(set(Paths.statusDeploymentGroupHosts(groupName), Json.asBytes(hosts))); ops.add(set(Paths.statusDeploymentGroupRemovedHosts(groupName), Json.asBytes(removedHosts))); ops.add(check(Paths.configDeploymentGroup(groupName), deploymentGroupVersion)); ops.add(set(Paths.configDeploymentGroup(deploymentGroup.getName()), deploymentGroup));
public static ZooKeeperOperation create(final String path, final Descriptor data, final int version) { return create(path, data.toJsonBytes(), version); }
operations.add(delete(node)); operations.add(delete(Paths.configJobHost(job, host))); operations.add(delete(s)); operations.add(delete(Paths.configHostJobs(host))); operations.add(delete(node)); operations.add(delete(Paths.configHostPort(host, Integer.valueOf(port)))); operations.add(delete(Paths.configHostPorts(host))); operations.add(delete(idPath)); operations.add(delete(Paths.configHost(host)));
final ZooKeeperClient client = provider.get("rollingUpdate"); operations.add(set(Paths.configDeploymentGroup(updated.getName()), updated));
ops.add(check(Paths.statusDeploymentGroupTasks(deploymentGroupName), versionedTasks.version())); ops.addAll(op.operations());
public RollingUpdateOp nextTask(final List<ZooKeeperOperation> operations) { final List<ZooKeeperOperation> ops = Lists.newArrayList(operations); final List<Map<String, Object>> events = Lists.newArrayList(); final RolloutTask task = tasks.getRolloutTasks().get(tasks.getTaskIndex()); // Update the task index, delete tasks if done if (tasks.getTaskIndex() + 1 == tasks.getRolloutTasks().size()) { final DeploymentGroupStatus status = DeploymentGroupStatus.newBuilder() .setState(DONE) .build(); // We are done -> delete tasks & update status ops.add(delete(Paths.statusDeploymentGroupTasks(deploymentGroup.getName()))); ops.add(set(Paths.statusDeploymentGroup(deploymentGroup.getName()), status)); // Emit an event signalling that we're DONE! events.add(eventFactory.rollingUpdateDone(deploymentGroup)); } else { ops.add( set(Paths.statusDeploymentGroupTasks(deploymentGroup.getName()), tasks.toBuilder() .setTaskIndex(tasks.getTaskIndex() + 1) .build())); // Only emit an event if the task resulted in taking in action. If there are no ZK operations // the task was effectively a no-op. if (!operations.isEmpty()) { events.add(eventFactory.rollingUpdateTaskSucceeded(deploymentGroup, task)); } } return new RollingUpdateOp(ImmutableList.copyOf(ops), ImmutableList.copyOf(events)); }
deployment.getDeployerMaster(), deployment.getDeploymentGroupName()); final List<ZooKeeperOperation> operations = Lists.newArrayList( check(jobPath), create(portNodes), create(Paths.configJobHost(id, host))); operations.add(create(taskPath, task)); operations.add(create(taskCreationPath)); } catch (KeeperException e) { throw new HeliosRuntimeException("reading existing task description failed", e);
try { client.ensurePath(Paths.historyJob(id)); client.transaction(create(Paths.configJob(id), job), create(Paths.configJobRefShort(id), id), create(Paths.configJobHosts(id)), create(creationPath), set(Paths.configJobs(), UUID.randomUUID().toString().getBytes())); } catch (final NodeExistsException e) { if (client.exists(creationPath) != null) {
public static ZooKeeperOperation create(final String path, final Descriptor data) { return create(path, data.toJsonBytes()); }
return ImmutableList.of(delete(nodes));
@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); } }
ops.add(create(Paths.statusDeploymentGroupTasks(deploymentGroup.getName()))); .setState(DONE) .build(); ops.add(delete(Paths.statusDeploymentGroupTasks(deploymentGroup.getName()))); events.add(eventFactory.rollingUpdateDone(deploymentGroup)); } else { .setState(ROLLING_OUT) .build(); ops.add(set(Paths.statusDeploymentGroupTasks(deploymentGroup.getName()), tasks)); ops.add(set(Paths.statusDeploymentGroup(deploymentGroup.getName()), status));