Search in sources :

Example 21 with Deployment

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()));
}
Also used : Deployment(com.spotify.helios.common.descriptors.Deployment)

Example 22 with Deployment

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()));
}
Also used : AgentMain(com.spotify.helios.agent.AgentMain) Deployment(com.spotify.helios.common.descriptors.Deployment) JobDeployResponse(com.spotify.helios.common.protocol.JobDeployResponse) Test(org.junit.Test)

Example 23 with Deployment

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()));
}
Also used : Deployment(com.spotify.helios.common.descriptors.Deployment)

Example 24 with Deployment

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);
    }
}
Also used : Deployment(com.spotify.helios.common.descriptors.Deployment) TaskStatus(com.spotify.helios.common.descriptors.TaskStatus)

Example 25 with 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);
}
Also used : Deployment(com.spotify.helios.common.descriptors.Deployment) TaskStatus(com.spotify.helios.common.descriptors.TaskStatus) JobDeployResponse(com.spotify.helios.common.protocol.JobDeployResponse)

Aggregations

Deployment (com.spotify.helios.common.descriptors.Deployment)44 JobId (com.spotify.helios.common.descriptors.JobId)30 Test (org.junit.Test)24 Job (com.spotify.helios.common.descriptors.Job)21 HeliosClient (com.spotify.helios.client.HeliosClient)19 JobDeployResponse (com.spotify.helios.common.protocol.JobDeployResponse)18 TaskStatus (com.spotify.helios.common.descriptors.TaskStatus)16 CreateJobResponse (com.spotify.helios.common.protocol.CreateJobResponse)14 DockerClient (com.spotify.docker.client.DockerClient)8 HostStatus (com.spotify.helios.common.descriptors.HostStatus)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 AgentMain (com.spotify.helios.agent.AgentMain)5 HeliosRuntimeException (com.spotify.helios.common.HeliosRuntimeException)5 JobStatus (com.spotify.helios.common.descriptors.JobStatus)5 ZooKeeperClient (com.spotify.helios.servicescommon.coordination.ZooKeeperClient)5 KeeperException (org.apache.zookeeper.KeeperException)5 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)5 RolloutTask (com.spotify.helios.common.descriptors.RolloutTask)3 Task (com.spotify.helios.common.descriptors.Task)3 JobUndeployResponse (com.spotify.helios.common.protocol.JobUndeployResponse)3