use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class InternalPartitionImplTest method testIsLocal_whenNOTOwnedByThis.
@Test
public void testIsLocal_whenNOTOwnedByThis() {
replicaOwners[0] = new PartitionReplica(newAddress(6000), UuidUtil.newUnsecureUUID());
partition.setReplicas(replicaOwners);
assertFalse(partition.isLocal());
assertEquals(1, partition.version());
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class InternalPartitionImplTest method testVersion_setReplica.
@Test
public void testVersion_setReplica() {
partition.setReplica(1, new PartitionReplica(newAddress(6000), UuidUtil.newUnsecureUUID()));
assertEquals(1, partition.version());
partition.setReplica(0, new PartitionReplica(newAddress(7000), UuidUtil.newUnsecureUUID()));
assertEquals(2, partition.version());
partition.setReplica(0, partition.getReplica(0));
assertEquals(2, partition.version());
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class FrozenPartitionTableTest method partitionTable_isFrozen_whenMemberReJoins_duringClusterStateIs.
private void partitionTable_isFrozen_whenMemberReJoins_duringClusterStateIs(ClusterState state) {
Config config = new Config();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(4);
HazelcastInstance[] instances = factory.newInstances(config, 3);
HazelcastInstance hz1 = instances[0];
HazelcastInstance hz2 = instances[1];
HazelcastInstance hz3 = instances[2];
Address hz3Address = getNode(hz3).getThisAddress();
warmUpPartitions(instances);
final PartitionTableView partitionTable = getPartitionTable(hz1);
changeClusterStateEventually(hz2, state);
final Member member3 = getClusterService(hz3).getLocalMember();
terminateInstance(hz2);
terminateInstance(hz3);
hz3 = factory.newHazelcastInstance(hz3Address);
final Member newMember3 = getClusterService(hz3).getLocalMember();
assertClusterSizeEventually(2, hz1, hz3);
final List<HazelcastInstance> instanceList = asList(hz1, hz3);
assertTrueAllTheTime(new AssertTask() {
@Override
public void run() {
for (HazelcastInstance instance : instanceList) {
PartitionTableView newPartitionTable = getPartitionTable(instance);
for (int i = 0; i < newPartitionTable.length(); i++) {
for (int j = 0; j < InternalPartition.MAX_REPLICA_COUNT; j++) {
PartitionReplica replica = partitionTable.getReplica(i, j);
PartitionReplica newReplica = newPartitionTable.getReplica(i, j);
if (replica == null) {
assertNull(newReplica);
} else if (replica.equals(PartitionReplica.from(member3))) {
assertEquals(PartitionReplica.from(newMember3), newReplica);
} else {
assertEquals(replica, newReplica);
}
}
}
}
}
}, 5);
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class InternalPartitionServiceImplTest method test_setInitialState_multipleTimes.
@Test(expected = IllegalStateException.class)
public void test_setInitialState_multipleTimes() {
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));
partitionService.setInitialState(new PartitionTableView(partitions));
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class MigrationCommitServiceTest method createMoveMigration.
private MigrationInfo createMoveMigration(int partitionId, int replicaIndex, PartitionReplica destination) {
InternalPartition partition = getPartition(instances[0], partitionId);
PartitionReplica source = partition.getReplica(replicaIndex);
return new MigrationInfo(partitionId, source, destination, replicaIndex, -1, -1, replicaIndex);
}
Aggregations