Package co.cask.cdap.app

Examples of co.cask.cdap.app.ApplicationSpecification


  @Override
  protected ProgramController launch(Program program, ProgramOptions options,
                                     File hConfFile, File cConfFile, ApplicationLauncher launcher) {
    // Extract and verify parameters
    ApplicationSpecification appSpec = program.getSpecification();
    Preconditions.checkNotNull(appSpec, "Missing application specification.");

    ProgramType processorType = program.getType();
    Preconditions.checkNotNull(processorType, "Missing processor type.");
    Preconditions.checkArgument(processorType == ProgramType.WORKFLOW, "Only WORKFLOW process type is supported.");

    WorkflowSpecification workflowSpec = appSpec.getWorkflows().get(program.getName());
    Preconditions.checkNotNull(workflowSpec, "Missing WorkflowSpecification for %s", program.getName());

    LOG.info("Launching distributed workflow: " + program.getName() + ":" + workflowSpec.getName());
    TwillController controller = launcher.launch(new WorkflowTwillApplication(program, workflowSpec,
                                                                              hConfFile, cConfFile, eventHandler));
View Full Code Here


    });

    List<ProgramSpecification> deletedProgramSpecs = Lists.newArrayList();

    if (existing != null) {
      ApplicationSpecification existingAppSpec = existing.getSpec();

      ImmutableMap<String, ProgramSpecification> existingSpec = new ImmutableMap.Builder<String, ProgramSpecification>()
                                                                      .putAll(existingAppSpec.getMapReduce())
                                                                      .putAll(existingAppSpec.getSpark())
                                                                      .putAll(existingAppSpec.getWorkflows())
                                                                      .putAll(existingAppSpec.getFlows())
                                                                      .putAll(existingAppSpec.getProcedures())
                                                                      .putAll(existingAppSpec.getServices())
                                                                      .build();

      ImmutableMap<String, ProgramSpecification> newSpec = new ImmutableMap.Builder<String, ProgramSpecification>()
                                                                      .putAll(appSpec.getMapReduce())
                                                                      .putAll(existingAppSpec.getSpark())
                                                                      .putAll(appSpec.getWorkflows())
                                                                      .putAll(appSpec.getFlows())
                                                                      .putAll(appSpec.getProcedures())
                                                                      .putAll(appSpec.getServices())
                                                                      .build();
View Full Code Here

              id.getAccountId(), id.getApplicationId(), id.getId(), flowletId, count);

    txnl.executeUnchecked(new TransactionExecutor.Function<AppMds, Void>() {
      @Override
      public Void apply(AppMds mds) throws Exception {
        ApplicationSpecification appSpec = getAppSpecOrFail(mds, id);
        ApplicationSpecification newAppSpec = updateFlowletInstancesInAppSpec(appSpec, id, flowletId, count);
        replaceAppSpecInProgramJar(id, newAppSpec, ProgramType.FLOW);

        mds.apps.updateAppSpec(id.getAccountId(), id.getApplicationId(), newAppSpec);
        return null;
      }
View Full Code Here

      String runIdOption = options.getArguments().getOption(ProgramOptionConstants.RUN_ID);
      Preconditions.checkNotNull(runIdOption, "Missing runId");
      RunId runId = RunIds.fromString(runIdOption);

      ApplicationSpecification appSpec = program.getSpecification();
      Preconditions.checkNotNull(appSpec, "Missing application specification.");

      ProgramType processorType = program.getType();
      Preconditions.checkNotNull(processorType, "Missing processor type.");
      Preconditions.checkArgument(processorType == ProgramType.FLOW, "Only FLOW process type is supported.");

      String processorName = program.getName();
      Preconditions.checkNotNull(processorName, "Missing processor name.");

      FlowSpecification flowSpec = appSpec.getFlows().get(processorName);
      FlowletDefinition flowletDef = flowSpec.getFlowlets().get(flowletName);
      Preconditions.checkNotNull(flowletDef, "Definition missing for flowlet \"%s\"", flowletName);

      boolean disableTransaction = program.getMainClass().isAnnotationPresent(DisableTransaction.class);
      if (disableTransaction) {
View Full Code Here

  @Override
  public int getFlowletInstances(final Id.Program id, final String flowletId) {
    return txnl.executeUnchecked(new TransactionExecutor.Function<AppMds, Integer>() {
      @Override
      public Integer apply(AppMds mds) throws Exception {
        ApplicationSpecification appSpec = getAppSpecOrFail(mds, id);
        FlowSpecification flowSpec = getFlowSpecOrFail(id, appSpec);
        FlowletDefinition flowletDef = getFlowletDefinitionOrFail(flowSpec, flowletId, id);
        return flowletDef.getInstances();
      }
    });
View Full Code Here

  @Override
  public int getProcedureInstances(final Id.Program id) {
    return txnl.executeUnchecked(new TransactionExecutor.Function<AppMds, Integer>() {
      @Override
      public Integer apply(AppMds mds) throws Exception {
        ApplicationSpecification appSpec = getAppSpecOrFail(mds, id);
        ProcedureSpecification specification = getProcedureSpecOrFail(id, appSpec);
        return specification.getInstances();
      }
    });
  }
View Full Code Here

    Preconditions.checkArgument(count > 0, "cannot change number of program instances to negative number: " + count);

    txnl.executeUnchecked(new TransactionExecutor.Function<AppMds, Void>() {
      @Override
      public Void apply(AppMds mds) throws Exception {
        ApplicationSpecification appSpec = getAppSpecOrFail(mds, id);
        ProcedureSpecification specification = getProcedureSpecOrFail(id, appSpec);

        ProcedureSpecification newSpecification =  new DefaultProcedureSpecification(specification.getClassName(),
                                                                                     specification.getName(),
                                                                                     specification.getDescription(),
                                                                                     specification.getDataSets(),
                                                                                     specification.getProperties(),
                                                                                     specification.getResources(),
                                                                                     count);

        ApplicationSpecification newAppSpec = replaceProcedureInAppSpec(appSpec, id, newSpecification);
        replaceAppSpecInProgramJar(id, newAppSpec, ProgramType.PROCEDURE);

        mds.apps.updateAppSpec(id.getAccountId(), id.getApplicationId(), newAppSpec);
        return null;
      }
View Full Code Here

  @Override
  public int getServiceRunnableInstances(final Id.Program id, final String runnable) {
    return txnl.executeUnchecked(new TransactionExecutor.Function<AppMds, Integer>() {
      @Override
      public Integer apply(AppMds mds) throws Exception {
        ApplicationSpecification appSpec = getAppSpecOrFail(mds, id);
        ServiceSpecification serviceSpec = getServiceSpecOrFail(id, appSpec);
        RuntimeSpecification runtimeSpec = getRunnableSpecOrFail(id, serviceSpec, runnable);
        return runtimeSpec.getResourceSpecification().getInstances();
      }
    });
View Full Code Here

    Preconditions.checkArgument(count > 0, "cannot change number of program instances to negative number: " + count);

    txnl.executeUnchecked(new TransactionExecutor.Function<AppMds, Void>() {
      @Override
      public Void apply(AppMds mds) throws Exception {
        ApplicationSpecification appSpec = getAppSpecOrFail(mds, id);
        ServiceSpecification serviceSpec = getServiceSpecOrFail(id, appSpec);

        RuntimeSpecification runtimeSpec = serviceSpec.getRunnables().get(runnable);
        if (runtimeSpec == null) {
          throw new IllegalArgumentException(String.format("Runnable not found, app: %s, service: %s, runnable %s",
                                                           id.getApplication(), id.getId(), runnable));
        }

        ResourceSpecification resourceSpec = replaceInstanceCount(runtimeSpec.getResourceSpecification(), count);
        RuntimeSpecification newRuntimeSpec = replaceResourceSpec(runtimeSpec, resourceSpec);

        Preconditions.checkNotNull(newRuntimeSpec);

        ApplicationSpecification newAppSpec =
          replaceServiceSpec(appSpec, id.getId(), replaceRuntimeSpec(runnable, serviceSpec, newRuntimeSpec));
        replaceAppSpecInProgramJar(id, newAppSpec, ProgramType.SERVICE);

        mds.apps.updateAppSpec(id.getAccountId(), id.getApplicationId(), newAppSpec);
        return null;
View Full Code Here

              flow.getAccountId(), flow.getApplicationId(), flow.getId(), flowletId, oldValue, newValue);

    txnl.executeUnchecked(new TransactionExecutor.Function<AppMds, Void>() {
      @Override
      public Void apply(AppMds mds) throws Exception {
        ApplicationSpecification appSpec = getAppSpecOrFail(mds, flow);

        FlowSpecification flowSpec = getFlowSpecOrFail(flow, appSpec);

        boolean adjusted = false;
        List<FlowletConnection> conns = Lists.newArrayList();
        for (FlowletConnection con : flowSpec.getConnections()) {
          if (FlowletConnection.Type.STREAM == con.getSourceType() &&
            flowletId.equals(con.getTargetName()) &&
            oldValue.equals(con.getSourceName())) {

            conns.add(new FlowletConnection(con.getSourceType(), newValue, con.getTargetName()));
            adjusted = true;
          } else {
            conns.add(con);
          }
        }

        if (!adjusted) {
          throw new IllegalArgumentException(
            String.format("Cannot change stream connection to %s, the connection to be changed is not found," +
                            " account: %s, application: %s, flow: %s, flowlet: %s, source stream: %s",
                          newValue, flow.getAccountId(), flow.getApplicationId(), flow.getId(), flowletId, oldValue));
        }

        FlowletDefinition flowletDef = getFlowletDefinitionOrFail(flowSpec, flowletId, flow);
        FlowletDefinition newFlowletDef = new FlowletDefinition(flowletDef, oldValue, newValue);
        ApplicationSpecification newAppSpec = replaceInAppSpec(appSpec, flow, flowSpec, newFlowletDef, conns);

        replaceAppSpecInProgramJar(flow, newAppSpec, ProgramType.FLOW);

        Id.Application app = flow.getApplication();
        mds.apps.updateAppSpec(app.getAccountId(), app.getId(), newAppSpec);
View Full Code Here

TOP

Related Classes of co.cask.cdap.app.ApplicationSpecification

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.