Search in sources :

Example 26 with JobConfig

use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.

the class KinesisIntegrationTest method restart_staticStream.

private void restart_staticStream(boolean graceful) {
    HELPER.createStream(3);
    JobConfig jobConfig = new JobConfig().setProcessingGuarantee(ProcessingGuarantee.AT_LEAST_ONCE).setSnapshotIntervalMillis(SECONDS.toMillis(1));
    Job job = hz().getJet().newJob(getPipeline(kinesisSource().build()), jobConfig);
    Map<String, List<String>> expectedMessages = sendMessages();
    // wait for some data to start coming out of the pipeline
    assertTrueEventually(() -> assertFalse(results.isEmpty()));
    ((JobProxy) job).restart(graceful);
    assertMessages(expectedMessages, true, !graceful);
}
Also used : JobProxy(com.hazelcast.jet.impl.JobProxy) List(java.util.List) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig)

Example 27 with JobConfig

use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.

the class KinesisIntegrationTest method restart_dynamicStream.

private void restart_dynamicStream(boolean graceful) {
    HELPER.createStream(3);
    JobConfig jobConfig = new JobConfig().setProcessingGuarantee(ProcessingGuarantee.AT_LEAST_ONCE).setSnapshotIntervalMillis(SECONDS.toMillis(1));
    Job job = hz().getJet().newJob(getPipeline(kinesisSource().build()), jobConfig);
    Map<String, List<String>> expectedMessages = sendMessages();
    // wait for some data to start coming out of the pipeline
    assertTrueEventually(() -> assertFalse(results.isEmpty()));
    List<Shard> openShards = listOpenShards();
    Shard shard1 = openShards.get(0);
    Shard shard2 = openShards.get(1);
    Shard shard3 = openShards.get(2);
    splitShard(shard1);
    HELPER.waitForStreamToActivate();
    assertOpenShards(4, shard1);
    mergeShards(shard2, shard3);
    HELPER.waitForStreamToActivate();
    assertOpenShards(3, shard2, shard3);
    ((JobProxy) job).restart(graceful);
    assertMessages(expectedMessages, false, !graceful);
}
Also used : JobProxy(com.hazelcast.jet.impl.JobProxy) List(java.util.List) Job(com.hazelcast.jet.Job) Shard(com.amazonaws.services.kinesis.model.Shard) JobConfig(com.hazelcast.jet.config.JobConfig)

Example 28 with JobConfig

use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.

the class JobSerializerTest method when_serializerIsNotRegistered_then_throwsException.

@Test
public void when_serializerIsNotRegistered_then_throwsException() {
    String listName = "list-1";
    List<Person> list = client().getList(listName);
    list.add(Person.newBuilder().setName("Joe").setAge(33).build());
    Pipeline pipeline = Pipeline.create();
    pipeline.readFrom(Sources.<Person>list(listName)).map(Person::getName).writeTo(Sinks.logger());
    assertThatThrownBy(() -> client().getJet().newJob(pipeline, new JobConfig()).join()).hasCauseInstanceOf(JetException.class);
}
Also used : Person(com.hazelcast.jet.protobuf.Messages.Person) JobConfig(com.hazelcast.jet.config.JobConfig) Pipeline(com.hazelcast.jet.pipeline.Pipeline) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 29 with JobConfig

use of com.hazelcast.jet.config.JobConfig in project hazelcast by hazelcast.

the class JobSerializerTest method when_serializerIsRegisteredForDistributedJob_then_itIsAvailableForAllStages.

@Test
public void when_serializerIsRegisteredForDistributedJob_then_itIsAvailableForAllStages() {
    List<String> input = IntStream.range(0, 10_000).boxed().map(t -> Integer.toString(t)).collect(toList());
    Pipeline pipeline = Pipeline.create();
    pipeline.readFrom(TestSources.items(input)).map(name -> Person.newBuilder().setName(name).build()).groupingKey(identity()).filterUsingService(sharedService(ctx -> null), (s, k, v) -> true).map(person -> person.getName()).writeTo(AssertionSinks.assertAnyOrder(input));
    client().getJet().newJob(pipeline, new JobConfig().registerSerializer(Person.class, PersonSerializer.class)).join();
}
Also used : AssertionSinks(com.hazelcast.jet.pipeline.test.AssertionSinks) IntStream(java.util.stream.IntStream) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) BeforeClass(org.junit.BeforeClass) ServiceFactories.sharedService(com.hazelcast.jet.pipeline.ServiceFactories.sharedService) QuickTest(com.hazelcast.test.annotation.QuickTest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Collections.singletonList(java.util.Collections.singletonList) JetException(com.hazelcast.jet.JetException) ClientListProxy(com.hazelcast.client.impl.proxy.ClientListProxy) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ClientConfig(com.hazelcast.client.config.ClientConfig) SerializerConfig(com.hazelcast.config.SerializerConfig) Animal(com.hazelcast.jet.protobuf.Messages.Animal) SimpleTestInClusterSupport(com.hazelcast.jet.SimpleTestInClusterSupport) Config(com.hazelcast.config.Config) Pipeline(com.hazelcast.jet.pipeline.Pipeline) JobConfig(com.hazelcast.jet.config.JobConfig) Sinks(com.hazelcast.jet.pipeline.Sinks) Test(org.junit.Test) Person(com.hazelcast.jet.protobuf.Messages.Person) Category(org.junit.experimental.categories.Category) Sources(com.hazelcast.jet.pipeline.Sources) TestSources(com.hazelcast.jet.pipeline.test.TestSources) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) FunctionEx.identity(com.hazelcast.function.FunctionEx.identity) JobConfig(com.hazelcast.jet.config.JobConfig) Pipeline(com.hazelcast.jet.pipeline.Pipeline) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 30 with JobConfig

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));
}
Also used : ArrayList(java.util.ArrayList) DAG(com.hazelcast.jet.core.DAG) JobConfig(com.hazelcast.jet.config.JobConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

JobConfig (com.hazelcast.jet.config.JobConfig)248 Test (org.junit.Test)194 Job (com.hazelcast.jet.Job)160 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)111 QuickTest (com.hazelcast.test.annotation.QuickTest)109 Pipeline (com.hazelcast.jet.pipeline.Pipeline)68 HazelcastInstance (com.hazelcast.core.HazelcastInstance)64 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)46 Assert.assertEquals (org.junit.Assert.assertEquals)43 Category (org.junit.experimental.categories.Category)43 DAG (com.hazelcast.jet.core.DAG)41 JobRepository (com.hazelcast.jet.impl.JobRepository)40 List (java.util.List)36 NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)35 Config (com.hazelcast.config.Config)33 Assert.assertTrue (org.junit.Assert.assertTrue)32 ArrayList (java.util.ArrayList)30 RUNNING (com.hazelcast.jet.core.JobStatus.RUNNING)27 Sinks (com.hazelcast.jet.pipeline.Sinks)27 RunWith (org.junit.runner.RunWith)27