Search in sources :

Example 26 with DAG

use of com.hazelcast.jet.core.DAG in project hazelcast-jet by hazelcast.

the class AbstractDeploymentTest method testDeployment_whenJarAddedAsResource_thenClassesAvailableOnClassLoader.

@Test
public void testDeployment_whenJarAddedAsResource_thenClassesAvailableOnClassLoader() throws Throwable {
    createCluster();
    DAG dag = new DAG();
    dag.newVertex("load class", new LoadPersonIsolatedMetaSupplier());
    JetInstance jetInstance = getJetInstance();
    JobConfig jobConfig = new JobConfig();
    jobConfig.addJar(this.getClass().getResource("/deployment/sample-pojo-1.0-person.jar"));
    executeAndPeel(jetInstance.newJob(dag, jobConfig));
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) LoadPersonIsolatedMetaSupplier(com.hazelcast.jet.impl.deployment.LoadPersonIsolated.LoadPersonIsolatedMetaSupplier) DAG(com.hazelcast.jet.core.DAG) JobConfig(com.hazelcast.jet.config.JobConfig) Test(org.junit.Test)

Example 27 with DAG

use of com.hazelcast.jet.core.DAG in project hazelcast-jet by hazelcast.

the class AbstractDeploymentTest method testDeployment_whenClassAddedAsResource_thenClassAvailableOnClassLoader.

@Test
public void testDeployment_whenClassAddedAsResource_thenClassAvailableOnClassLoader() throws Throwable {
    createCluster();
    DAG dag = new DAG();
    dag.newVertex("create and print person", new LoadPersonIsolatedMetaSupplier());
    JobConfig jobConfig = new JobConfig();
    URL classUrl = this.getClass().getResource("/cp1/");
    URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { classUrl }, null);
    Class<?> appearance = urlClassLoader.loadClass("com.sample.pojo.person.Person$Appereance");
    jobConfig.addClass(appearance);
    executeAndPeel(getJetInstance().newJob(dag, jobConfig));
}
Also used : URLClassLoader(java.net.URLClassLoader) LoadPersonIsolatedMetaSupplier(com.hazelcast.jet.impl.deployment.LoadPersonIsolated.LoadPersonIsolatedMetaSupplier) DAG(com.hazelcast.jet.core.DAG) JobConfig(com.hazelcast.jet.config.JobConfig) URL(java.net.URL) Test(org.junit.Test)

Example 28 with DAG

use of com.hazelcast.jet.core.DAG in project hazelcast-jet by hazelcast.

the class WatermarkMaxRetention_IntegrationTest method test_onEdgeCoalescing.

@Test
public void test_onEdgeCoalescing() {
    DAG dag = new DAG();
    // a vertex with two processor instances, one will emit a wm and the other won't
    Vertex source = dag.newVertex("source", (int count) -> asList(new ListSource(singletonList(new Watermark(1))), new StuckForeverSourceP())).localParallelism(2);
    Vertex map = dag.newVertex("map", MapWmToStringP::new).localParallelism(1);
    Vertex sink = dag.newVertex("sink", writeListP(SINK_NAME));
    dag.edge(between(source, map)).edge(between(map, sink));
    doTest(dag);
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) StuckForeverSourceP(com.hazelcast.jet.core.TestProcessors.StuckForeverSourceP) ListSource(com.hazelcast.jet.core.TestProcessors.ListSource) DAG(com.hazelcast.jet.core.DAG) Watermark(com.hazelcast.jet.core.Watermark) Test(org.junit.Test)

Example 29 with DAG

use of com.hazelcast.jet.core.DAG in project hazelcast-jet by hazelcast.

the class WatermarkMaxRetention_IntegrationTest method test_onVertexCoalescing.

@Test
public void test_onVertexCoalescing() {
    DAG dag = new DAG();
    Vertex source0 = dag.newVertex("source0", () -> new ListSource(singletonList(new Watermark(1)))).localParallelism(1);
    Vertex source1 = dag.newVertex("source1", StuckForeverSourceP::new);
    // a vertex with two inputs, one will emit a wm and the other won't
    Vertex map = dag.newVertex("map", MapWmToStringP::new).localParallelism(1);
    Vertex sink = dag.newVertex("sink", writeListP(SINK_NAME));
    dag.edge(from(source0).to(map, 0)).edge(from(source1).to(map, 1)).edge(between(map, sink));
    doTest(dag);
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) StuckForeverSourceP(com.hazelcast.jet.core.TestProcessors.StuckForeverSourceP) ListSource(com.hazelcast.jet.core.TestProcessors.ListSource) DAG(com.hazelcast.jet.core.DAG) Watermark(com.hazelcast.jet.core.Watermark) Test(org.junit.Test)

Example 30 with DAG

use of com.hazelcast.jet.core.DAG in project hazelcast-jet by hazelcast.

the class HazelcastConnectorTest method when_readMap_withPredicateAndDistributedFunction.

@Test
public void when_readMap_withPredicateAndDistributedFunction() {
    IMapJet<Integer, Integer> sourceMap = jetInstance.getMap(sourceName);
    range(0, ENTRY_COUNT).forEach(i -> sourceMap.put(i, i));
    DAG dag = new DAG();
    Vertex source = dag.newVertex("source", readMapP(sourceName, e -> !e.getKey().equals(0), Map.Entry::getKey));
    Vertex sink = dag.newVertex("sink", writeListP(sinkName));
    dag.edge(between(source, sink));
    jetInstance.newJob(dag).join();
    IListJet<Object> list = jetInstance.getList(sinkName);
    assertEquals(ENTRY_COUNT - 1, list.size());
    assertFalse(list.contains(0));
    assertTrue(list.contains(1));
}
Also used : WatermarkPolicies.limitingLag(com.hazelcast.jet.core.WatermarkPolicies.limitingLag) IntStream.range(java.util.stream.IntStream.range) EventJournalConfig(com.hazelcast.config.EventJournalConfig) IMapJet(com.hazelcast.jet.IMapJet) SourceProcessors.readMapP(com.hazelcast.jet.core.processor.SourceProcessors.readMapP) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) SourceProcessors.readListP(com.hazelcast.jet.core.processor.SourceProcessors.readListP) SourceProcessors.streamCacheP(com.hazelcast.jet.core.processor.SourceProcessors.streamCacheP) ICacheJet(com.hazelcast.jet.ICacheJet) Map(java.util.Map) WatermarkEmissionPolicy.noThrottling(com.hazelcast.jet.core.WatermarkEmissionPolicy.noThrottling) SinkProcessors.writeCacheP(com.hazelcast.jet.core.processor.SinkProcessors.writeCacheP) DAG(com.hazelcast.jet.core.DAG) WatermarkGenerationParams.noWatermarks(com.hazelcast.jet.core.WatermarkGenerationParams.noWatermarks) Projections(com.hazelcast.projection.Projections) WatermarkGenerationParams.wmGenParams(com.hazelcast.jet.core.WatermarkGenerationParams.wmGenParams) SourceProcessors.readCacheP(com.hazelcast.jet.core.processor.SourceProcessors.readCacheP) EventJournalMapEvent(com.hazelcast.map.journal.EventJournalMapEvent) JetTestSupport(com.hazelcast.jet.core.JetTestSupport) START_FROM_OLDEST(com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST) Collectors.joining(java.util.stream.Collectors.joining) PredicateTestUtils.entry(com.hazelcast.query.impl.predicates.PredicateTestUtils.entry) JetCacheManager(com.hazelcast.jet.JetCacheManager) Assert.assertFalse(org.junit.Assert.assertFalse) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) Entry(java.util.Map.Entry) SinkProcessors.writeMapP(com.hazelcast.jet.core.processor.SinkProcessors.writeMapP) IntStream(java.util.stream.IntStream) JetInstance(com.hazelcast.jet.JetInstance) SourceProcessors(com.hazelcast.jet.core.processor.SourceProcessors) RunWith(org.junit.runner.RunWith) Job(com.hazelcast.jet.Job) Before(org.junit.Before) EventJournalCacheEvent(com.hazelcast.cache.journal.EventJournalCacheEvent) Config(com.hazelcast.config.Config) JetConfig(com.hazelcast.jet.config.JetConfig) SourceProcessors.streamMapP(com.hazelcast.jet.core.processor.SourceProcessors.streamMapP) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IListJet(com.hazelcast.jet.IListJet) Vertex(com.hazelcast.jet.core.Vertex) TruePredicate(com.hazelcast.query.TruePredicate) Collectors.toList(java.util.stream.Collectors.toList) Predicates(com.hazelcast.query.Predicates) ICache(com.hazelcast.cache.ICache) Util.mapPutEvents(com.hazelcast.jet.Util.mapPutEvents) Assert.assertEquals(org.junit.Assert.assertEquals) Edge.between(com.hazelcast.jet.core.Edge.between) SinkProcessors.writeListP(com.hazelcast.jet.core.processor.SinkProcessors.writeListP) Vertex(com.hazelcast.jet.core.Vertex) DAG(com.hazelcast.jet.core.DAG) Map(java.util.Map) Test(org.junit.Test)

Aggregations

DAG (com.hazelcast.jet.core.DAG)211 Test (org.junit.Test)159 Vertex (com.hazelcast.jet.core.Vertex)127 QuickTest (com.hazelcast.test.annotation.QuickTest)100 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)91 Job (com.hazelcast.jet.Job)64 Entry (java.util.Map.Entry)51 List (java.util.List)38 Assert.assertEquals (org.junit.Assert.assertEquals)37 Map (java.util.Map)36 JobConfig (com.hazelcast.jet.config.JobConfig)35 Assert.assertTrue (org.junit.Assert.assertTrue)31 Edge (com.hazelcast.jet.core.Edge)29 IntStream (java.util.stream.IntStream)29 Category (org.junit.experimental.categories.Category)28 Collectors.toList (java.util.stream.Collectors.toList)26 HazelcastInstance (com.hazelcast.core.HazelcastInstance)23 FunctionEx (com.hazelcast.function.FunctionEx)23 ArrayList (java.util.ArrayList)22 Nonnull (javax.annotation.Nonnull)21