use of io.cdap.cdap.runtime.spi.runtimejob.RuntimeJobEnvironment in project cdap by caskdata.
the class RemoteExecutionJobMainTest method testJobEnvironment.
@Test
public void testJobEnvironment() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.set(Constants.CFG_HDFS_NAMESPACE, TEMP_FOLDER.newFolder().getAbsolutePath());
RemoteExecutionJobMain runner = new RemoteExecutionJobMain();
RuntimeJobEnvironment jobEnv = runner.initialize(cConf);
try {
Assert.assertNotNull(jobEnv.getLocationFactory());
Assert.assertNotNull(jobEnv.getTwillRunner());
Map<String, String> properties = jobEnv.getProperties();
ZKClientService zkClient = ZKClientService.Builder.of(properties.get(Constants.Zookeeper.QUORUM)).build();
zkClient.startAndWait();
try {
Assert.assertNotNull(zkClient.exists("/").get());
} finally {
zkClient.stopAndWait();
}
} finally {
runner.destroy();
}
}
use of io.cdap.cdap.runtime.spi.runtimejob.RuntimeJobEnvironment 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);
}
Aggregations