Search in sources :

Example 1 with MapPartitionLostEvent

use of com.hazelcast.map.MapPartitionLostEvent 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 2 with MapPartitionLostEvent

use of com.hazelcast.map.MapPartitionLostEvent in project hazelcast by hazelcast.

the class MapEventPublishingService method dispatchMapPartitionLostEventData.

private void dispatchMapPartitionLostEventData(MapPartitionEventData eventData, ListenerAdapter listener) {
    Member member = getMember(eventData);
    MapPartitionLostEvent event = createMapPartitionLostEventData(eventData, member);
    callListener(listener, event);
}
Also used : MapPartitionLostEvent(com.hazelcast.map.MapPartitionLostEvent) Member(com.hazelcast.cluster.Member)

Aggregations

MapPartitionLostEvent (com.hazelcast.map.MapPartitionLostEvent)2 ClientEndpoint (com.hazelcast.client.ClientEndpoint)1 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 Member (com.hazelcast.cluster.Member)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 MapPartitionLostListener (com.hazelcast.map.listener.MapPartitionLostListener)1