Search in sources :

Example 36 with CPGroupId

use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.

the class MetadataRaftGroupManager method ensureMetadataGroupId.

private void ensureMetadataGroupId(CPGroupId groupId) {
    CPGroupId metadataGroupId = getMetadataGroupId();
    checkTrue(metadataGroupId.equals(groupId), "Invalid RaftGroupId! Expected: " + metadataGroupId + ", Actual: " + groupId);
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId)

Example 37 with CPGroupId

use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.

the class RaftService method getLeadedGroups.

public Collection<CPGroupId> getLeadedGroups() {
    Collection<CPGroupId> groupIds = new ArrayList<>();
    RaftEndpoint localEndpoint = getLocalCPEndpoint();
    for (RaftNode raftNode : nodes.values()) {
        if (CPGroup.METADATA_CP_GROUP_NAME.equals(raftNode.getGroupId().getName())) {
            // Ignore metadata group
            continue;
        }
        RaftEndpoint leader = raftNode.getLeader();
        if (leader != null && leader.equals(localEndpoint)) {
            groupIds.add(raftNode.getGroupId());
        }
    }
    return groupIds;
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint) ArrayList(java.util.ArrayList) RaftNode(com.hazelcast.cp.internal.raft.impl.RaftNode) RaftNodeImpl.newRaftNode(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl.newRaftNode)

Example 38 with CPGroupId

use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.

the class RaftInvocationFailureTest method test_invocationFailsWithMemberLeftException_when_thereAreRetryableExceptionsAfterwards.

@Test
public void test_invocationFailsWithMemberLeftException_when_thereAreRetryableExceptionsAfterwards() throws ExecutionException, InterruptedException {
    CPGroupId groupId = getRaftInvocationManager(instances[0]).createRaftGroup(groupName).get();
    waitAllForLeaderElection(instances, groupId);
    HazelcastInstance leader = getLeaderInstance(instances, groupId);
    Future f = new RaftInvocation(getOperationService(leader).invocationContext, getRaftInvocationManager(leader).getRaftInvocationContext(), groupId, new DefaultRaftReplicateOp(groupId, new CustomResponseOp2()), 10, 50, 60000).invoke();
    try {
        f.get(60, TimeUnit.SECONDS);
        fail();
    } catch (Exception e) {
        assertInstanceOf(IndeterminateOperationStateException.class, e.getCause());
    }
    assertTrue(COMMIT_COUNT.get() > groupSize);
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Future(java.util.concurrent.Future) IndeterminateOperationStateException(com.hazelcast.core.IndeterminateOperationStateException) DefaultRaftReplicateOp(com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp) StaleAppendRequestException(com.hazelcast.cp.exception.StaleAppendRequestException) CallerNotMemberException(com.hazelcast.spi.exception.CallerNotMemberException) IndeterminateOperationStateException(com.hazelcast.core.IndeterminateOperationStateException) MemberLeftException(com.hazelcast.core.MemberLeftException) ExecutionException(java.util.concurrent.ExecutionException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 39 with CPGroupId

use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.

the class RaftInvocationFailureTest method test_invocationFailsWitNonRetryableException_when_thereAreRetryableExceptionsAfterIndeterminateOperationState.

@Test
public void test_invocationFailsWitNonRetryableException_when_thereAreRetryableExceptionsAfterIndeterminateOperationState() throws ExecutionException, InterruptedException {
    CPGroupId groupId = getRaftInvocationManager(instances[0]).createRaftGroup(groupName).get();
    waitAllForLeaderElection(instances, groupId);
    HazelcastInstance leader = getLeaderInstance(instances, groupId);
    Future f = new RaftInvocation(getOperationService(leader).invocationContext, getRaftInvocationManager(leader).getRaftInvocationContext(), groupId, new DefaultRaftReplicateOp(groupId, new CustomResponseOp5()), 10, 50, 60000).invoke();
    try {
        f.get(60, TimeUnit.SECONDS);
        fail();
    } catch (Exception e) {
        assertInstanceOf(IllegalStateException.class, e.getCause());
    }
    assertTrue(COMMIT_COUNT.get() > groupSize);
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Future(java.util.concurrent.Future) DefaultRaftReplicateOp(com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp) StaleAppendRequestException(com.hazelcast.cp.exception.StaleAppendRequestException) CallerNotMemberException(com.hazelcast.spi.exception.CallerNotMemberException) IndeterminateOperationStateException(com.hazelcast.core.IndeterminateOperationStateException) MemberLeftException(com.hazelcast.core.MemberLeftException) ExecutionException(java.util.concurrent.ExecutionException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 40 with CPGroupId

use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.

the class AbstractSessionlessSemaphoreBasicTest method testIncreasePermits_notifiesPendingAcquires.

@Test
public void testIncreasePermits_notifiesPendingAcquires() {
    semaphore.init(1);
    CountDownLatch latch = new CountDownLatch(1);
    spawn(() -> {
        try {
            semaphore.tryAcquire(2, 10, TimeUnit.MINUTES);
            latch.countDown();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    });
    assertTrueEventually(() -> {
        CPGroupId groupId = getGroupId(semaphore);
        HazelcastInstance leader = leaderInstanceOf(groupId);
        SemaphoreService service = getNodeEngineImpl(leader).getService(SemaphoreService.SERVICE_NAME);
        SemaphoreRegistry registry = service.getRegistryOrNull(groupId);
        assertNotNull(registry);
        assertFalse(registry.getWaitTimeouts().isEmpty());
    });
    semaphore.increasePermits(1);
    assertOpenEventually(latch);
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) HazelcastInstance(com.hazelcast.core.HazelcastInstance) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

CPGroupId (com.hazelcast.cp.CPGroupId)81 Test (org.junit.Test)50 HazelcastInstance (com.hazelcast.core.HazelcastInstance)42 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)37 QuickTest (com.hazelcast.test.annotation.QuickTest)31 CPGroup (com.hazelcast.cp.CPGroup)14 CPMember (com.hazelcast.cp.CPMember)13 RaftEndpoint (com.hazelcast.cp.internal.raft.impl.RaftEndpoint)11 RaftNodeImpl (com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)9 ArrayList (java.util.ArrayList)8 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)7 CountDownLatch (java.util.concurrent.CountDownLatch)7 ExecutionException (java.util.concurrent.ExecutionException)7 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)6 SlowTest (com.hazelcast.test.annotation.SlowTest)6 IndeterminateOperationStateException (com.hazelcast.core.IndeterminateOperationStateException)5 MemberLeftException (com.hazelcast.core.MemberLeftException)5 StaleAppendRequestException (com.hazelcast.cp.exception.StaleAppendRequestException)5 DefaultRaftReplicateOp (com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp)5 CallerNotMemberException (com.hazelcast.spi.exception.CallerNotMemberException)5