use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class AbstractPromotionOperation method sendMigrationEvent.
void sendMigrationEvent(final MigrationStatus status) {
final int partitionId = getPartitionId();
final NodeEngine nodeEngine = getNodeEngine();
final Member localMember = nodeEngine.getLocalMember();
final MigrationEvent event = new MigrationEvent(partitionId, null, localMember, status);
final EventService eventService = nodeEngine.getEventService();
final Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, MIGRATION_EVENT_TOPIC);
eventService.publishEvent(SERVICE_NAME, registrations, event, partitionId);
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class PartitionEventManager method addLocalPartitionLostListener.
public String addLocalPartitionLostListener(PartitionLostListener listener) {
if (listener == null) {
throw new NullPointerException("listener can't be null");
}
final PartitionLostListenerAdapter adapter = new PartitionLostListenerAdapter(listener);
EventService eventService = nodeEngine.getEventService();
EventRegistration registration = eventService.registerLocalListener(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC, adapter);
return registration.getId();
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class PartitionEventManager method sendMigrationEvent.
void sendMigrationEvent(final MigrationInfo migrationInfo, final MigrationEvent.MigrationStatus status) {
if (migrationInfo.getSourceCurrentReplicaIndex() != 0 && migrationInfo.getDestinationNewReplicaIndex() != 0) {
// only fire events for 0th replica migrations
return;
}
ClusterServiceImpl clusterService = node.getClusterService();
MemberImpl current = clusterService.getMember(migrationInfo.getSource());
MemberImpl newOwner = clusterService.getMember(migrationInfo.getDestination());
MigrationEvent event = new MigrationEvent(migrationInfo.getPartitionId(), current, newOwner, status);
EventService eventService = nodeEngine.getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, MIGRATION_EVENT_TOPIC);
eventService.publishEvent(SERVICE_NAME, registrations, event, event.getPartitionId());
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class MultiMapOperation method hasListener.
public final boolean hasListener() {
EventService eventService = getNodeEngine().getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(getServiceName(), name);
return registrations.size() > 0;
}
Aggregations