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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations