Package co.cask.cdap.api.procedure

Examples of co.cask.cdap.api.procedure.ProcedureSpecification


  }

  @Override
  public void addProcedure(Procedure procedure) {
    Preconditions.checkArgument(procedure != null, "Procedure cannot be null.");
    ProcedureSpecification spec = new DefaultProcedureSpecification(procedure, 1);
    procedures.put(spec.getName(), spec);
  }
View Full Code Here


  @Override
  public void addProcedure(Procedure procedure, int instance) {
    Preconditions.checkArgument(procedure != null, "Procedure cannot be null.");
    Preconditions.checkArgument(instance >= 1, "Number of instances can't be less than 1");
    ProcedureSpecification spec = new DefaultProcedureSpecification(procedure, instance);
    procedures.put(spec.getName(), spec);
  }
View Full Code Here

  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

    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(),
View Full Code Here

    }
    return spec;
  }

  private static ProcedureSpecification getProcedureSpecOrFail(Id.Program id, ApplicationSpecification appSpec) {
    ProcedureSpecification procedureSpecification = appSpec.getProcedures().get(id.getId());
    if (procedureSpecification == null) {
      throw new NoSuchElementException("no such procedure @ account id: " + id.getAccountId() +
                                           ", app id: " + id.getApplication() +
                                           ", procedure id: " + id.getId());
    }
View Full Code Here

                                       ResourceSpecification resources) {
    this(null, name, description, dataSets, properties, resources);
  }

  public DefaultProcedureSpecification(Procedure procedure, int instances) {
    ProcedureSpecification configureSpec = procedure.configure();
    Set<String> dataSets = Sets.newHashSet(configureSpec.getDataSets());
    Map<String, String> properties = Maps.newHashMap(configureSpec.getProperties());

    Reflections.visit(procedure, TypeToken.of(procedure.getClass()),
                      new PropertyFieldExtractor(properties),
                      new DataSetFieldExtractor(dataSets));

    this.className = procedure.getClass().getName();
    this.name = configureSpec.getName();
    this.description = configureSpec.getDescription();
    this.dataSets = ImmutableSet.copyOf(dataSets);
    this.properties = ImmutableMap.copyOf(properties);
    this.resources = configureSpec.getResources();
    this.instances = instances;
  }
View Full Code Here

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

    ProcedureSpecification procedureSpec = appSpec.getProcedures().get(program.getName());
    Preconditions.checkNotNull(procedureSpec, "Missing ProcedureSpecification for %s", program.getName());

    LOG.info("Launching distributed flow: " + program.getName() + ":" + procedureSpec.getName());
    TwillController controller = launcher.launch(new ProcedureTwillApplication(program, procedureSpec,
                                                                               hConfFile, cConfFile, eventHandler));
    return new ProcedureTwillProgramController(program.getName(), controller).startListen();
  }
View Full Code Here

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

      ProcedureSpecification procedureSpec = appSpec.getProcedures().get(program.getName());
      Preconditions.checkNotNull(procedureSpec, "Missing ProcedureSpecification for %s", program.getName());

      int instanceId = Integer.parseInt(options.getArguments().getOption(ProgramOptionConstants.INSTANCE_ID, "0"));

      int instanceCount = appSpec.getProcedures().get(program.getName()).getInstances();
View Full Code Here

TOP

Related Classes of co.cask.cdap.api.procedure.ProcedureSpecification

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.