@Override public void killed() { super.killed(); // The AM is stopped explicitly, always record the state as killed. programStateWriterWithHeartBeat.killed(); }
void writeError(ProgramStateWriterWithHeartBeat writer) { String errorMessage = String.format("Container %s, instance %s stopped with exit status %d", containerId, instanceId, exitStatus); writer.error(new Exception(errorMessage)); } }
public void running(@Nullable String twillRunId) { programStateWriter.running(programRunId, twillRunId); scheduleHeartBeatThread(); }
new ProgramStateWriterWithHeartBeat(runId, programStateWriter, 1, programStatePublisher); ApplicationSpecification appSpec = new DefaultApplicationSpecification( "name", "1.0.0", "desc", null, artifactId, programStateWriterWithHeartBeat.start(programOptions, null, programDescriptor); Assert.assertEquals(0, ((MockProgramStatePublisher) programStatePublisher).getHeartBeatCount()); programStateWriterWithHeartBeat.running(null); programStateWriterWithHeartBeat.suspend(); Tasks.waitFor(false , () -> programStateWriterWithHeartBeat.isHeartBeatThreadAlive(), 5, TimeUnit.SECONDS, "Heartbeat thread did not stop after 5 seconds"); long heartBeatAfterSuspend = ((MockProgramStatePublisher) programStatePublisher).getHeartBeatCount(); programStateWriterWithHeartBeat.resume(); long expected = heartBeatAfterSuspend + 1; Tasks.waitFor(true , () -> ((MockProgramStatePublisher) programStatePublisher).getHeartBeatCount() > expected, programStateWriterWithHeartBeat.killed(); Tasks.waitFor(false , () -> programStateWriterWithHeartBeat.isHeartBeatThreadAlive(), 5, TimeUnit.SECONDS, "Heartbeat thread did not stop after 5 seconds");
@Override public void containerLaunched(String runnableName, int instanceId, String containerId) { super.containerLaunched(runnableName, instanceId, containerId); if (runningPublished.compareAndSet(false, true)) { // The program is marked as running when the first container for the program is launched programStateWriterWithHeartBeat.running(twillRunId.getId()); } }
public void killed() { stopHeartbeatThread(); programStateWriter.killed(programRunId); }
MessagingService messagingService = injector.getInstance(MessagingService.class); programStateWriterWithHeartBeat = new ProgramStateWriterWithHeartBeat(programRunId, programStateWriter, messagingService, cConf); } catch (Exception e) { throw Throwables.propagate(e);
@Override public void completed() { super.completed(); // On normal AM completion, based on the last container failure to publish the state if (lastContainerFailure == null) { programStateWriterWithHeartBeat.completed(); } else { lastContainerFailure.writeError(programStateWriterWithHeartBeat); } }
@Override public void containerLaunched(String runnableName, int instanceId, String containerId) { super.containerLaunched(runnableName, instanceId, containerId); if (runningPublished.compareAndSet(false, true)) { // The program is marked as running when the first container for the program is launched programStateWriterWithHeartBeat.running(twillRunId.getId()); } }
public void error(Throwable failureCause) { stopHeartbeatThread(); programStateWriter.error(programRunId, failureCause); }
MessagingService messagingService = injector.getInstance(MessagingService.class); programStateWriterWithHeartBeat = new ProgramStateWriterWithHeartBeat(programRunId, programStateWriter, messagingService, cConf); } catch (Exception e) { throw Throwables.propagate(e);
@Override public void completed() { super.completed(); // On normal AM completion, based on the last container failure to publish the state if (lastContainerFailure == null) { programStateWriterWithHeartBeat.completed(); } else { lastContainerFailure.writeError(programStateWriterWithHeartBeat); } }
@Override public void killed() { super.killed(); // The AM is stopped explicitly, always record the state as killed. programStateWriterWithHeartBeat.killed(); }
public void suspend() { stopHeartbeatThread(); programStateWriter.suspend(programRunId); }
void writeError(ProgramStateWriterWithHeartBeat writer) { String errorMessage = String.format("Container %s, instance %s stopped with exit status %d", containerId, instanceId, exitStatus); writer.error(new Exception(errorMessage)); } }
public void resume() { scheduleHeartBeatThread(); programStateWriter.resume(programRunId); }
public void completed() { stopHeartbeatThread(); programStateWriter.completed(programRunId); }
@Override public void aborted() { super.aborted(); programStateWriterWithHeartBeat.error( new Exception(String.format("No containers for %s. Abort the application", programRunId))); }
public void running(@Nullable String twillRunId) { programStateWriter.running(programRunId, twillRunId); scheduleHeartBeatThread(); }
public void killed() { stopHeartbeatThread(); programStateWriter.killed(programRunId); }