use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class QueueListenerTest method testItemListener_addedToQueueConfig_Issue366.
@Test
public void testItemListener_addedToQueueConfig_Issue366() throws Exception {
String queueName = "Q";
int totalQueuePut = 2000;
CountdownItemListener countdownItemListener = new CountdownItemListener(totalQueuePut, 0);
Config config = getConfig();
ItemListenerConfig itemListenerConfig = new ItemListenerConfig().setImplementation(countdownItemListener).setIncludeValue(true);
config.getQueueConfig(queueName).addItemListenerConfig(itemListenerConfig);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance = factory.newHazelcastInstance(config);
IQueue<VersionedObject<Integer>> queue = instance.getQueue(queueName);
for (int i = 0; i < totalQueuePut / 2; i++) {
queue.put(new VersionedObject<>(i));
}
HazelcastInstance second = factory.newHazelcastInstance(config);
assertTrueEventually(() -> {
EventService eventService1 = getNodeEngineImpl(instance).getEventService();
EventService eventService2 = getNodeEngineImpl(second).getEventService();
assertEquals(2, eventService1.getRegistrations(QueueService.SERVICE_NAME, queueName).size());
assertEquals(2, eventService2.getRegistrations(QueueService.SERVICE_NAME, queueName).size());
});
for (int i = 0; i < totalQueuePut / 4; i++) {
queue.put(new VersionedObject<>(i));
}
assertOpenEventually(countdownItemListener.added);
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class AbstractCollectionProxyImpl method addItemListener.
@Nonnull
public UUID addItemListener(@Nonnull ItemListener<E> listener, boolean includeValue) {
checkNotNull(listener, "Null listener is not allowed!");
final EventService eventService = getNodeEngine().getEventService();
final CollectionEventFilter filter = new CollectionEventFilter(includeValue);
final EventRegistration registration = eventService.registerListener(getServiceName(), name, filter, listener);
return registration.getId();
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class RemoveCPMembershipListenerMessageTask method processInternal.
@Override
protected CompletableFuture<Boolean> processInternal() {
UUID registrationId = this.parameters;
endpoint.removeDestroyAction(registrationId);
EventService eventService = clientEngine.getEventService();
return eventService.deregisterListenerAsync(getServiceName(), EVENT_TOPIC_MEMBERSHIP, registrationId);
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class PartitionEventManager method addMigrationListenerAsync.
public CompletableFuture<UUID> addMigrationListenerAsync(@Nonnull MigrationListener listener) {
checkNotNull(listener, "listener can't be null");
final MigrationListenerAdapter adapter = new MigrationListenerAdapter(listener);
EventService eventService = nodeEngine.getEventService();
return eventService.registerListenerAsync(SERVICE_NAME, MIGRATION_EVENT_TOPIC, adapter).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class PartitionEventManager method addMigrationListener.
public UUID addMigrationListener(@Nonnull MigrationListener listener) {
checkNotNull(listener, "listener can't be null");
final MigrationListenerAdapter adapter = new MigrationListenerAdapter(listener);
EventService eventService = nodeEngine.getEventService();
EventRegistration registration = eventService.registerListener(SERVICE_NAME, MIGRATION_EVENT_TOPIC, adapter);
return registration.getId();
}
Aggregations