Search in sources :

Example 6 with ClientEndpoint

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;
}
Also used : MapPartitionLostListener(com.hazelcast.map.listener.MapPartitionLostListener) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientEndpoint(com.hazelcast.client.ClientEndpoint) MapService(com.hazelcast.map.impl.MapService) MapPartitionLostEvent(com.hazelcast.map.MapPartitionLostEvent) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 7 with ClientEndpoint

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;
}
Also used : CollectionEventFilter(com.hazelcast.collection.impl.collection.CollectionEventFilter) EventRegistration(com.hazelcast.spi.EventRegistration) Data(com.hazelcast.nio.serialization.Data) ItemListener(com.hazelcast.core.ItemListener) EventService(com.hazelcast.spi.EventService) ClientEndpoint(com.hazelcast.client.ClientEndpoint)

Example 8 with ClientEndpoint

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;
}
Also used : ClientEndpoint(com.hazelcast.client.ClientEndpoint) MapService(com.hazelcast.map.impl.MapService) EventFilter(com.hazelcast.spi.EventFilter) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 9 with ClientEndpoint

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;
}
Also used : ClientEndpoint(com.hazelcast.client.ClientEndpoint) CacheContext(com.hazelcast.cache.impl.CacheContext) CacheService(com.hazelcast.cache.impl.CacheService)

Example 10 with ClientEndpoint

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);
}
Also used : OperationFactoryWrapper(com.hazelcast.client.impl.operations.OperationFactoryWrapper) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) ClientEndpoint(com.hazelcast.client.ClientEndpoint) OperationFactory(com.hazelcast.spi.OperationFactory)

Aggregations

ClientEndpoint (com.hazelcast.client.ClientEndpoint)21 CacheService (com.hazelcast.cache.impl.CacheService)4 Data (com.hazelcast.nio.serialization.Data)4 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)3 ItemListener (com.hazelcast.core.ItemListener)3 EventRegistration (com.hazelcast.spi.EventRegistration)3 EventService (com.hazelcast.spi.EventService)3 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)3 CacheContext (com.hazelcast.cache.impl.CacheContext)2 ClientEngineImpl (com.hazelcast.client.impl.ClientEngineImpl)2 OperationFactoryWrapper (com.hazelcast.client.impl.operations.OperationFactoryWrapper)2 CollectionEventFilter (com.hazelcast.collection.impl.collection.CollectionEventFilter)2 MapService (com.hazelcast.map.impl.MapService)2 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)2 EventFilter (com.hazelcast.spi.EventFilter)2 InvocationBuilder (com.hazelcast.spi.InvocationBuilder)2 OperationFactory (com.hazelcast.spi.OperationFactory)2 ICacheService (com.hazelcast.cache.impl.ICacheService)1 CachePartitionLostEvent (com.hazelcast.cache.impl.event.CachePartitionLostEvent)1 CachePartitionLostEventFilter (com.hazelcast.cache.impl.event.CachePartitionLostEventFilter)1