Search in sources :

Example 1 with EventJournalCacheEvent

use of com.hazelcast.cache.EventJournalCacheEvent in project hazelcast 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, eventTimePolicy(i -> i, limitingLag(0), 1, 0, 10_000)));
    Vertex sink = dag.newVertex(SINK_NAME, writeListP(SINK_NAME));
    dag.edge(between(source, sink));
    Job job = localHz.getJet().newJob(dag);
    populateCache(remoteHz.getCacheManager().getCache(SOURCE_NAME));
    assertSizeEventually(ITEM_COUNT - 1, localHz.getList(SINK_NAME));
    assertFalse(localHz.getList(SINK_NAME).contains(0));
    assertTrue(localHz.getList(SINK_NAME).contains(1));
    job.cancel();
}
Also used : Address(com.hazelcast.cluster.Address) QuickTest(com.hazelcast.test.annotation.QuickTest) SourceProcessors.readMapP(com.hazelcast.jet.core.processor.SourceProcessors.readMapP) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) MapConfig(com.hazelcast.config.MapConfig) EventJournalCacheEvent(com.hazelcast.cache.EventJournalCacheEvent) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) SourceProcessors.readRemoteMapP(com.hazelcast.jet.core.processor.SourceProcessors.readRemoteMapP) DAG(com.hazelcast.jet.core.DAG) Projections(com.hazelcast.projection.Projections) SourceProcessors.readCacheP(com.hazelcast.jet.core.processor.SourceProcessors.readCacheP) AfterClass(org.junit.AfterClass) JetTestSupport(com.hazelcast.jet.core.JetTestSupport) START_FROM_OLDEST(com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST) Category(org.junit.experimental.categories.Category) Hazelcast(com.hazelcast.core.Hazelcast) EventJournalMapEvent(com.hazelcast.map.EventJournalMapEvent) Assert.assertFalse(org.junit.Assert.assertFalse) Entry(java.util.Map.Entry) IntStream(java.util.stream.IntStream) BeforeClass(org.junit.BeforeClass) SourceProcessors.readRemoteCacheP(com.hazelcast.jet.core.processor.SourceProcessors.readRemoteCacheP) HazelcastClient(com.hazelcast.client.HazelcastClient) HazelcastInstanceFactory(com.hazelcast.instance.impl.HazelcastInstanceFactory) SourceProcessors(com.hazelcast.jet.core.processor.SourceProcessors) RunWith(org.junit.runner.RunWith) HazelcastSerialClassRunner(com.hazelcast.test.HazelcastSerialClassRunner) ClientConfig(com.hazelcast.client.config.ClientConfig) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) SinkProcessors.writeRemoteMapP(com.hazelcast.jet.core.processor.SinkProcessors.writeRemoteMapP) Job(com.hazelcast.jet.Job) Before(org.junit.Before) IList(com.hazelcast.collection.IList) Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SourceProcessors.streamRemoteMapP(com.hazelcast.jet.core.processor.SourceProcessors.streamRemoteMapP) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) WatermarkPolicy.limitingLag(com.hazelcast.jet.core.WatermarkPolicy.limitingLag) Vertex(com.hazelcast.jet.core.Vertex) DistributedObject(com.hazelcast.core.DistributedObject) Predicates(com.hazelcast.query.Predicates) ICache(com.hazelcast.cache.ICache) EventTimePolicy.eventTimePolicy(com.hazelcast.jet.core.EventTimePolicy.eventTimePolicy) 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) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with EventJournalCacheEvent

use of com.hazelcast.cache.EventJournalCacheEvent in project hazelcast 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, eventTimePolicy(i -> i, limitingLag(0), 1, 0, 10_000)));
    Vertex sink = dag.newVertex("sink", writeListP(streamSinkName));
    dag.edge(between(source, sink));
    Job job = instance().getJet().newJob(dag);
    ICache<Integer, Integer> sourceCache = instance().getCacheManager().getCache(streamSourceName);
    range(0, ENTRY_COUNT).forEach(i -> sourceCache.put(i, i));
    assertSizeEventually(ENTRY_COUNT - 1, instance().getList(streamSinkName));
    assertFalse(instance().getList(streamSinkName).contains(0));
    assertTrue(instance().getList(streamSinkName).contains(1));
    job.cancel();
}
Also used : ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) IntStream.range(java.util.stream.IntStream.range) QuickTest(com.hazelcast.test.annotation.QuickTest) SourceProcessors.readMapP(com.hazelcast.jet.core.processor.SourceProcessors.readMapP) SourceProcessors.readListP(com.hazelcast.jet.core.processor.SourceProcessors.readListP) SourceProcessors.streamCacheP(com.hazelcast.jet.core.processor.SourceProcessors.streamCacheP) EventJournalCacheEvent(com.hazelcast.cache.EventJournalCacheEvent) TruePredicate(com.hazelcast.query.impl.predicates.TruePredicate) Map(java.util.Map) SinkProcessors.writeCacheP(com.hazelcast.jet.core.processor.SinkProcessors.writeCacheP) DAG(com.hazelcast.jet.core.DAG) ICacheManager(com.hazelcast.core.ICacheManager) Projections(com.hazelcast.projection.Projections) SourceProcessors.readCacheP(com.hazelcast.jet.core.processor.SourceProcessors.readCacheP) SimpleTestInClusterSupport(com.hazelcast.jet.SimpleTestInClusterSupport) EventTimePolicy.noEventTime(com.hazelcast.jet.core.EventTimePolicy.noEventTime) START_FROM_OLDEST(com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST) Category(org.junit.experimental.categories.Category) Collectors.joining(java.util.stream.Collectors.joining) List(java.util.List) NearCacheConfig(com.hazelcast.config.NearCacheConfig) EventJournalMapEvent(com.hazelcast.map.EventJournalMapEvent) Assert.assertFalse(org.junit.Assert.assertFalse) SinkProcessors(com.hazelcast.jet.core.processor.SinkProcessors) Entry(java.util.Map.Entry) SinkProcessors.writeMapP(com.hazelcast.jet.core.processor.SinkProcessors.writeMapP) IntStream(java.util.stream.IntStream) NearCachedMapProxyImpl(com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl) BeforeClass(org.junit.BeforeClass) SourceProcessors(com.hazelcast.jet.core.processor.SourceProcessors) TestProcessors(com.hazelcast.jet.core.TestProcessors) Util.entry(com.hazelcast.jet.Util.entry) Job(com.hazelcast.jet.Job) Before(org.junit.Before) IList(com.hazelcast.collection.IList) Config(com.hazelcast.config.Config) SourceProcessors.streamMapP(com.hazelcast.jet.core.processor.SourceProcessors.streamMapP) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) WatermarkPolicy.limitingLag(com.hazelcast.jet.core.WatermarkPolicy.limitingLag) Vertex(com.hazelcast.jet.core.Vertex) Collectors.toList(java.util.stream.Collectors.toList) Predicates(com.hazelcast.query.Predicates) ICache(com.hazelcast.cache.ICache) EventTimePolicy.eventTimePolicy(com.hazelcast.jet.core.EventTimePolicy.eventTimePolicy) Util.mapPutEvents(com.hazelcast.jet.Util.mapPutEvents) Assert.assertEquals(org.junit.Assert.assertEquals) IMap(com.hazelcast.map.IMap) 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

EventJournalCacheEvent (com.hazelcast.cache.EventJournalCacheEvent)2 ICache (com.hazelcast.cache.ICache)2 IList (com.hazelcast.collection.IList)2 Config (com.hazelcast.config.Config)2 Job (com.hazelcast.jet.Job)2 DAG (com.hazelcast.jet.core.DAG)2 Edge.between (com.hazelcast.jet.core.Edge.between)2 EventTimePolicy.eventTimePolicy (com.hazelcast.jet.core.EventTimePolicy.eventTimePolicy)2 Vertex (com.hazelcast.jet.core.Vertex)2 WatermarkPolicy.limitingLag (com.hazelcast.jet.core.WatermarkPolicy.limitingLag)2 SinkProcessors.writeListP (com.hazelcast.jet.core.processor.SinkProcessors.writeListP)2 SourceProcessors (com.hazelcast.jet.core.processor.SourceProcessors)2 SourceProcessors.readCacheP (com.hazelcast.jet.core.processor.SourceProcessors.readCacheP)2 SourceProcessors.readMapP (com.hazelcast.jet.core.processor.SourceProcessors.readMapP)2 START_FROM_OLDEST (com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST)2 EventJournalMapEvent (com.hazelcast.map.EventJournalMapEvent)2 Projections (com.hazelcast.projection.Projections)2 Predicates (com.hazelcast.query.Predicates)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Map (java.util.Map)2