use of com.hazelcast.cp.internal.raft.impl.RaftNode in project hazelcast by hazelcast.
the class RaftService method stepDownRaftNode.
public void stepDownRaftNode(CPGroupId groupId) {
if (terminatedRaftNodeGroupIds.contains(groupId) || !hasSameSeed(groupId)) {
return;
}
assert !(Thread.currentThread() instanceof PartitionOperationThread) : "Cannot step down RaftNode of " + groupId + " in a partition thread!";
nodeLock.readLock().lock();
try {
if (terminatedRaftNodeGroupIds.contains(groupId)) {
return;
}
CPPersistenceService persistenceService = getCPPersistenceService();
RaftNode node = nodes.get(groupId);
if (node != null && node.getStatus() == RaftNodeStatus.STEPPED_DOWN) {
terminatedRaftNodeGroupIds.add(groupId);
destroyRaftNode(node, true);
logger.fine("RaftNode[" + groupId + "] has stepped down.");
} else if (node == null && persistenceService.isEnabled()) {
persistenceService.removeRaftStateStore((RaftGroupId) groupId);
logger.info("RaftStateStore of RaftNode[" + groupId + "] is deleted.");
}
} finally {
nodeLock.readLock().unlock();
}
}
use of com.hazelcast.cp.internal.raft.impl.RaftNode in project hazelcast by hazelcast.
the class RaftService method getOrInitRaftNode.
public RaftNode getOrInitRaftNode(CPGroupId groupId) {
RaftNode node = nodes.get(groupId);
if (node == null && isStartCompleted() && isDiscoveryCompleted() && !destroyedGroupIds.contains(groupId) && !terminatedRaftNodeGroupIds.contains(groupId)) {
logger.fine("RaftNode[" + groupId + "] does not exist. Asking to the METADATA CP group...");
nodeEngine.getExecutionService().execute(CP_SUBSYSTEM_EXECUTOR, new InitializeRaftNodeTask(groupId));
}
return node;
}
use of com.hazelcast.cp.internal.raft.impl.RaftNode in project hazelcast by hazelcast.
the class MetadataRaftGroupManager method isMetadataGroupLeader.
// could return stale information
boolean isMetadataGroupLeader() {
CPMemberInfo localCPMember = getLocalCPMember();
if (localCPMember == null) {
return false;
}
RaftNode raftNode = raftService.getRaftNode(getMetadataGroupId());
return raftNode != null && !raftNode.isTerminatedOrSteppedDown() && localCPMember.toRaftEndpoint().equals(raftNode.getLeader());
}
use of com.hazelcast.cp.internal.raft.impl.RaftNode in project hazelcast by hazelcast.
the class RaftQueryOp method run.
@Override
public final void run() {
RaftService service = getService();
RaftNode raftNode = service.getRaftNode(groupId);
if (raftNode == null) {
if (service.isRaftGroupDestroyed(groupId)) {
sendResponse(new CPGroupDestroyedException(groupId));
} else {
sendResponse(new NotLeaderException(groupId, service.getLocalCPEndpoint(), null));
}
return;
} else if (raftNode.getStatus() == RaftNodeStatus.STEPPED_DOWN) {
sendResponse(new NotLeaderException(groupId, service.getLocalCPEndpoint(), null));
getNodeEngine().getExecutionService().execute(CP_SUBSYSTEM_EXECUTOR, () -> service.stepDownRaftNode(groupId));
return;
}
if (op instanceof RaftNodeAware) {
((RaftNodeAware) op).setRaftNode(raftNode);
}
raftNode.query(op, queryPolicy).whenCompleteAsync(this, CALLER_RUNS);
}
Aggregations