use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class AbstractDeploymentTest method testDeployment_whenAttachDirectoryWithoutId_thenFilesAvailableOnMembers.
@Test
public void testDeployment_whenAttachDirectoryWithoutId_thenFilesAvailableOnMembers() throws Throwable {
String dirName = "deployment";
String dirToAttach = Paths.get(this.getClass().getResource("/" + dirName).toURI()).toString();
Pipeline pipeline = attachDirectoryPipeline(dirName);
JobConfig jobConfig = new JobConfig();
jobConfig.attachDirectory(dirToAttach);
executeAndPeel(getJet().newJob(pipeline, jobConfig));
}
use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class AbstractDeploymentTest method testDeployment_whenAttachNestedDirectory_thenFilesAvailableOnMembers.
@Test
public void testDeployment_whenAttachNestedDirectory_thenFilesAvailableOnMembers() throws Throwable {
Pipeline pipeline = Pipeline.create();
String dirName = "nested";
String dirToAttach = Paths.get(this.getClass().getResource("/" + dirName).toURI()).toString();
pipeline.readFrom(TestSources.items(1)).flatMapUsingService(ServiceFactories.sharedService(context -> context.attachedDirectory(dirName)), (file, integer) -> Traversers.traverseStream(Files.list(file.toPath()).map(Path::toString))).apply(assertCollected(c -> {
c.forEach(s -> {
File dir = new File(s);
assertTrue(dir.exists());
try {
List<Path> subFiles = Files.list(dir.toPath()).collect(toList());
assertEquals("each dir should contain 1 file", 1, subFiles.size());
} catch (IOException ex) {
throw new RuntimeException(ex);
}
});
assertEquals("list size must be 3", 3, c.size());
})).writeTo(Sinks.logger());
JobConfig jobConfig = new JobConfig();
jobConfig.attachDirectory(dirToAttach);
executeAndPeel(getJet().newJob(pipeline, jobConfig));
}
use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class AbstractDeploymentTest method testDeployment_whenJarAddedAsResource_thenClassesAvailableOnClassLoader.
@Test
public void testDeployment_whenJarAddedAsResource_thenClassesAvailableOnClassLoader() throws Throwable {
DAG dag = new DAG();
dag.newVertex("load class", () -> new LoadClassesIsolated(true));
JobConfig jobConfig = new JobConfig();
jobConfig.addJar(this.getClass().getResource("/deployment/sample-pojo-1.0-person.jar"));
executeAndPeel(getJet().newJob(dag, jobConfig));
}
use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class AbstractDeploymentTest method testDeployment_whenAddClass_thenNestedClassesAreAddedAsWell.
@Test
public void testDeployment_whenAddClass_thenNestedClassesAreAddedAsWell() throws Throwable {
DAG dag = new DAG();
dag.newVertex("executes lambda from a nested class", NestedClassIsLoaded::new);
JobConfig jobConfig = new JobConfig();
URL classUrl = new File(CLASS_DIRECTORY).toURI().toURL();
URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { classUrl }, null);
Class<?> worker = urlClassLoader.loadClass("com.sample.lambda.Worker");
jobConfig.addClass(worker);
executeAndPeel(getJet().newJob(dag, jobConfig));
}
use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class JobMetrics_MiscTest method when_jobSuspended_andMetricsNotStored_then_onlyPeriodicMetricsReturned.
@Test
public void when_jobSuspended_andMetricsNotStored_then_onlyPeriodicMetricsReturned() throws Throwable {
DAG dag = new DAG();
Vertex v1 = dag.newVertex("v1", TestProcessors.MockP::new);
Vertex v2 = dag.newVertex("v2", (SupplierEx<Processor>) TestProcessors.NoOutputSourceP::new);
dag.edge(between(v1, v2));
// init
JobConfig config = new JobConfig().setMetricsEnabled(// enable metric collection
true).setStoreMetricsAfterJobCompletion(// disable metric saving on completion
false);
Job job = hz().getJet().newJob(dag, config);
// when
TestProcessors.NoOutputSourceP.executionStarted.await();
// then
assertJobStatusEventually(job, JobStatus.RUNNING);
assertTrueEventually(() -> assertJobHasMetrics(job, false));
// when
job.suspend();
// then
assertJobStatusEventually(job, SUSPENDED);
assertTrueEventually(() -> assertEmptyJobMetrics(job, false));
// when
job.resume();
// then
assertJobStatusEventually(job, RUNNING);
assertTrueEventually(() -> assertJobHasMetrics(job, false));
// when
TestProcessors.NoOutputSourceP.proceedLatch.countDown();
job.join();
// then
assertJobStatusEventually(job, JobStatus.COMPLETED);
assertEmptyJobMetrics(job, false);
}
Aggregations