Search in sources :

Example 21 with START_FROM_OLDEST

use of com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST in project hazelcast-jet by hazelcast.

the class HazelcastRemoteConnectorTest method when_streamRemoteMap_withPredicateAndProjection.

@Test
public void when_streamRemoteMap_withPredicateAndProjection() {
    DAG dag = new DAG();
    Vertex source = dag.newVertex(SOURCE_NAME, SourceProcessors.<Integer, Integer, Integer>streamRemoteMapP(SOURCE_NAME, clientConfig, event -> event.getKey() != 0, EventJournalMapEvent::getKey, START_FROM_OLDEST, wmGenParams(i -> i, limitingLag(0), noThrottling(), 10_000)));
    Vertex sink = dag.newVertex(SINK_NAME, writeListP(SINK_NAME));
    dag.edge(between(source, sink));
    Job job = jet.newJob(dag);
    populateMap(hz.getMap(SOURCE_NAME));
    assertSizeEventually(ITEM_COUNT - 1, jet.getList(SINK_NAME));
    assertFalse(jet.getList(SINK_NAME).contains(0));
    assertTrue(jet.getList(SINK_NAME).contains(1));
    job.cancel();
}
Also used : WatermarkPolicies.limitingLag(com.hazelcast.jet.core.WatermarkPolicies.limitingLag) EventJournalConfig(com.hazelcast.config.EventJournalConfig) Address(com.hazelcast.nio.Address) SourceProcessors.readMapP(com.hazelcast.jet.core.processor.SourceProcessors.readMapP) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) WatermarkEmissionPolicy.noThrottling(com.hazelcast.jet.core.WatermarkEmissionPolicy.noThrottling) SourceProcessors.readRemoteMapP(com.hazelcast.jet.core.processor.SourceProcessors.readRemoteMapP) DAG(com.hazelcast.jet.core.DAG) 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) AfterClass(org.junit.AfterClass) JetTestSupport(com.hazelcast.jet.core.JetTestSupport) START_FROM_OLDEST(com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST) Hazelcast(com.hazelcast.core.Hazelcast) Assert.assertFalse(org.junit.Assert.assertFalse) Entry(java.util.Map.Entry) IntStream(java.util.stream.IntStream) JetInstance(com.hazelcast.jet.JetInstance) BeforeClass(org.junit.BeforeClass) SourceProcessors.readRemoteCacheP(com.hazelcast.jet.core.processor.SourceProcessors.readRemoteCacheP) SourceProcessors(com.hazelcast.jet.core.processor.SourceProcessors) RunWith(org.junit.runner.RunWith) JetTestInstanceFactory(com.hazelcast.jet.JetTestInstanceFactory) HazelcastSerialClassRunner(com.hazelcast.test.HazelcastSerialClassRunner) ClientConfig(com.hazelcast.client.config.ClientConfig) SinkProcessors.writeRemoteMapP(com.hazelcast.jet.core.processor.SinkProcessors.writeRemoteMapP) Job(com.hazelcast.jet.Job) Before(org.junit.Before) EventJournalCacheEvent(com.hazelcast.cache.journal.EventJournalCacheEvent) Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) JetConfig(com.hazelcast.jet.config.JetConfig) SourceProcessors.streamRemoteMapP(com.hazelcast.jet.core.processor.SourceProcessors.streamRemoteMapP) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IListJet(com.hazelcast.jet.IListJet) Vertex(com.hazelcast.jet.core.Vertex) DistributedObject(com.hazelcast.core.DistributedObject) Predicates(com.hazelcast.query.Predicates) ICache(com.hazelcast.cache.ICache) SinkProcessors.writeRemoteCacheP(com.hazelcast.jet.core.processor.SinkProcessors.writeRemoteCacheP) SourceProcessors.streamRemoteCacheP(com.hazelcast.jet.core.processor.SourceProcessors.streamRemoteCacheP) 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) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Example 22 with START_FROM_OLDEST

use of com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST in project hazelcast-jet by hazelcast.

the class HazelcastRemoteConnectorTest method when_streamRemoteCache_withPredicateAndProjection.

@Test
public void when_streamRemoteCache_withPredicateAndProjection() {
    DAG dag = new DAG();
    Vertex source = dag.newVertex(SOURCE_NAME, SourceProcessors.<Integer, Integer, Integer>streamRemoteCacheP(SOURCE_NAME, clientConfig, event -> !event.getKey().equals(0), EventJournalCacheEvent::getKey, START_FROM_OLDEST, wmGenParams(i -> i, limitingLag(0), noThrottling(), 10_000)));
    Vertex sink = dag.newVertex(SINK_NAME, writeListP(SINK_NAME));
    dag.edge(between(source, sink));
    Job job = jet.newJob(dag);
    populateCache(hz.getCacheManager().getCache(SOURCE_NAME));
    assertSizeEventually(ITEM_COUNT - 1, jet.getList(SINK_NAME));
    assertFalse(jet.getList(SINK_NAME).contains(0));
    assertTrue(jet.getList(SINK_NAME).contains(1));
    job.cancel();
}
Also used : WatermarkPolicies.limitingLag(com.hazelcast.jet.core.WatermarkPolicies.limitingLag) EventJournalConfig(com.hazelcast.config.EventJournalConfig) Address(com.hazelcast.nio.Address) SourceProcessors.readMapP(com.hazelcast.jet.core.processor.SourceProcessors.readMapP) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) WatermarkEmissionPolicy.noThrottling(com.hazelcast.jet.core.WatermarkEmissionPolicy.noThrottling) SourceProcessors.readRemoteMapP(com.hazelcast.jet.core.processor.SourceProcessors.readRemoteMapP) DAG(com.hazelcast.jet.core.DAG) 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) AfterClass(org.junit.AfterClass) JetTestSupport(com.hazelcast.jet.core.JetTestSupport) START_FROM_OLDEST(com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST) Hazelcast(com.hazelcast.core.Hazelcast) Assert.assertFalse(org.junit.Assert.assertFalse) Entry(java.util.Map.Entry) IntStream(java.util.stream.IntStream) JetInstance(com.hazelcast.jet.JetInstance) BeforeClass(org.junit.BeforeClass) SourceProcessors.readRemoteCacheP(com.hazelcast.jet.core.processor.SourceProcessors.readRemoteCacheP) SourceProcessors(com.hazelcast.jet.core.processor.SourceProcessors) RunWith(org.junit.runner.RunWith) JetTestInstanceFactory(com.hazelcast.jet.JetTestInstanceFactory) HazelcastSerialClassRunner(com.hazelcast.test.HazelcastSerialClassRunner) ClientConfig(com.hazelcast.client.config.ClientConfig) SinkProcessors.writeRemoteMapP(com.hazelcast.jet.core.processor.SinkProcessors.writeRemoteMapP) Job(com.hazelcast.jet.Job) Before(org.junit.Before) EventJournalCacheEvent(com.hazelcast.cache.journal.EventJournalCacheEvent) Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) JetConfig(com.hazelcast.jet.config.JetConfig) SourceProcessors.streamRemoteMapP(com.hazelcast.jet.core.processor.SourceProcessors.streamRemoteMapP) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IListJet(com.hazelcast.jet.IListJet) Vertex(com.hazelcast.jet.core.Vertex) DistributedObject(com.hazelcast.core.DistributedObject) Predicates(com.hazelcast.query.Predicates) ICache(com.hazelcast.cache.ICache) SinkProcessors.writeRemoteCacheP(com.hazelcast.jet.core.processor.SinkProcessors.writeRemoteCacheP) SourceProcessors.streamRemoteCacheP(com.hazelcast.jet.core.processor.SourceProcessors.streamRemoteCacheP) 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) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Example 23 with START_FROM_OLDEST

use of com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST in project hazelcast-jet by hazelcast.

the class StreamEventJournalPTest method setUp.

@Before
public void setUp() {
    JetConfig config = new JetConfig();
    EventJournalConfig journalConfig = new EventJournalConfig().setMapName("*").setCapacity(JOURNAL_CAPACITY).setEnabled(true);
    config.getHazelcastConfig().setProperty(PARTITION_COUNT.getName(), String.valueOf(NUM_PARTITIONS));
    config.getHazelcastConfig().addEventJournalConfig(journalConfig);
    instance = this.createJetMember(config);
    map = (MapProxyImpl<String, Integer>) instance.getHazelcastInstance().<String, Integer>getMap("test");
    List<Integer> allPartitions = IntStream.range(0, NUM_PARTITIONS).boxed().collect(toList());
    supplier = () -> new StreamEventJournalP<>(map, allPartitions, e -> true, EventJournalMapEvent::getNewValue, START_FROM_OLDEST, false, wmGenParams(Integer::intValue, limitingLag(0), suppressAll(), -1));
    key0 = generateKeyForPartition(instance.getHazelcastInstance(), 0);
    key1 = generateKeyForPartition(instance.getHazelcastInstance(), 1);
}
Also used : IntStream(java.util.stream.IntStream) PARTITION_COUNT(com.hazelcast.spi.properties.GroupProperty.PARTITION_COUNT) Arrays(java.util.Arrays) WatermarkPolicies.limitingLag(com.hazelcast.jet.core.WatermarkPolicies.limitingLag) JetInstance(com.hazelcast.jet.JetInstance) RunWith(org.junit.runner.RunWith) EventJournalConfig(com.hazelcast.config.EventJournalConfig) Processor(com.hazelcast.jet.core.Processor) TestOutbox(com.hazelcast.jet.core.test.TestOutbox) TestProcessorContext(com.hazelcast.jet.core.test.TestProcessorContext) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) WatermarkGenerationParams.wmGenParams(com.hazelcast.jet.core.WatermarkGenerationParams.wmGenParams) EventJournalMapEvent(com.hazelcast.map.journal.EventJournalMapEvent) Before(org.junit.Before) TestInbox(com.hazelcast.jet.core.test.TestInbox) DistributedSupplier(com.hazelcast.jet.function.DistributedSupplier) JetConfig(com.hazelcast.jet.config.JetConfig) JetTestSupport(com.hazelcast.jet.core.JetTestSupport) WatermarkEmissionPolicy(com.hazelcast.jet.core.WatermarkEmissionPolicy) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) START_FROM_OLDEST(com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST) Collectors(java.util.stream.Collectors) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) SAME_ITEMS_ANY_ORDER(com.hazelcast.jet.core.test.TestSupport.SAME_ITEMS_ANY_ORDER) TestSupport(com.hazelcast.jet.core.test.TestSupport) Assert.assertFalse(org.junit.Assert.assertFalse) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) Entry(java.util.Map.Entry) Assert.assertEquals(org.junit.Assert.assertEquals) JetConfig(com.hazelcast.jet.config.JetConfig) EventJournalConfig(com.hazelcast.config.EventJournalConfig) Before(org.junit.Before)

Aggregations

START_FROM_OLDEST (com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST)23 Assert.assertEquals (org.junit.Assert.assertEquals)23 Test (org.junit.Test)23 Before (org.junit.Before)21 Entry (java.util.Map.Entry)18 Category (org.junit.experimental.categories.Category)18 RunWith (org.junit.runner.RunWith)17 Config (com.hazelcast.config.Config)16 Job (com.hazelcast.jet.Job)16 IntStream (java.util.stream.IntStream)15 DAG (com.hazelcast.jet.core.DAG)14 JetTestSupport (com.hazelcast.jet.core.JetTestSupport)14 Vertex (com.hazelcast.jet.core.Vertex)14 Edge.between (com.hazelcast.jet.core.Edge.between)13 BeforeClass (org.junit.BeforeClass)13 Assert.assertTrue (org.junit.Assert.assertTrue)12 ICache (com.hazelcast.cache.ICache)10 Util.entry (com.hazelcast.jet.Util.entry)10 EventJournalMapEvent (com.hazelcast.map.EventJournalMapEvent)10 IList (com.hazelcast.collection.IList)9