Search in sources :

Example 1 with ICacheJet

use of com.hazelcast.jet.ICacheJet in project hazelcast-jet by hazelcast.

the class HazelcastConnectorTest method when_streamCache_withFilterAndProjection.

@Test
public void when_streamCache_withFilterAndProjection() {
    DAG dag = new DAG();
    Vertex source = dag.newVertex("source", SourceProcessors.<Integer, Integer, Integer>streamCacheP(streamSourceName, event -> !event.getKey().equals(0), EventJournalCacheEvent::getKey, START_FROM_OLDEST, wmGenParams(i -> i, limitingLag(0), noThrottling(), 10_000)));
    Vertex sink = dag.newVertex("sink", writeListP(streamSinkName));
    dag.edge(between(source, sink));
    Job job = jetInstance.newJob(dag);
    ICacheJet<Integer, Integer> sourceCache = jetInstance.getCacheManager().getCache(streamSourceName);
    range(0, ENTRY_COUNT).forEach(i -> sourceCache.put(i, i));
    assertSizeEventually(ENTRY_COUNT - 1, jetInstance.getList(streamSinkName));
    assertFalse(jetInstance.getList(streamSinkName).contains(0));
    assertTrue(jetInstance.getList(streamSinkName).contains(1));
    job.cancel();
}
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) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Aggregations

ICache (com.hazelcast.cache.ICache)1 EventJournalCacheEvent (com.hazelcast.cache.journal.EventJournalCacheEvent)1 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)1 Config (com.hazelcast.config.Config)1 EventJournalConfig (com.hazelcast.config.EventJournalConfig)1 ICacheJet (com.hazelcast.jet.ICacheJet)1 IListJet (com.hazelcast.jet.IListJet)1 IMapJet (com.hazelcast.jet.IMapJet)1 JetCacheManager (com.hazelcast.jet.JetCacheManager)1 JetInstance (com.hazelcast.jet.JetInstance)1 Job (com.hazelcast.jet.Job)1 Util.mapPutEvents (com.hazelcast.jet.Util.mapPutEvents)1 JetConfig (com.hazelcast.jet.config.JetConfig)1 DAG (com.hazelcast.jet.core.DAG)1 Edge.between (com.hazelcast.jet.core.Edge.between)1 JetTestSupport (com.hazelcast.jet.core.JetTestSupport)1 Vertex (com.hazelcast.jet.core.Vertex)1 WatermarkEmissionPolicy.noThrottling (com.hazelcast.jet.core.WatermarkEmissionPolicy.noThrottling)1 WatermarkGenerationParams.noWatermarks (com.hazelcast.jet.core.WatermarkGenerationParams.noWatermarks)1 WatermarkGenerationParams.wmGenParams (com.hazelcast.jet.core.WatermarkGenerationParams.wmGenParams)1