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);
}
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;
}
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();
}
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();
}
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();
}
Aggregations