use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.
the class MapAddPartitionLostListenerMessageTask method call.
@Override
protected Object call() {
final ClientEndpoint endpoint = getEndpoint();
final MapService mapService = getService(MapService.SERVICE_NAME);
final MapPartitionLostListener listener = new MapPartitionLostListener() {
@Override
public void partitionLost(MapPartitionLostEvent event) {
if (endpoint.isAlive()) {
ClientMessage eventMessage = MapAddPartitionLostListenerCodec.encodeMapPartitionLostEvent(event.getPartitionId(), event.getMember().getUuid());
sendClientMessage(null, eventMessage);
}
}
};
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
String registrationId;
if (parameters.localOnly) {
registrationId = mapServiceContext.addLocalPartitionLostListener(listener, parameters.name);
} else {
registrationId = mapServiceContext.addPartitionLostListener(listener, parameters.name);
}
endpoint.addListenerDestroyAction(MapService.SERVICE_NAME, parameters.name, registrationId);
return registrationId;
}
use of com.hazelcast.client.ClientEndpoint 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.client.ClientEndpoint in project hazelcast by hazelcast.
the class AbstractMapAddEntryListenerMessageTask method call.
@Override
protected Object call() {
final ClientEndpoint endpoint = getEndpoint();
final MapService mapService = getService(MapService.SERVICE_NAME);
Object listener = newMapListener();
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
String name = getDistributedObjectName();
EventFilter eventFilter = getEventFilter();
String registrationId;
if (isLocalOnly()) {
registrationId = mapServiceContext.addLocalEventListener(listener, eventFilter, name);
} else {
registrationId = mapServiceContext.addEventListener(listener, eventFilter, name);
}
endpoint.addListenerDestroyAction(MapService.SERVICE_NAME, name, registrationId);
return registrationId;
}
use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.
the class Pre38CacheAddInvalidationListenerTask method call.
@Override
protected Object call() {
ClientEndpoint endpoint = getEndpoint();
CacheService cacheService = getService(CacheService.SERVICE_NAME);
CacheContext cacheContext = cacheService.getOrCreateCacheContext(parameters.name);
Pre38NearCacheInvalidationListener listener = new Pre38NearCacheInvalidationListener(endpoint, cacheContext, nodeEngine.getLocalMember().getUuid());
String registrationId = cacheService.addInvalidationListener(parameters.name, listener, parameters.localOnly);
endpoint.addListenerDestroyAction(CacheService.SERVICE_NAME, parameters.name, registrationId);
return registrationId;
}
use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.
the class AbstractMultiPartitionMessageTask method call.
@Override
protected Object call() throws Exception {
ClientEndpoint endpoint = getEndpoint();
OperationFactory operationFactory = new OperationFactoryWrapper(createOperationFactory(), endpoint.getUuid());
final InternalOperationService operationService = nodeEngine.getOperationService();
Map<Integer, Object> map = operationService.invokeOnPartitions(getServiceName(), operationFactory, getPartitions());
return reduce(map);
}
Aggregations