Search in sources :

Example 1 with NoopTwillRunnerService

use of io.cdap.cdap.common.twill.NoopTwillRunnerService in project cdap by caskdata.

the class DefaultRuntimeJobTest method testInjector.

@Test
public void testInjector() throws Exception {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().toString());
    LocationFactory locationFactory = new LocalLocationFactory(TEMP_FOLDER.newFile());
    DefaultRuntimeJob defaultRuntimeJob = new DefaultRuntimeJob();
    Arguments systemArgs = new BasicArguments(Collections.singletonMap(SystemArguments.PROFILE_NAME, "test"));
    Node node = new Node("test", Node.Type.MASTER, "127.0.0.1", System.currentTimeMillis(), Collections.emptyMap());
    Cluster cluster = new Cluster("test", ClusterStatus.RUNNING, Collections.singleton(node), Collections.emptyMap());
    ProgramRunId programRunId = NamespaceId.DEFAULT.app("app").workflow("workflow").run(RunIds.generate());
    SimpleProgramOptions programOpts = new SimpleProgramOptions(programRunId.getParent(), systemArgs, new BasicArguments());
    Injector injector = Guice.createInjector(defaultRuntimeJob.createModules(new RuntimeJobEnvironment() {

        @Override
        public LocationFactory getLocationFactory() {
            return locationFactory;
        }

        @Override
        public TwillRunner getTwillRunner() {
            return new NoopTwillRunnerService();
        }

        @Override
        public Map<String, String> getProperties() {
            return Collections.emptyMap();
        }
    }, cConf, programRunId, programOpts));
    injector.getInstance(LogAppenderInitializer.class);
    defaultRuntimeJob.createCoreServices(injector, systemArgs, cluster);
}
Also used : Node(io.cdap.cdap.runtime.spi.provisioner.Node) Arguments(io.cdap.cdap.app.runtime.Arguments) SystemArguments(io.cdap.cdap.internal.app.runtime.SystemArguments) BasicArguments(io.cdap.cdap.internal.app.runtime.BasicArguments) Cluster(io.cdap.cdap.runtime.spi.provisioner.Cluster) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) NoopTwillRunnerService(io.cdap.cdap.common.twill.NoopTwillRunnerService) Injector(com.google.inject.Injector) RuntimeJobEnvironment(io.cdap.cdap.runtime.spi.runtimejob.RuntimeJobEnvironment) BasicArguments(io.cdap.cdap.internal.app.runtime.BasicArguments) ProgramRunId(io.cdap.cdap.proto.id.ProgramRunId) SimpleProgramOptions(io.cdap.cdap.internal.app.runtime.SimpleProgramOptions) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) Test(org.junit.Test)

Example 2 with NoopTwillRunnerService

use of io.cdap.cdap.common.twill.NoopTwillRunnerService in project cdap by caskdata.

the class MockMasterEnvironment method initialize.

@Override
public void initialize(MasterEnvironmentContext context) {
    zkClient = ZKClientService.Builder.of(context.getConfigurations().get(Constants.Zookeeper.QUORUM)).build();
    zkClient.startAndWait();
    discoveryService = new ZKDiscoveryService(zkClient);
    twillRunnerService = new NoopTwillRunnerService();
    Map<String, String> conf = context.getConfigurations();
    // Add conf properties for SystemMetricsExporterServiceMain
    String prefix = MasterEnvironmentContext.ENVIRONMENT_PROPERTY_PREFIX;
    conf.put(prefix + "key1", "value1");
    conf.put(prefix + "key2", "value2");
}
Also used : ZKDiscoveryService(org.apache.twill.discovery.ZKDiscoveryService) NoopTwillRunnerService(io.cdap.cdap.common.twill.NoopTwillRunnerService)

Aggregations

NoopTwillRunnerService (io.cdap.cdap.common.twill.NoopTwillRunnerService)2 Injector (com.google.inject.Injector)1 Arguments (io.cdap.cdap.app.runtime.Arguments)1 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)1 BasicArguments (io.cdap.cdap.internal.app.runtime.BasicArguments)1 SimpleProgramOptions (io.cdap.cdap.internal.app.runtime.SimpleProgramOptions)1 SystemArguments (io.cdap.cdap.internal.app.runtime.SystemArguments)1 ProgramRunId (io.cdap.cdap.proto.id.ProgramRunId)1 Cluster (io.cdap.cdap.runtime.spi.provisioner.Cluster)1 Node (io.cdap.cdap.runtime.spi.provisioner.Node)1 RuntimeJobEnvironment (io.cdap.cdap.runtime.spi.runtimejob.RuntimeJobEnvironment)1 ZKDiscoveryService (org.apache.twill.discovery.ZKDiscoveryService)1 LocalLocationFactory (org.apache.twill.filesystem.LocalLocationFactory)1 LocationFactory (org.apache.twill.filesystem.LocationFactory)1 Test (org.junit.Test)1