use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class FrozenPartitionTableTest method testPartitionTableIsHealedWhenClusterStateIsActiveAfter.
private void testPartitionTableIsHealedWhenClusterStateIsActiveAfter(final ClusterState clusterState) {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
HazelcastInstance[] instances = factory.newInstances();
warmUpPartitions(instances);
changeClusterStateEventually(instances[0], clusterState);
List<HazelcastInstance> instancesList = new ArrayList<HazelcastInstance>(asList(instances));
Collections.shuffle(instancesList);
final HazelcastInstance instanceToShutdown = instancesList.remove(0);
final Address addressToShutdown = getNode(instanceToShutdown).getThisAddress();
instanceToShutdown.shutdown();
for (HazelcastInstance instance : instancesList) {
assertClusterSizeEventually(2, instance);
}
changeClusterStateEventually(instancesList.get(0), ClusterState.ACTIVE);
waitAllForSafeState(instancesList);
for (HazelcastInstance instance : instancesList) {
PartitionTableView partitionTable = getPartitionTable(instance);
for (int i = 0; i < partitionTable.length(); i++) {
for (PartitionReplica replica : partitionTable.getReplicas(i)) {
if (replica == null) {
continue;
}
assertNotEquals(addressToShutdown, replica.address());
}
}
}
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class InternalPartitionServiceImplTest method test_setInitialState.
@Test
public void test_setInitialState() {
InternalPartition[] partitions = new InternalPartition[partitionCount];
for (int i = 0; i < partitionCount; i++) {
PartitionReplica[] replicas = new PartitionReplica[MAX_REPLICA_COUNT];
replicas[0] = PartitionReplica.from(localMember);
partitions[i] = new ReadonlyInternalPartition(replicas, i, RandomPicker.getInt(1, 10));
}
partitionService.setInitialState(new PartitionTableView(partitions));
for (int i = 0; i < partitionCount; i++) {
assertTrue(partitionService.isPartitionOwner(i));
}
assertNotEquals(0, partitionService.getPartitionStateStamp());
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class MigrationCommitServiceTest method createShiftUpMigration.
private MigrationInfo createShiftUpMigration(int partitionId, int oldReplicaIndex, int newReplicaIndex) {
InternalPartitionImpl partition = getPartition(instances[0], partitionId);
PartitionReplica source = partition.getReplica(newReplicaIndex);
PartitionReplica destination = partition.getReplica(oldReplicaIndex);
return new MigrationInfo(partitionId, source, destination, newReplicaIndex, -1, oldReplicaIndex, newReplicaIndex);
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class MigrationCommitServiceTest method testSuccessfulMoveMigration.
private void testSuccessfulMoveMigration(int partitionId, int replicaIndexToClear, int replicaIndexToMigrate) throws Exception {
PartitionReplica destination = clearReplicaIndex(partitionId, replicaIndexToClear);
MigrationInfo migration = createMoveMigration(partitionId, replicaIndexToMigrate, destination);
migrateWithSuccess(migration);
assertMigrationSourceCommit(migration);
assertMigrationDestinationCommit(migration);
assertPartitionDataAfterMigrations();
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class InternalPartitionImplTest method testSetReplicaAddresses_ListenerShouldBeCalled.
@Test
public void testSetReplicaAddresses_ListenerShouldBeCalled() {
replicaOwners[0] = localReplica;
replicaOwners[1] = new PartitionReplica(newAddress(5001), UuidUtil.newUnsecureUUID());
partition.setReplicas(replicaOwners);
assertEquals(2, partitionListener.eventCount);
}
Aggregations