use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.
the class HazelcastRaftTestSupport method getLeaderInstance.
protected static HazelcastInstance getLeaderInstance(HazelcastInstance[] instances, CPGroupId groupId) {
RaftNodeImpl[] raftNodeRef = new RaftNodeImpl[1];
assertTrueEventually(() -> {
for (HazelcastInstance instance : instances) {
RaftNodeImpl raftNode = getRaftNode(instance, groupId);
if (raftNode != null) {
raftNodeRef[0] = raftNode;
return;
}
}
fail();
});
RaftNodeImpl raftNode = raftNodeRef[0];
waitUntilLeaderElected(raftNode);
RaftEndpoint leaderEndpoint = getLeaderMember(raftNode);
assertNotNull(leaderEndpoint);
for (HazelcastInstance instance : instances) {
CPMember cpMember = instance.getCPSubsystem().getLocalCPMember();
if (cpMember != null && leaderEndpoint.getUuid().equals(cpMember.getUuid())) {
return instance;
}
}
throw new AssertionError();
}
use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.
the class RaftInvocation method getTargetEndpoint.
private CPMember getTargetEndpoint() {
CPMember target = raftInvocationContext.getKnownLeader(groupId);
if (target != null) {
return target;
}
MemberCursor cursor = memberCursor;
if (cursor == null || !cursor.advance()) {
cursor = raftInvocationContext.newMemberCursor();
if (!cursor.advance()) {
return null;
}
memberCursor = cursor;
}
return cursor.get();
}
use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.
the class GetCPMembersMessageTask method processInternal.
@Override
protected CompletableFuture<List<SimpleEntry<UUID, UUID>>> processInternal() {
CPSubsystemManagementService cpService = nodeEngine.getHazelcastInstance().getCPSubsystem().getCPSubsystemManagementService();
ClusterService clusterService = nodeEngine.getClusterService();
return cpService.getCPMembers().toCompletableFuture().thenApply(cpMembers -> {
List<SimpleEntry<UUID, UUID>> result = new ArrayList<>(cpMembers.size());
for (CPMember cpMember : cpMembers) {
UUID apUuid = clusterService.getMember(cpMember.getAddress()).getUuid();
result.add(new SimpleEntry<>(cpMember.getUuid(), apUuid));
}
return result;
});
}
use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.
the class RaftService method removeCPMember.
public InternalCompletableFuture<Void> removeCPMember(UUID cpMemberUuid) {
ClusterService clusterService = nodeEngine.getClusterService();
InternalCompletableFuture<Void> future = newCompletableFuture();
BiConsumer<Void, Throwable> removeMemberCallback = (response, t) -> {
if (t == null) {
future.complete(null);
} else {
if (t instanceof CannotRemoveCPMemberException) {
t = new IllegalStateException(t.getMessage());
}
complete(future, t);
}
};
invocationManager.<Collection<CPMember>>invoke(getMetadataGroupId(), new GetActiveCPMembersOp()).whenCompleteAsync((cpMembers, t) -> {
if (t == null) {
CPMemberInfo cpMemberToRemove = null;
for (CPMember cpMember : cpMembers) {
if (cpMember.getUuid().equals(cpMemberUuid)) {
cpMemberToRemove = (CPMemberInfo) cpMember;
break;
}
}
if (cpMemberToRemove == null) {
complete(future, new IllegalArgumentException("No CPMember found with uuid: " + cpMemberUuid));
return;
} else {
Member member = clusterService.getMember(cpMemberToRemove.getAddress());
if (member != null) {
logger.warning("Only unreachable/crashed CP members should be removed. " + member + " is alive but " + cpMemberToRemove + " with the same address is being removed.");
}
}
invokeTriggerRemoveMember(cpMemberToRemove).whenCompleteAsync(removeMemberCallback);
} else {
complete(future, t);
}
});
return future;
}
use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.
the class CPGroupSummary method writeData.
@Override
public void writeData(ObjectDataOutput out) throws IOException {
out.writeObject(id);
out.writeInt(initialMembers.size());
for (RaftEndpoint member : initialMembers) {
out.writeObject(member);
}
out.writeInt(members.size());
for (CPMember member : members) {
out.writeObject(member);
}
out.writeString(status.toString());
}
Aggregations