use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.
the class AbstractDeploymentTest method testDeployment_whenZipAddedAsResource_thenClassesFromAllJarsAvailableOnClassLoader.
@Test
public void testDeployment_whenZipAddedAsResource_thenClassesFromAllJarsAvailableOnClassLoader() throws Throwable {
DAG dag = new DAG();
List<String> onClasspath = new ArrayList<>();
onClasspath.add("com.sample.pojo.person.Person$Appereance");
onClasspath.add("com.sample.pojo.car.Car");
List<String> notOnClasspath = new ArrayList<>();
notOnClasspath.add("com.sample.pojo.address.Address");
dag.newVertex("load class", () -> new LoadClassesIsolated(onClasspath, notOnClasspath, true));
JobConfig jobConfig = new JobConfig();
jobConfig.addJarsInZip(this.getClass().getResource("/zip-resources/person-car-jar.zip"));
executeAndPeel(getJet().newJob(dag, 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_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_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 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));
}
Aggregations