Package co.cask.cdap.common.lang

Examples of co.cask.cdap.common.lang.InstantiatorFactory


    this.schema = schema;

    this.type = type.getRawType().equals(StreamEvent.class)
                      ? (TypeToken<T>) TypeToken.of(DefaultStreamEvent.class) : type;

    this.creatorFactory = new InstantiatorFactory(true);
    this.creators = Maps.newIdentityHashMap();
    this.fieldAccessorFactory = new ReflectionFieldAccessorFactory();
  }
View Full Code Here


      } else if (runnableClass.isAssignableFrom(ServiceWorkerTwillRunnable.class)) {
        runnable = new ServiceWorkerTwillRunnable(program, runId, runnableName, program.getClassLoader(),
                                                  cConfiguration, metricsCollectionService, datasetFramework,
                                                  transactionSystemClient, discoveryServiceClient);
      } else {
        runnable = new InstantiatorFactory(false).get(runnableType).create();
      }

      InMemoryRunnableDriver driver = new
        InMemoryRunnableDriver(runnable, twillContext, new UserServiceLoggingContext(program.getAccountId(),
                                                                                     program.getApplicationId(),
View Full Code Here

        delegate = new ServiceWorkerTwillRunnable(program, runId, runnableName, program.getClassLoader(), cConf,
                                                  metricsCollectionService, datasetFramework,
                                                  transactionSystemClient,
                                                  discoveryServiceClient);
      } else {
        delegate = (TwillRunnable) new InstantiatorFactory(false).get(TypeToken.of(clz)).create();
      }

      Reflections.visit(delegate, TypeToken.of(delegate.getClass()),
                        new MetricsFieldSetter(new ServiceRunnableMetrics(metricsCollectionService,
                                                                          program.getApplicationId(),
View Full Code Here

      // Creates QueueSpecification
      Table<Node, String, Set<QueueSpecification>> queueSpecs =
        new SimpleQueueSpecificationGenerator(Id.Application.from(program.getAccountId(), program.getApplicationId()))
          .create(flowSpec);

      Flowlet flowlet = new InstantiatorFactory(false).get(TypeToken.of(flowletClass)).create();
      TypeToken<? extends Flowlet> flowletType = TypeToken.of(flowletClass);

      // Set the context classloader to the cdap classloader. It is needed for the DatumWriterFactory be able
      // to load cdap classes
      Thread.currentThread().setContextClassLoader(FlowletProgramRunner.class.getClassLoader());
View Full Code Here

    List<String> handlerNames = GSON.fromJson(runnableArgs.get(CONF_HANDLER), HANDLER_NAMES_TYPE);
    List<HttpServiceSpecification> specs = GSON.fromJson(runnableArgs.get(CONF_SPEC), HANDLER_SPEC_TYPE);
    datasets = GSON.fromJson(runnableArgs.get("service.datasets"), new TypeToken<Set<String>>() { }.getType());
    // we will need the context based on the spec when we create NettyHttpService
    List<HandlerDelegatorContext> delegatorContexts = Lists.newArrayList();
    InstantiatorFactory instantiatorFactory = new InstantiatorFactory(false);

    for (int i = 0; i < handlerNames.size(); ++i) {
      try {
        Class<?> handlerClass = program.getClassLoader().loadClass(handlerNames.get(i));
        @SuppressWarnings("unchecked")
View Full Code Here

  public void initialize(TwillContext context) {
    Map<String, String> runnableArgs = context.getSpecification().getConfigs();
    String serviceClassName = runnableArgs.get("service.class.name");
    datasets = GSON.fromJson(runnableArgs.get("service.datasets"), new TypeToken<Set<String>>() { }.getType());

    InstantiatorFactory factory = new InstantiatorFactory(false);
    try {
      TypeToken<?> type = TypeToken.of(programClassLoader.loadClass(serviceClassName));
      worker = (ServiceWorker) factory.get(type).create();
      Reflections.visit(worker, type, new MetricsFieldSetter(metrics),
                                      new PropertyFieldSetter(runnableArgs));
      if (worker instanceof GuavaServiceWorker) {
        String delegateClassName = runnableArgs.get("delegate.class.name");
        type = TypeToken.of(programClassLoader.loadClass(delegateClassName));
        ((GuavaServiceWorker) worker).setDelegate((Service) factory.get(type).create());
      }
      int instanceId = context.getInstanceId();
      worker.initialize(new BasicServiceWorkerContext(program, runId, instanceId, runnableName, programClassLoader,
                                                      cConfiguration, context.getSpecification().getConfigs(), datasets,
                                                      metricsCollectionService, datasetFramework,
View Full Code Here

    this.dataFabricFacade = dataFabricFacade;
    this.context = context;

    try {
      TypeToken<? extends Procedure> procedureType = TypeToken.of(program.<Procedure>getMainClass());
      procedure = new InstantiatorFactory(false).get(procedureType).create();
      Reflections.visit(procedure, TypeToken.of(procedure.getClass()),
                        new PropertyFieldSetter(context.getSpecification().getProperties()),
                        new DataSetFieldSetter(context),
                        new MetricsFieldSetter(context.getMetrics()));
View Full Code Here

    String workflowBatch = arguments.getOption(ProgramOptionConstants.WORKFLOW_BATCH);

    Spark spark;
    try {
      spark = new InstantiatorFactory(false).get(TypeToken.of(program.<Spark>getMainClass())).create();
    } catch (Exception e) {
      LOG.error("Failed to instantiate Spark class for {}", spec.getClassName(), e);
      throw Throwables.propagate(e);
    }
View Full Code Here

                                : System.currentTimeMillis();

    String workflowBatch = arguments.getOption(ProgramOptionConstants.WORKFLOW_BATCH);
    MapReduce mapReduce;
    try {
      mapReduce = new InstantiatorFactory(false).get(TypeToken.of(program.<MapReduce>getMainClass())).create();
    } catch (Exception e) {
      LOG.error("Failed to instantiate MapReduce class for {}", spec.getClassName(), e);
      throw Throwables.propagate(e);
    }
View Full Code Here

  }

  @Override
  protected void run() throws Exception {
    LOG.info("Start workflow execution for {}", workflowSpec);
    InstantiatorFactory instantiator = new InstantiatorFactory(false);
    ClassLoader classLoader = program.getClassLoader();

    // Executes actions step by step. Individually invoke the init()->run()->destroy() sequence.
    Iterator<WorkflowActionSpecification> iterator = workflowSpec.getActions().iterator();
    int step = 0;
View Full Code Here

TOP

Related Classes of co.cask.cdap.common.lang.InstantiatorFactory

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.