Search in sources :

Example 26 with PartitionReplica

use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.

the class MigrationCommitServiceTest method createShiftDownMigration.

private MigrationInfo createShiftDownMigration(int partitionId, int oldReplicaIndex, int newReplicaIndex, PartitionReplica destination) {
    InternalPartitionImpl partition = getPartition(instances[0], partitionId);
    PartitionReplica source = partition.getReplica(oldReplicaIndex);
    return new MigrationInfo(partitionId, source, destination, oldReplicaIndex, newReplicaIndex, -1, oldReplicaIndex);
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica)

Example 27 with PartitionReplica

use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.

the class MigrationCommitServiceTest method clearReplicaIndex.

private PartitionReplica clearReplicaIndex(final int partitionId, int replicaIndexToClear) {
    final InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) getPartitionService(instances[0]);
    InternalPartitionImpl partition = (InternalPartitionImpl) partitionService.getPartition(partitionId);
    final PartitionReplica oldReplicaOwner = partition.getReplica(replicaIndexToClear);
    partition.setReplica(replicaIndexToClear, null);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            partitionService.checkClusterPartitionRuntimeStates();
            for (HazelcastInstance instance : instances) {
                assertEquals(partitionService.getPartitionStateStamp(), getPartitionService(instance).getPartitionStateStamp());
            }
        }
    });
    HazelcastInstance oldReplicaOwnerInstance = factory.getInstance(oldReplicaOwner.address());
    ClearReplicaRunnable op = new ClearReplicaRunnable(partitionId, getNodeEngineImpl(oldReplicaOwnerInstance));
    getOperationService(oldReplicaOwnerInstance).execute(op);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            PartitionReplicaVersionsView replicaVersionsView = getPartitionReplicaVersionsView(getNode(factory.getInstance(oldReplicaOwner.address())), partitionId);
            for (ServiceNamespace namespace : replicaVersionsView.getNamespaces()) {
                assertArrayEquals(new long[InternalPartition.MAX_BACKUP_COUNT], replicaVersionsView.getVersions(namespace));
            }
        }
    });
    TestMigrationAwareService migrationAwareService = getService(oldReplicaOwner.address());
    migrationAwareService.clearPartitionReplica(partitionId);
    for (HazelcastInstance instance : instances) {
        TestMigrationAwareService service = getNodeEngineImpl(instance).getService(TestMigrationAwareService.SERVICE_NAME);
        service.clearEvents();
    }
    return oldReplicaOwner;
}
Also used : TestMigrationAwareService(com.hazelcast.internal.partition.service.TestMigrationAwareService) HazelcastInstance(com.hazelcast.core.HazelcastInstance) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) AssertTask(com.hazelcast.test.AssertTask) PartitionReplicaVersionsView(com.hazelcast.internal.partition.PartitionReplicaVersionsView) TestPartitionUtils.getPartitionReplicaVersionsView(com.hazelcast.internal.partition.TestPartitionUtils.getPartitionReplicaVersionsView)

Example 28 with PartitionReplica

use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.

the class MigrationCommitServiceTest method testFailedMoveMigration.

private void testFailedMoveMigration(int partitionId, int replicaIndexToClear, int replicaIndexToMigrate) throws Exception {
    PartitionReplica destination = clearReplicaIndex(partitionId, replicaIndexToClear);
    MigrationInfo migration = createMoveMigration(partitionId, replicaIndexToMigrate, destination);
    migrateWithFailure(migration);
    assertMigrationSourceRollback(migration);
    assertMigrationDestinationRollback(migration);
    assertPartitionDataAfterMigrations();
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica)

Example 29 with PartitionReplica

use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.

the class MigrationCommitServiceTest method testPartitionBackupCopyRollback.

@Test
public void testPartitionBackupCopyRollback() throws Exception {
    PartitionReplica destination = clearReplicaIndex(PARTITION_ID_TO_MIGRATE, NODE_COUNT - 1);
    MigrationInfo migration = createCopyMigration(PARTITION_ID_TO_MIGRATE, NODE_COUNT - 1, destination);
    migrateWithFailure(migration);
    assertMigrationDestinationRollback(migration);
    assertPartitionDataAfterMigrations();
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 30 with PartitionReplica

use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.

the class MigrationCommitServiceTest method testSuccessfulShiftDownMigration.

private void testSuccessfulShiftDownMigration(int partitionId, int replicaIndexToClear, int oldReplicaIndex, int newReplicaIndex) throws Exception {
    PartitionReplica destination = clearReplicaIndex(partitionId, replicaIndexToClear);
    MigrationInfo migration = createShiftDownMigration(partitionId, oldReplicaIndex, newReplicaIndex, destination);
    migrateWithSuccess(migration);
    assertMigrationSourceCommit(migration);
    assertMigrationDestinationCommit(migration);
    assertPartitionDataAfterMigrations();
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica)

Aggregations

PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)103 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)51 QuickTest (com.hazelcast.test.annotation.QuickTest)51 Test (org.junit.Test)51 Address (com.hazelcast.cluster.Address)44 InternalPartition (com.hazelcast.internal.partition.InternalPartition)17 MigrationInfo (com.hazelcast.internal.partition.MigrationInfo)17 ArrayList (java.util.ArrayList)10 Member (com.hazelcast.cluster.Member)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)7 PartitionTableView (com.hazelcast.internal.partition.PartitionTableView)6 ReadonlyInternalPartition (com.hazelcast.internal.partition.ReadonlyInternalPartition)6 ClusterState (com.hazelcast.cluster.ClusterState)5 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)5 NodeEngine (com.hazelcast.spi.impl.NodeEngine)4 Operation (com.hazelcast.spi.impl.operationservice.Operation)4 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)3 MemberLeftException (com.hazelcast.core.MemberLeftException)3 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)3