use of com.hazelcast.internal.journal.EventJournalInitialSubscriberState in project hazelcast by hazelcast.
the class MapEventJournalSubscribeOperation method runInternal.
@Override
protected void runInternal() {
final MapEventJournal eventJournal = mapServiceContext.getEventJournal();
final long newestSequence = eventJournal.newestSequence(namespace, getPartitionId());
final long oldestSequence = eventJournal.oldestSequence(namespace, getPartitionId());
response = new EventJournalInitialSubscriberState(oldestSequence, newestSequence);
}
use of com.hazelcast.internal.journal.EventJournalInitialSubscriberState in project hazelcast by hazelcast.
the class CacheEventJournalSubscribeOperation method run.
@Override
public void run() {
final CacheService service = getService();
final CacheEventJournal eventJournal = service.getEventJournal();
final long newestSequence = eventJournal.newestSequence(namespace, getPartitionId());
final long oldestSequence = eventJournal.oldestSequence(namespace, getPartitionId());
response = new EventJournalInitialSubscriberState(oldestSequence, newestSequence);
}
use of com.hazelcast.internal.journal.EventJournalInitialSubscriberState in project hazelcast by hazelcast.
the class ClientMapProxy method subscribeToEventJournal.
@Override
public InternalCompletableFuture<EventJournalInitialSubscriberState> subscribeToEventJournal(int partitionId) {
final ClientMessage request = MapEventJournalSubscribeCodec.encodeRequest(name);
final ClientInvocationFuture fut = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
return new ClientDelegatingFuture<>(fut, getSerializationService(), message -> {
ResponseParameters resp = MapEventJournalSubscribeCodec.decodeResponse(message);
return new EventJournalInitialSubscriberState(resp.oldestSequence, resp.newestSequence);
});
}
use of com.hazelcast.internal.journal.EventJournalInitialSubscriberState in project hazelcast by hazelcast.
the class AbstractEventJournalBounceTest method getEventJournalEvents.
private <T> LinkedList<T> getEventJournalEvents(EventJournalReader<T> reader) {
final LinkedList<T> events = new LinkedList<T>();
for (int i = 1; i < TEST_PARTITION_COUNT; i++) {
try {
final EventJournalInitialSubscriberState state = reader.subscribeToEventJournal(i).toCompletableFuture().get();
final ReadResultSet<T> partitionEvents = reader.readFromEventJournal(state.getOldestSequence(), 1, (int) (state.getNewestSequence() - state.getOldestSequence() + 1), i, new TruePredicate<T>(), new IdentityFunction<T>()).toCompletableFuture().get();
for (T event : partitionEvents) {
events.add(event);
}
} catch (Exception e) {
throw rethrow(e);
}
}
return events;
}
use of com.hazelcast.internal.journal.EventJournalInitialSubscriberState in project hazelcast by hazelcast.
the class AbstractEventJournalBasicTest method skipEventsWhenFallenBehind.
@Test
public void skipEventsWhenFallenBehind() throws Exception {
final EventJournalTestContext<String, Integer, EJ_TYPE> context = createContext();
final int count = 1000;
assertEventJournalSize(context.dataAdapter, 0);
for (int i = 0; i < count; i++) {
context.dataAdapter.put(randomPartitionKey(), i);
}
final EventJournalInitialSubscriberState state = subscribeToEventJournal(context.dataAdapter, partitionId);
assertEquals(500, state.getOldestSequence());
assertEquals(999, state.getNewestSequence());
assertEventJournalSize(context.dataAdapter, 500);
final int startSequence = 0;
final ReadResultSet<EJ_TYPE> resultSet = readFromEventJournal(context.dataAdapter, startSequence, 1, partitionId, TRUE_PREDICATE, IDENTITY_FUNCTION).toCompletableFuture().get();
assertEquals(1, resultSet.size());
assertEquals(1, resultSet.readCount());
assertNotEquals(startSequence + resultSet.readCount(), resultSet.getNextSequenceToReadFrom());
assertEquals(501, resultSet.getNextSequenceToReadFrom());
final long lostCount = resultSet.getNextSequenceToReadFrom() - resultSet.readCount() - startSequence;
assertEquals(500, lostCount);
}
Aggregations