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);
}
}