Search in sources :

Example 1 with ReadonlyInternalPartition

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;
}
Also used : InternalPartition(com.hazelcast.internal.partition.InternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition)

Example 2 with ReadonlyInternalPartition

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));
}
Also used : PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) PartitionTableView(com.hazelcast.internal.partition.PartitionTableView) InternalPartition(com.hazelcast.internal.partition.InternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with ReadonlyInternalPartition

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));
}
Also used : Address(com.hazelcast.cluster.Address) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) InternalPartition(com.hazelcast.internal.partition.InternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with ReadonlyInternalPartition

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));
}
Also used : InternalPartition(com.hazelcast.internal.partition.InternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with ReadonlyInternalPartition

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));
}
Also used : InternalPartition(com.hazelcast.internal.partition.InternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition) ReadonlyInternalPartition(com.hazelcast.internal.partition.ReadonlyInternalPartition) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

InternalPartition (com.hazelcast.internal.partition.InternalPartition)6 ReadonlyInternalPartition (com.hazelcast.internal.partition.ReadonlyInternalPartition)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)3 PartitionTableView (com.hazelcast.internal.partition.PartitionTableView)2 Address (com.hazelcast.cluster.Address)1