use of com.spotify.helios.common.descriptors.TaskStatus 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);
}
use of com.spotify.helios.common.descriptors.TaskStatus in project helios by spotify.
the class ZooKeeperClusterIdTest method testAgent.
@Test
public void testAgent() throws Exception {
startDefaultMaster("--zk-cluster-id=" + zkClusterId);
startDefaultAgent(testHost(), "--zk-cluster-id=" + zkClusterId);
awaitHostStatus(testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
// Create job and deploy it
final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, IDLE_COMMAND);
deployJob(jobId, testHost());
final TaskStatus runningStatus = awaitTaskState(jobId, testHost(), RUNNING);
final String containerId = runningStatus.getContainerId();
// Delete the config node which contains the cluster ID and all the job definitions
zk().curatorWithSuperAuth().delete().deletingChildrenIfNeeded().forPath("/config");
// Sleep for a second so agent has a chance to react to deletion
Thread.sleep(1000);
// Make sure the agent didn't stop the job
try (final DockerClient docker = getNewDockerClient()) {
final List<Container> containers = docker.listContainers();
final CustomTypeSafeMatcher<Container> containerIdMatcher = new CustomTypeSafeMatcher<Container>("Container with id " + containerId) {
@Override
protected boolean matchesSafely(Container container) {
return container.id().equals(containerId);
}
};
assertContainersMatch(containers, containerIdMatcher);
}
}
use of com.spotify.helios.common.descriptors.TaskStatus in project helios by spotify.
the class Agent method createSupervisor.
/**
* Create a job supervisor.
*
* @param job The job .
*/
private Supervisor createSupervisor(final Job job, final Map<String, Integer> portAllocation) {
log.debug("creating job supervisor: {}", job);
final TaskStatus taskStatus = model.getTaskStatus(job.getId());
final String containerId = (taskStatus == null) ? null : taskStatus.getContainerId();
final Supervisor supervisor = supervisorFactory.create(job, containerId, portAllocation, supervisorListener);
supervisors.put(job.getId(), supervisor);
return supervisor;
}
use of com.spotify.helios.common.descriptors.TaskStatus in project helios by spotify.
the class ZooKeeperAgentModel method getTaskStatuses.
/**
* Returns the {@link TaskStatus}es for all tasks assigned to the current agent.
*/
@Override
public Map<JobId, TaskStatus> getTaskStatuses() {
final Map<JobId, TaskStatus> statuses = Maps.newHashMap();
for (final Map.Entry<String, byte[]> entry : this.taskStatuses.entrySet()) {
try {
final JobId id = JobId.fromString(entry.getKey());
final TaskStatus status = Json.read(entry.getValue(), TaskStatus.class);
statuses.put(id, status);
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
return statuses;
}
use of com.spotify.helios.common.descriptors.TaskStatus in project helios by spotify.
the class DefaultStatusUpdater method update.
@Override
public void update() throws InterruptedException {
final TaskStatus status = builder.setGoal(goal).setState(state).setContainerId(containerId).setThrottled(throttleState).setContainerError(containerError).build();
model.setTaskStatus(status.getJob().getId(), status);
}
Aggregations