use of com.spotify.helios.common.descriptors.Deployment in project helios by spotify.
the class JobStopCommand method runWithJobId.
@Override
protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException {
final List<String> hosts = options.getList(hostsArg.getDest());
final Deployment deployment = new Deployment.Builder().setGoal(Goal.STOP).setJobId(jobId).build();
if (!json) {
out.printf("Stopping %s on %s%n", jobId, hosts);
}
return Utils.setGoalOnHosts(client, out, json, hosts, deployment, options.getString(tokenArg.getDest()));
}
use of com.spotify.helios.common.descriptors.Deployment in project helios by spotify.
the class ZooKeeperRestoreTest method verifyAgentPushesTaskStateAfterRestore.
@Test
public void verifyAgentPushesTaskStateAfterRestore() throws Exception {
// Start agent once to have it register
final AgentMain agent1 = startDefaultAgent(testHost());
awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
agent1.stopAsync().awaitTerminated();
// Deploy job
final Deployment deployment = Deployment.of(fooJob.getId(), START);
final JobDeployResponse deployed = client.deploy(deployment, testHost()).get();
assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());
// Back up zk
zkc.backup(backupDir);
// Start agent
startDefaultAgent(testHost());
awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
// Wait for agent to indicate that job is running
awaitJobState(client, testHost(), fooJob.getId(), RUNNING, LONG_WAIT_SECONDS, SECONDS);
// Restore zk, erasing task state
zkc.stop();
zkc.restore(backupDir);
zkc.start();
// Wait for agent to again indicate that job is running
awaitJobState(client, testHost(), fooJob.getId(), RUNNING, LONG_WAIT_SECONDS, SECONDS);
// Remove task status
zkc.curatorWithSuperAuth().delete().forPath(Paths.statusHostJob(testHost(), fooJob.getId()));
}
use of com.spotify.helios.common.descriptors.Deployment in project helios by spotify.
the class JobStartCommand method runWithJobId.
@Override
protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException {
final List<String> hosts = options.getList(hostsArg.getDest());
final Deployment deployment = new Deployment.Builder().setGoal(Goal.START).setJobId(jobId).build();
if (!json) {
out.printf("Starting %s on %s%n", jobId, hosts);
}
return Utils.setGoalOnHosts(client, out, json, hosts, deployment, options.getString(tokenArg.getDest()));
}
use of com.spotify.helios.common.descriptors.Deployment in project helios by spotify.
the class JobStatusCommand method displayTask.
private void displayTask(final boolean full, final JobStatusTable table, final JobId jobId, final JobStatus jobStatus, final Map<String, TaskStatus> taskStatuses, final Iterable<String> matchingHosts) {
for (final String host : matchingHosts) {
final Map<String, Deployment> deployments = jobStatus.getDeployments();
final TaskStatus ts = taskStatuses.get(host);
final Deployment deployment = (deployments == null) ? null : deployments.get(host);
table.task(jobId, formatHostname(full, host), ts, deployment);
}
}
use of com.spotify.helios.common.descriptors.Deployment in project helios by spotify.
the class VolumeTest method assertVolumes.
public void assertVolumes(final JobId jobId) throws Exception {
// Wait for agent to come up
awaitHostRegistered(client, testHost(), LONG_WAIT_SECONDS, SECONDS);
awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
// Deploy the job on the agent
final Deployment deployment = Deployment.of(jobId, START);
final JobDeployResponse deployed = client.deploy(deployment, testHost()).get();
assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());
// Wait for the job to run
final TaskStatus taskStatus = awaitJobState(client, testHost(), jobId, RUNNING, LONG_WAIT_SECONDS, SECONDS);
assertJobEquals(job, taskStatus.getJob());
final Integer barPort = taskStatus.getPorts().get("bar").getExternalPort();
final Integer hostnamePort = taskStatus.getPorts().get("hostname").getExternalPort();
assert barPort != null;
assert hostnamePort != null;
// Read "foo" from /volume/bar
final String foo = recvUtf8(barPort, 3);
assertEquals("foo", foo);
// Read hostname from /hostname
final String hostname = getNewDockerClient().info().name();
final String mountedHostname = recvUtf8(hostnamePort, hostname.length());
assertEquals(hostname, mountedHostname);
}
Aggregations