use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class RaftInvocationManagerTest method when_raftGroupIsCreated_then_raftOperationsAreExecutedOnNonCPNode.
@Test
public void when_raftGroupIsCreated_then_raftOperationsAreExecutedOnNonCPNode() throws ExecutionException, InterruptedException {
int cpNodeCount = 5;
instances = newInstances(cpNodeCount, 3, 1);
RaftInvocationManager invocationService = getRaftInvocationManager(instances[instances.length - 1]);
CPGroupId groupId = invocationService.createRaftGroup("test", cpNodeCount).get();
for (int i = 0; i < 100; i++) {
invocationService.invoke(groupId, new RaftTestApplyOp("val" + i)).get();
}
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class RaftInvocationManagerTest method when_raftGroupIsDestroyed_then_operationsEventuallyFail.
@Test
public void when_raftGroupIsDestroyed_then_operationsEventuallyFail() throws ExecutionException, InterruptedException {
int nodeCount = 3;
instances = newInstances(nodeCount);
RaftInvocationManager invocationManager = getRaftInvocationManager(instances[0]);
CPGroupId groupId = invocationManager.createRaftGroup("test", nodeCount).get();
invocationManager.invoke(groupId, new RaftTestApplyOp("val")).get();
invocationManager.invoke(getRaftService(instances[0]).getMetadataGroupId(), new TriggerDestroyRaftGroupOp(groupId)).get();
assertTrueEventually(() -> {
try {
invocationManager.invoke(groupId, new RaftTestApplyOp("val")).get();
fail();
} catch (ExecutionException e) {
assertInstanceOf(CPGroupDestroyedException.class, e.getCause());
}
});
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class RaftInvocationManagerTest method when_raftGroupIsCreated_then_raftOperationsAreExecuted.
@Test
public void when_raftGroupIsCreated_then_raftOperationsAreExecuted() throws ExecutionException, InterruptedException {
int nodeCount = 5;
instances = newInstances(nodeCount);
RaftInvocationManager invocationService = getRaftInvocationManager(instances[0]);
CPGroupId groupId = invocationService.createRaftGroup("test", nodeCount).get();
for (int i = 0; i < 100; i++) {
invocationService.invoke(groupId, new RaftTestApplyOp("val" + i)).get();
}
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class RaftService method publishGroupAvailabilityEvents.
private void publishGroupAvailabilityEvents(MemberImpl removedMember) {
ClusterService clusterService = nodeEngine.getClusterService();
if (clusterService.getClusterVersion().isUnknownOrLessThan(Versions.V4_1)) {
return;
}
// they will be the ones that keep track of unreachable CP members.
for (CPGroupId groupId : metadataGroupManager.getActiveGroupIds()) {
CPGroupSummary group = metadataGroupManager.getGroup(groupId);
Collection<CPMember> missing = new ArrayList<>();
boolean availabilityDecreased = false;
for (CPMember member : group.members()) {
if (member.getAddress().equals(removedMember.getAddress())) {
// Group's availability decreased because of this removed member
availabilityDecreased = true;
missing.add(member);
} else if (clusterService.getMember(member.getAddress()) == null) {
missing.add(member);
}
}
if (availabilityDecreased) {
CPGroupAvailabilityEvent e = new CPGroupAvailabilityEventImpl(group.id(), group.members(), missing);
nodeEngine.getEventService().publishEvent(SERVICE_NAME, EVENT_TOPIC_AVAILABILITY, e, EVENT_TOPIC_AVAILABILITY.hashCode());
}
}
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class RaftService method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
MetricDescriptor rootDescriptor = descriptor.withPrefix(CP_PREFIX_RAFT_GROUP);
for (Entry<CPGroupId, RaftNodeMetrics> entry : nodeMetrics.entrySet()) {
CPGroupId groupId = entry.getKey();
RaftRole role = entry.getValue().role;
MetricDescriptor groupDescriptor = rootDescriptor.copy().withDiscriminator(CP_DISCRIMINATOR_GROUPID, String.valueOf(groupId.getId())).withTag(CP_TAG_NAME, groupId.getName()).withTag("role", role != null ? role.toString() : "NONE");
context.collect(groupDescriptor, entry.getValue());
}
}
Aggregations