use of com.hazelcast.cp.internal.raftop.metadata.AddCPMemberOp in project hazelcast by hazelcast.
the class RaftService method promoteToCPMember.
public InternalCompletableFuture<Void> promoteToCPMember() {
InternalCompletableFuture<Void> future = newCompletableFuture();
if (!metadataGroupManager.isDiscoveryCompleted()) {
return complete(future, new IllegalStateException("CP Subsystem discovery is not completed yet!"));
}
if (nodeEngine.getLocalMember().isLiteMember()) {
return complete(future, new IllegalStateException("Lite members cannot be promoted to CP member!"));
}
if (getLocalCPMember() != null) {
future.complete(null);
return future;
}
MemberImpl localMember = nodeEngine.getLocalMember();
// Local member may be recovered during restart, for instance via Hot Restart,
// but Raft state cannot be recovered back.
// That's why we generate a new UUID while promoting a member to CP.
// This new UUID generation can be removed when Hot Restart allows to recover Raft state.
CPMemberInfo member = new CPMemberInfo(newUnsecureUUID(), localMember.getAddress());
logger.info("Adding new CP member: " + member);
invocationManager.invoke(getMetadataGroupId(), new AddCPMemberOp(member)).whenCompleteAsync((response, t) -> {
if (t == null) {
metadataGroupManager.initPromotedCPMember(member);
future.complete(null);
} else {
complete(future, t);
}
});
return future;
}
Aggregations