use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class CacheAddPartitionLostListenerMessageTask method call.
@Override
protected Object call() {
final ClientEndpoint endpoint = getEndpoint();
CachePartitionLostListener listener = new CachePartitionLostListener() {
@Override
public void partitionLost(CachePartitionLostEvent event) {
if (endpoint.isAlive()) {
ClientMessage eventMessage = CacheAddPartitionLostListenerCodec.encodeCachePartitionLostEvent(event.getPartitionId(), event.getMember().getUuid());
sendClientMessage(null, eventMessage);
}
}
};
InternalCachePartitionLostListenerAdapter listenerAdapter = new InternalCachePartitionLostListenerAdapter(listener);
EventFilter filter = new CachePartitionLostEventFilter();
CacheService service = getService(CacheService.SERVICE_NAME);
EventService eventService = service.getNodeEngine().getEventService();
EventRegistration registration;
if (parameters.localOnly) {
registration = eventService.registerLocalListener(ICacheService.SERVICE_NAME, parameters.name, filter, listenerAdapter);
} else {
registration = eventService.registerListener(ICacheService.SERVICE_NAME, parameters.name, filter, listenerAdapter);
}
String registrationId = registration.getId();
endpoint.addListenerDestroyAction(CacheService.SERVICE_NAME, parameters.name, registrationId);
return registrationId;
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class ListAddListenerMessageTask method call.
@Override
protected Object call() {
ClientEndpoint endpoint = getEndpoint();
Data partitionKey = serializationService.toData(parameters.name);
ItemListener listener = createItemListener(endpoint, partitionKey);
EventService eventService = clientEngine.getEventService();
CollectionEventFilter filter = new CollectionEventFilter(parameters.includeValue);
EventRegistration registration;
if (parameters.localOnly) {
registration = eventService.registerLocalListener(getServiceName(), parameters.name, filter, listener);
} else {
registration = eventService.registerListener(getServiceName(), parameters.name, filter, listener);
}
String registrationId = registration.getId();
endpoint.addListenerDestroyAction(getServiceName(), parameters.name, registrationId);
return registrationId;
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class SetAddListenerMessageTask method call.
@Override
protected Object call() {
ClientEndpoint endpoint = getEndpoint();
Data partitionKey = serializationService.toData(parameters.name);
ItemListener listener = createItemListener(endpoint, partitionKey);
EventService eventService = clientEngine.getEventService();
CollectionEventFilter filter = new CollectionEventFilter(parameters.includeValue);
EventRegistration registration;
if (parameters.localOnly) {
registration = eventService.registerLocalListener(getServiceName(), parameters.name, filter, listener);
} else {
registration = eventService.registerListener(getServiceName(), parameters.name, filter, listener);
}
String registrationId = registration.getId();
endpoint.addListenerDestroyAction(getServiceName(), parameters.name, registrationId);
return registrationId;
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class AbstractCollectionProxyImpl method addItemListener.
public String addItemListener(ItemListener<E> listener, boolean includeValue) {
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.EventService in project hazelcast by hazelcast.
the class TimedMemberStateFactoryHelper method registerJMXBeans.
static void registerJMXBeans(HazelcastInstanceImpl instance, MemberStateImpl memberState) {
final EventService es = instance.node.nodeEngine.getEventService();
final InternalOperationService os = instance.node.nodeEngine.getOperationService();
final ConnectionManager cm = instance.node.connectionManager;
final InternalPartitionService ps = instance.node.partitionService;
final ProxyService proxyService = instance.node.nodeEngine.getProxyService();
final ExecutionService executionService = instance.node.nodeEngine.getExecutionService();
final MXBeansDTO beans = new MXBeansDTO();
final EventServiceDTO esBean = new EventServiceDTO(es);
beans.setEventServiceBean(esBean);
final OperationServiceDTO osBean = new OperationServiceDTO(os);
beans.setOperationServiceBean(osBean);
final ConnectionManagerDTO cmBean = new ConnectionManagerDTO(cm);
beans.setConnectionManagerBean(cmBean);
final PartitionServiceBeanDTO psBean = new PartitionServiceBeanDTO(ps, instance);
beans.setPartitionServiceBean(psBean);
final ProxyServiceDTO proxyServiceBean = new ProxyServiceDTO(proxyService);
beans.setProxyServiceBean(proxyServiceBean);
final ManagedExecutorService systemExecutor = executionService.getExecutor(ExecutionService.SYSTEM_EXECUTOR);
final ManagedExecutorService asyncExecutor = executionService.getExecutor(ExecutionService.ASYNC_EXECUTOR);
final ManagedExecutorService scheduledExecutor = executionService.getExecutor(ExecutionService.SCHEDULED_EXECUTOR);
final ManagedExecutorService clientExecutor = executionService.getExecutor(ExecutionService.CLIENT_EXECUTOR);
final ManagedExecutorService queryExecutor = executionService.getExecutor(ExecutionService.QUERY_EXECUTOR);
final ManagedExecutorService ioExecutor = executionService.getExecutor(ExecutionService.IO_EXECUTOR);
final ManagedExecutorDTO systemExecutorDTO = new ManagedExecutorDTO(systemExecutor);
final ManagedExecutorDTO asyncExecutorDTO = new ManagedExecutorDTO(asyncExecutor);
final ManagedExecutorDTO scheduledExecutorDTO = new ManagedExecutorDTO(scheduledExecutor);
final ManagedExecutorDTO clientExecutorDTO = new ManagedExecutorDTO(clientExecutor);
final ManagedExecutorDTO queryExecutorDTO = new ManagedExecutorDTO(queryExecutor);
final ManagedExecutorDTO ioExecutorDTO = new ManagedExecutorDTO(ioExecutor);
beans.putManagedExecutor(ExecutionService.SYSTEM_EXECUTOR, systemExecutorDTO);
beans.putManagedExecutor(ExecutionService.ASYNC_EXECUTOR, asyncExecutorDTO);
beans.putManagedExecutor(ExecutionService.SCHEDULED_EXECUTOR, scheduledExecutorDTO);
beans.putManagedExecutor(ExecutionService.CLIENT_EXECUTOR, clientExecutorDTO);
beans.putManagedExecutor(ExecutionService.QUERY_EXECUTOR, queryExecutorDTO);
beans.putManagedExecutor(ExecutionService.IO_EXECUTOR, ioExecutorDTO);
memberState.setBeans(beans);
}
Aggregations