private void putBack(TaskStatusEvent event) { final JobId key = event.getStatus().getJob().getId(); final Deque<TaskStatusEvent> queue = getDeque(key); synchronized (queue) { if (queue.size() >= MAX_QUEUE_SIZE) { // already full, just toss the event return; } queue.push(event); count.incrementAndGet(); } }
final JobId id = current.getStatus().getJob().getId(); final Deque<TaskStatusEvent> deque = items.get(id); if (deque == null) {
private void add(TaskStatusEvent item) throws InterruptedException { // If too many "globally", toss them while (count.get() >= MAX_TOTAL_SIZE) { getNext(); } final JobId key = item.getStatus().getJob().getId(); final Deque<TaskStatusEvent> deque = getDeque(key); synchronized (deque) { // if too many in the particular deque, toss them while (deque.size() >= MAX_QUEUE_SIZE) { deque.remove(); count.decrementAndGet(); } deque.add(item); count.incrementAndGet(); } try { backingStore.set(items); } catch (ClosedByInterruptException e) { log.debug("Writing task status event to backing store was interrupted"); } catch (IOException e) { // We are best effort after all... log.warn("Failed to write task status event to backing store", e); } }
@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); }
public void assertRamdisk(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 dfPort = taskStatus.getPorts().get("df").getExternalPort(); assert dfPort != null; // If "/much-volatile" mount is present a line starting with tmpfs should be returned final String dfOutput = recvUtf8(dfPort, 5); assertEquals("tmpfs", dfOutput); }
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 randomVolPort = taskStatus.getPorts().get("random").getExternalPort(); final Integer namedVolPort = taskStatus.getPorts().get("named").getExternalPort(); final Integer hostnamePort = taskStatus.getPorts().get("hostname").getExternalPort(); assert randomVolPort != null; assert namedVolPort != null; assert hostnamePort != null; // Read "foo" from /volume/bar and /mnt/my-volume/bar assertEquals("foo", recvUtf8(randomVolPort, 3)); assertEquals("foo", recvUtf8(namedVolPort, 3)); // Read hostname from /hostname final String hostname = getNewDockerClient().info().name(); final String mountedHostname = recvUtf8(hostnamePort, hostname.length()); assertEquals(hostname, mountedHostname); }
assertJobEquals(job, taskStatus.getJob());
assertJobEquals(job, taskStatus.getJob());
assertJobEquals(job, taskStatus.getJob());
assertJobEquals(job, firstTaskStatus.getJob()); assertEquals(1, listContainers(dockerClient, testTag).size()); assertTrue(dockerClient.inspectContainer(firstTaskStatus.getContainerId()).state().running());
assertJobEquals(job, firstTaskStatus.getJob()); assertNotNull(dockerClient.inspectContainer(firstTaskStatus.getContainerId()));
@Override protected String getZkEventsPath(TaskStatusEvent event) { final JobId jobId = event.getStatus().getJob().getId(); return Paths.historyJobHostEvents(jobId, hostname); }
@Override protected String getKey(final TaskStatusEvent event) { return event.getStatus().getJob().getId().toString(); }
@Override public void update() throws InterruptedException { final TaskStatus status = builder .setGoal(goal) .setState(state) .setContainerId(containerId) .setThrottled(throttleState) .build(); model.setTaskStatus(status.getJob().getId(), status); }