/**
* Executes a program and block until it is completed.
*/
private void executeAndBlock(final Program program, ProgramOptions options) throws JobExecutionException {
ProgramController controller = runtimeService.run(program, options).getController();
store.setStart(program.getId(), controller.getRunId().getId(),
TimeUnit.SECONDS.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS));
final Id.Program programId = program.getId();
final String runId = controller.getRunId().getId();
final CountDownLatch latch = new CountDownLatch(1);
controller.addListener(new AbstractListener() {
@Override
public void stopped() {
store.setStop(programId, runId,
TimeUnit.SECONDS.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS),
ProgramController.State.STOPPED.toString());