Search in sources :

Example 1 with PartitionReplicaVersionsView

use of com.hazelcast.internal.partition.PartitionReplicaVersionsView 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)

Aggregations

HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)1 PartitionReplicaVersionsView (com.hazelcast.internal.partition.PartitionReplicaVersionsView)1 TestPartitionUtils.getPartitionReplicaVersionsView (com.hazelcast.internal.partition.TestPartitionUtils.getPartitionReplicaVersionsView)1 TestMigrationAwareService (com.hazelcast.internal.partition.service.TestMigrationAwareService)1 ServiceNamespace (com.hazelcast.internal.services.ServiceNamespace)1 AssertTask (com.hazelcast.test.AssertTask)1