Search in sources :

Example 1 with ReplicaMigrationEvent

use of com.hazelcast.partition.ReplicaMigrationEvent in project hazelcast by hazelcast.

the class PartitionEventManager method sendMigrationProcessStartedEvent.

public void sendMigrationProcessStartedEvent(MigrationState state) {
    ReplicaMigrationEvent event = new ReplicaMigrationEventImpl(state, MIGRATION_STARTED_PARTITION_ID, 0, null, null, false, 0L);
    sendMigrationEvent(event);
}
Also used : ReplicaMigrationEventImpl(com.hazelcast.internal.partition.ReplicaMigrationEventImpl) ReplicaMigrationEvent(com.hazelcast.partition.ReplicaMigrationEvent)

Example 2 with ReplicaMigrationEvent

use of com.hazelcast.partition.ReplicaMigrationEvent in project hazelcast by hazelcast.

the class MigrationListenerAdapterTest method test_migrationFailed.

@Test
public void test_migrationFailed() {
    MigrationState migrationSchedule = new MigrationStateImpl();
    ReplicaMigrationEvent event = new ReplicaMigrationEventImpl(migrationSchedule, 0, 0, null, null, false, 0L);
    adapter.onEvent(event);
    verify(listener, never()).migrationStarted(any(MigrationState.class));
    verify(listener, never()).migrationFinished(any(MigrationState.class));
    verify(listener, never()).replicaMigrationCompleted(any(ReplicaMigrationEvent.class));
    verify(listener).replicaMigrationFailed(event);
}
Also used : MigrationState(com.hazelcast.partition.MigrationState) ReplicaMigrationEventImpl(com.hazelcast.internal.partition.ReplicaMigrationEventImpl) MigrationStateImpl(com.hazelcast.internal.partition.MigrationStateImpl) ReplicaMigrationEvent(com.hazelcast.partition.ReplicaMigrationEvent) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with ReplicaMigrationEvent

use of com.hazelcast.partition.ReplicaMigrationEvent in project hazelcast by hazelcast.

the class PartitionEventManager method sendMigrationProcessCompletedEvent.

public void sendMigrationProcessCompletedEvent(MigrationState state) {
    ReplicaMigrationEvent event = new ReplicaMigrationEventImpl(state, MIGRATION_FINISHED_PARTITION_ID, 0, null, null, false, 0L);
    sendMigrationEvent(event);
}
Also used : ReplicaMigrationEventImpl(com.hazelcast.internal.partition.ReplicaMigrationEventImpl) ReplicaMigrationEvent(com.hazelcast.partition.ReplicaMigrationEvent)

Example 4 with ReplicaMigrationEvent

use of com.hazelcast.partition.ReplicaMigrationEvent in project hazelcast by hazelcast.

the class PartitionEventManager method sendMigrationEvent.

/**
 * Sends a {@link ReplicaMigrationEvent} to the registered event listeners.
 */
public void sendMigrationEvent(MigrationState state, MigrationInfo migrationInfo, long elapsed) {
    ClusterServiceImpl clusterService = node.getClusterService();
    PartitionReplica sourceReplica = migrationInfo.getSource();
    PartitionReplica destReplica = migrationInfo.getDestination();
    Member source = sourceReplica != null ? clusterService.getMember(sourceReplica.address(), sourceReplica.uuid()) : null;
    Member destination = clusterService.getMember(destReplica.address(), destReplica.uuid());
    int partitionId = migrationInfo.getPartitionId();
    int replicaIndex = migrationInfo.getDestinationNewReplicaIndex();
    boolean success = migrationInfo.getStatus() == MigrationStatus.SUCCESS;
    ReplicaMigrationEvent event = new ReplicaMigrationEventImpl(state, partitionId, replicaIndex, source, destination, success, elapsed);
    sendMigrationEvent(event);
}
Also used : PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ReplicaMigrationEventImpl(com.hazelcast.internal.partition.ReplicaMigrationEventImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ReplicaMigrationEvent(com.hazelcast.partition.ReplicaMigrationEvent) Member(com.hazelcast.cluster.Member)

Example 5 with ReplicaMigrationEvent

use of com.hazelcast.partition.ReplicaMigrationEvent in project hazelcast by hazelcast.

the class MigrationListenerAdapterTest method test_migrationProcessCompleted.

@Test
public void test_migrationProcessCompleted() {
    MigrationState migrationSchedule = new MigrationStateImpl();
    ReplicaMigrationEvent event = new ReplicaMigrationEventImpl(migrationSchedule, MIGRATION_FINISHED_PARTITION_ID, 0, null, null, true, 0L);
    adapter.onEvent(event);
    verify(listener, never()).migrationStarted(any(MigrationState.class));
    verify(listener).migrationFinished(migrationSchedule);
    verify(listener, never()).replicaMigrationCompleted(any(ReplicaMigrationEvent.class));
    verify(listener, never()).replicaMigrationFailed(any(ReplicaMigrationEvent.class));
}
Also used : MigrationState(com.hazelcast.partition.MigrationState) ReplicaMigrationEventImpl(com.hazelcast.internal.partition.ReplicaMigrationEventImpl) MigrationStateImpl(com.hazelcast.internal.partition.MigrationStateImpl) ReplicaMigrationEvent(com.hazelcast.partition.ReplicaMigrationEvent) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ReplicaMigrationEventImpl (com.hazelcast.internal.partition.ReplicaMigrationEventImpl)7 ReplicaMigrationEvent (com.hazelcast.partition.ReplicaMigrationEvent)7 MigrationStateImpl (com.hazelcast.internal.partition.MigrationStateImpl)4 MigrationState (com.hazelcast.partition.MigrationState)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 Member (com.hazelcast.cluster.Member)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)1