public void start(ProgramOptions programOptions, @Nullable String twillRunId, ProgramDescriptor programDescriptor) { programStateWriter.start(programRunId, programOptions, twillRunId, programDescriptor); }
public void start(ProgramOptions programOptions, @Nullable String twillRunId, ProgramDescriptor programDescriptor) { programStateWriter.start(programRunId, programOptions, twillRunId, programDescriptor); }
programStateWriter.start(programRunId, newProgramOptions, null, programDescriptor);
programStateWriter.start(programRunId, newProgramOptions, null, programDescriptor);
private void publishProgramStatus(ProgramRunId programRunId, ProgramStatus status) { ProgramStateWriter stateWriter = new MessagingProgramStateWriter(cConf, messagingService); switch (status) { case INITIALIZING: stateWriter.start(programRunId, new SimpleProgramOptions(programRunId.getParent()), null, null); break; case RUNNING: stateWriter.running(programRunId, null); break; case COMPLETED: stateWriter.completed(programRunId); break; case FAILED: stateWriter.error(programRunId, new Exception("Program run failed")); break; case KILLED: stateWriter.killed(programRunId); break; default: throw new IllegalArgumentException("Unsupported program status " + status); } }
ProgramRunId programRunId = programId.run(RunIds.generate()); programStateWriter.start(programRunId, options, null, programDescriptor); return startInternal(programDescriptor, options, programRunId);
ProgramRunId programRunId = programId.run(RunIds.generate()); programStateWriter.start(programRunId, options, null, programDescriptor); return startInternal(programDescriptor, options, programRunId);
@Test public void testAppSpecNotRequiredToWriteState() throws Exception { ProgramId programId = NamespaceId.DEFAULT.app("someapp").program(ProgramType.SERVICE, "s"); Map<String, String> systemArguments = new HashMap<>(); systemArguments.put(ProgramOptionConstants.SKIP_PROVISIONING, Boolean.TRUE.toString()); systemArguments.put(SystemArguments.PROFILE_NAME, ProfileId.NATIVE.getScopedName()); ProgramOptions programOptions = new SimpleProgramOptions(programId, new BasicArguments(systemArguments), new BasicArguments()); ProgramRunId runId = programId.run(RunIds.generate()); ArtifactId artifactId = NamespaceId.DEFAULT.artifact("testArtifact", "1.0").toApiArtifactId(); ApplicationSpecification appSpec = new DefaultApplicationSpecification( "name", "1.0.0", "desc", null, artifactId, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()); ProgramDescriptor programDescriptor = new ProgramDescriptor(programId, appSpec); programStateWriter.start(runId, programOptions, null, programDescriptor); Tasks.waitFor(ProgramRunStatus.STARTING, () -> txnl.execute(() -> { RunRecordMeta meta = metadataStoreDataset.getRun(runId); if (meta == null) { return null; } Assert.assertEquals(artifactId, meta.getArtifactId()); return meta.getStatus(); }), 10, TimeUnit.SECONDS); programStateWriter.completed(runId); }
private void runAndWait(ProgramRunner programRunner, Program program, ProgramOptions options) throws Exception { Closeable closeable = createCloseable(programRunner, program); // Publish the program's starting state RunId runId = ProgramRunners.getRunId(options); String twillRunId = options.getArguments().getOption(ProgramOptionConstants.TWILL_RUN_ID); ProgramDescriptor programDescriptor = new ProgramDescriptor(program.getId(), program.getApplicationSpecification()); programStateWriter.start(program.getId().run(runId), options, twillRunId, programDescriptor); ProgramController controller; try { controller = programRunner.run(program, options); } catch (Throwable t) { // If there is any exception when running the program, close the program to release resources. // Otherwise it will be released when the execution completed. programStateWriter.error(program.getId().run(runId), t); Closeables.closeQuietly(closeable); throw t; } blockForCompletion(closeable, controller); if (controller instanceof WorkflowDataProvider) { updateWorkflowToken(((WorkflowDataProvider) controller).getWorkflowToken()); } else { // This shouldn't happen throw new IllegalStateException("No WorkflowToken available after program completed: " + program.getId()); } }
private void runAndWait(ProgramRunner programRunner, Program program, ProgramOptions options) throws Exception { Closeable closeable = createCloseable(programRunner, program); // Publish the program's starting state RunId runId = ProgramRunners.getRunId(options); String twillRunId = options.getArguments().getOption(ProgramOptionConstants.TWILL_RUN_ID); ProgramDescriptor programDescriptor = new ProgramDescriptor(program.getId(), program.getApplicationSpecification()); programStateWriter.start(program.getId().run(runId), options, twillRunId, programDescriptor); ProgramController controller; try { controller = programRunner.run(program, options); } catch (Throwable t) { // If there is any exception when running the program, close the program to release resources. // Otherwise it will be released when the execution completed. programStateWriter.error(program.getId().run(runId), t); Closeables.closeQuietly(closeable); throw t; } blockForCompletion(closeable, controller); if (controller instanceof WorkflowDataProvider) { updateWorkflowToken(((WorkflowDataProvider) controller).getWorkflowToken()); } else { // This shouldn't happen throw new IllegalStateException("No WorkflowToken available after program completed: " + program.getId()); } }
ProgramOptions programOptions = new SimpleProgramOptions(anotherWorkflowRun.getParent(), systemArgs, new BasicArguments(), false); programStateWriter.start(anotherWorkflowRun, programOptions, null, programDescriptor); programStateWriter.running(anotherWorkflowRun, null); long lastProcessed = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()); programStateWriter.start(someWorkflowRun, new SimpleProgramOptions(someWorkflowRun.getParent(), systemArgs, new BasicArguments()), null, programDescriptor);
ProgramDescriptor programDescriptor = new ProgramDescriptor(programId, appSpec); heartBeatTxnl.execute(() -> { programStateWriter.start(runId, programOptions, null, programDescriptor); }); checkProgramStatus(artifactId, runId, ProgramRunStatus.STARTING); programStateWriter.start(runId2, programOptions, null, programDescriptor); }); checkProgramStatus(artifactId, runId2, ProgramRunStatus.STARTING);