Package co.cask.cdap.app.runtime

Examples of co.cask.cdap.app.runtime.ProgramController


                                                                          program.getApplicationId(),
                                                                          serviceSpec.getName(), runnableName,
                                                                          twillContext.getInstanceId())),
                        new PropertyFieldSetter(runnableSpec.getRunnableSpecification().getConfigs()));

      ProgramController controller = new InMemoryRunnableProgramController(program.getName(), runnableName,
                                                                           twillContext, driver,
                                                                           discoverables);

      LOG.info("Starting Runnable: {}", runnableName);
      driver.start();
View Full Code Here


      }

      // create more runnable instances, if necessary.
      for (int instanceId = liveCount; instanceId < newCount; instanceId++) {
        ProgramOptions newProgramOpts = createRunnableOptions(runnableName, instanceId, newCount, getRunId());
        ProgramController programController = startRunnable(program, newProgramOpts);
        runnables.put(runnableName, instanceId, programController);
      }
    }
View Full Code Here

      BasicArguments userArguments = new BasicArguments(userArgs);
      ProgramRuntimeService.RuntimeInfo runtimeInfo =
        runtimeService.run(program, new SimpleProgramOptions(id.getId(), new BasicArguments(), userArguments, debug));

      ProgramController controller = runtimeInfo.getController();
      final String runId = controller.getRunId().getId();

      controller.addListener(new AbstractListener() {
        @Override
        public void stopped() {
          store.setStop(id, runId,
                        TimeUnit.SECONDS.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS),
                        ProgramController.State.STOPPED.toString());
View Full Code Here

      }
    }

    try {
      Preconditions.checkNotNull(runtimeInfo, UserMessages.getMessage(UserErrors.RUNTIME_INFO_NOT_FOUND));
      ProgramController controller = runtimeInfo.getController();
      controller.stop().get();
      return AppFabricServiceStatus.OK;
    } catch (Throwable throwable) {
      LOG.warn(throwable.getMessage(), throwable);
      return AppFabricServiceStatus.INTERNAL_ERROR;
    }
View Full Code Here

  }

  private void doStop(ProgramRuntimeService.RuntimeInfo runtimeInfo)
    throws ExecutionException, InterruptedException {
    Preconditions.checkNotNull(runtimeInfo, UserMessages.getMessage(UserErrors.RUNTIME_INFO_NOT_FOUND));
    ProgramController controller = runtimeInfo.getController();
    controller.stop().get();
  }
View Full Code Here

  private RuntimeInfo createRuntimeInfo(ProgramType type, Id.Program programId, TwillController controller) {
    try {
      Program program = store.loadProgram(programId, type);
      Preconditions.checkNotNull(program, "Program not found");

      ProgramController programController = createController(program, controller);
      return programController == null ? null : new SimpleRuntimeInfo(programController, type, programId);
    } catch (Exception e) {
      LOG.error("Got exception: ", e);
      return null;
    }
View Full Code Here

  /**
   * 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());
View Full Code Here

    LoggingContextAccessor.setLoggingContext(context.getLoggingContext());

    Service sparkRuntimeService = new SparkRuntimeService(cConf, hConf, spark, spec, context,
                                                          program.getJarLocation(), locationFactory,
                                                          txSystemClient);
    ProgramController controller = new SparkProgramController(sparkRuntimeService, context);

    LOG.info("Starting Spark Job: {}", context.toString());
    sparkRuntimeService.start();
    return controller;
  }
View Full Code Here

    LoggingContextAccessor.setLoggingContext(context.getLoggingContext());

    Service mapReduceRuntimeService = new MapReduceRuntimeService(cConf, hConf, mapReduce, spec, context,
                                                                  program.getJarLocation(), locationFactory,
                                                                  streamAdmin, txSystemClient);
    ProgramController controller = new MapReduceProgramController(mapReduceRuntimeService, context);

    LOG.info("Starting MapReduce Job: {}", context.toString());
    mapReduceRuntimeService.start();
    return controller;
  }
View Full Code Here

    RunId runId = RunIds.generate();
    WorkflowDriver driver = new WorkflowDriver(program, runId, options, hostname, workflowSpec, mapReduceProgramRunner);

    // Controller needs to be created before starting the driver so that the state change of the driver
    // service can be fully captured by the controller.
    ProgramController controller = new WorkflowProgramController(program, driver, serviceAnnouncer, runId);
    driver.start();

    return controller;
  }
View Full Code Here

TOP

Related Classes of co.cask.cdap.app.runtime.ProgramController

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.