use of com.hazelcast.internal.partition.ReadonlyInternalPartition in project hazelcast by hazelcast.
the class PartitionStateManager method getPartitionsCopy.
/**
* Returns a copy of the current partition table.
*/
public InternalPartition[] getPartitionsCopy(boolean readonly) {
NopPartitionReplicaInterceptor interceptor = new NopPartitionReplicaInterceptor();
InternalPartition[] result = new InternalPartition[partitions.length];
for (int i = 0; i < partitionCount; i++) {
if (readonly) {
result[i] = new ReadonlyInternalPartition(partitions[i]);
} else {
result[i] = partitions[i].copy(interceptor);
}
}
return result;
}
use of com.hazelcast.internal.partition.ReadonlyInternalPartition 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.ReadonlyInternalPartition in project hazelcast by hazelcast.
the class PartitionReplicaStateChecker_triggerAndWaitForReplicaSyncTest method whenHasMissingReplicaOwners_withAddress_thenWaitForMissingReplicaOwners.
@Test
public void whenHasMissingReplicaOwners_withAddress_thenWaitForMissingReplicaOwners() throws Exception {
configureNeedsReplicaStateCheckResponse();
Address address = new Address("127.0.0.1", 5701);
PartitionReplica replica = new PartitionReplica(address, UuidUtil.newUnsecureUUID());
InternalPartition partition = new ReadonlyInternalPartition(new PartitionReplica[] { replica }, 1, 0);
partitions.add(partition);
assertEquals(REPLICA_NOT_OWNED, replicaStateChecker.getPartitionServiceState());
assertFalse(replicaStateChecker.triggerAndWaitForReplicaSync(10, TimeUnit.MILLISECONDS, 5));
}
use of com.hazelcast.internal.partition.ReadonlyInternalPartition in project hazelcast by hazelcast.
the class PartitionReplicaStateChecker_triggerAndWaitForReplicaSyncTest method whenCheckAndTriggerReplicaSync.
@Test
public void whenCheckAndTriggerReplicaSync() {
configureNeedsReplicaStateCheckResponseOnEachSecondCall();
InternalPartition partition = new ReadonlyInternalPartition(new PartitionReplica[] { null }, 1, 0);
partitions.add(partition);
assertEquals(REPLICA_NOT_SYNC, replicaStateChecker.getPartitionServiceState());
assertFalse(replicaStateChecker.triggerAndWaitForReplicaSync(10, TimeUnit.MILLISECONDS, 5));
}
use of com.hazelcast.internal.partition.ReadonlyInternalPartition in project hazelcast by hazelcast.
the class PartitionReplicaStateChecker_triggerAndWaitForReplicaSyncTest method whenHasMissingReplicaOwners_withoutAddress_thenWaitForMissingReplicaOwners.
@Test
public void whenHasMissingReplicaOwners_withoutAddress_thenWaitForMissingReplicaOwners() {
configureNeedsReplicaStateCheckResponse();
InternalPartition partition = new ReadonlyInternalPartition(new PartitionReplica[0], 1, 0);
partitions.add(partition);
assertEquals(REPLICA_NOT_OWNED, replicaStateChecker.getPartitionServiceState());
assertFalse(replicaStateChecker.triggerAndWaitForReplicaSync(10, TimeUnit.MILLISECONDS, 5));
}
Aggregations