Search in sources :

Example 11 with ReadResultSet

use of com.hazelcast.ringbuffer.ReadResultSet in project hazelcast by hazelcast.

the class AbstractEventJournalBasicTest method unparkReadOperation.

/**
 * Tests that event journal read operations parked on different partitions
 * can be woken up independently.
 */
@Test
public void unparkReadOperation() {
    final EventJournalTestContext<String, Integer, EJ_TYPE> context = createContext();
    assertEventJournalSize(context.dataAdapter, 0);
    final String key = randomPartitionKey();
    final Integer value = RANDOM.nextInt();
    final CountDownLatch latch = new CountDownLatch(1);
    final BiConsumer<ReadResultSet<EJ_TYPE>, Throwable> ec = addEventExecutionCallback(context, key, value, latch);
    readFromEventJournal(context.dataAdapter, 0, 100, partitionId, TRUE_PREDICATE, IDENTITY_FUNCTION).whenCompleteAsync(ec);
    readFromEventJournal(context.dataAdapter, 0, 100, partitionId + 1, TRUE_PREDICATE, IDENTITY_FUNCTION).whenCompleteAsync(ec);
    readFromEventJournal(context.dataAdapter, 0, 100, partitionId + 2, TRUE_PREDICATE, IDENTITY_FUNCTION).whenCompleteAsync(ec);
    readFromEventJournal(context.dataAdapter, 0, 100, partitionId + 3, TRUE_PREDICATE, IDENTITY_FUNCTION).whenCompleteAsync(ec);
    readFromEventJournal(context.dataAdapter, 0, 100, partitionId + 4, TRUE_PREDICATE, IDENTITY_FUNCTION).whenCompleteAsync(ec);
    context.dataAdapter.put(key, value);
    assertOpenEventually(latch, 30);
    assertEventJournalSize(context.dataAdapter, 1);
}
Also used : ReadResultSet(com.hazelcast.ringbuffer.ReadResultSet) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

ReadResultSet (com.hazelcast.ringbuffer.ReadResultSet)11 Test (org.junit.Test)11 QuickTest (com.hazelcast.test.annotation.QuickTest)6 AssertTask (com.hazelcast.test.AssertTask)3 StartsWithStringFilter (com.hazelcast.client.test.ringbuffer.filter.StartsWithStringFilter)2 StaleSequenceException (com.hazelcast.ringbuffer.StaleSequenceException)2 DistributedObjectDestroyedException (com.hazelcast.spi.exception.DistributedObjectDestroyedException)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutionException (java.util.concurrent.ExecutionException)2 Config (com.hazelcast.config.Config)1 EventJournalConfig (com.hazelcast.config.EventJournalConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 Node (com.hazelcast.instance.impl.Node)1 EventJournalInitialSubscriberState (com.hazelcast.internal.journal.EventJournalInitialSubscriberState)1 ObjectNamespace (com.hazelcast.internal.services.ObjectNamespace)1 ExceptionUtil.rethrow (com.hazelcast.internal.util.ExceptionUtil.rethrow)1 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)1 SetUtil (com.hazelcast.internal.util.SetUtil)1 EventType (com.hazelcast.journal.EventJournalEventAdapter.EventType)1 ADDED (com.hazelcast.journal.EventJournalEventAdapter.EventType.ADDED)1