Search in sources :

Example 1 with RaftNodeAware

use of com.hazelcast.cp.internal.RaftNodeAware 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);
}
Also used : RaftNodeAware(com.hazelcast.cp.internal.RaftNodeAware) NotLeaderException(com.hazelcast.cp.exception.NotLeaderException) RaftService(com.hazelcast.cp.internal.RaftService) CPGroupDestroyedException(com.hazelcast.cp.exception.CPGroupDestroyedException) RaftNode(com.hazelcast.cp.internal.raft.impl.RaftNode)

Aggregations

CPGroupDestroyedException (com.hazelcast.cp.exception.CPGroupDestroyedException)1 NotLeaderException (com.hazelcast.cp.exception.NotLeaderException)1 RaftNodeAware (com.hazelcast.cp.internal.RaftNodeAware)1 RaftService (com.hazelcast.cp.internal.RaftService)1 RaftNode (com.hazelcast.cp.internal.raft.impl.RaftNode)1