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