Search in sources :

Example 6 with MigrationEvent

use of com.hazelcast.core.MigrationEvent 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);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService) Member(com.hazelcast.core.Member) MigrationEvent(com.hazelcast.core.MigrationEvent) PartitionMigrationEvent(com.hazelcast.spi.PartitionMigrationEvent)

Example 7 with MigrationEvent

use of com.hazelcast.core.MigrationEvent 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());
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) MemberImpl(com.hazelcast.instance.MemberImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) EventService(com.hazelcast.spi.EventService) MigrationEvent(com.hazelcast.core.MigrationEvent)

Aggregations

MigrationEvent (com.hazelcast.core.MigrationEvent)7 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 EventRegistration (com.hazelcast.spi.EventRegistration)2 EventService (com.hazelcast.spi.EventService)2 Member (com.hazelcast.core.Member)1 MemberImpl (com.hazelcast.instance.MemberImpl)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 ObjectDataInput (com.hazelcast.nio.ObjectDataInput)1 ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 PartitionMigrationEvent (com.hazelcast.spi.PartitionMigrationEvent)1