Search in sources :

Example 1 with RaftStoreClosure

use of com.baidu.hugegraph.backend.store.raft.RaftStoreClosure in project incubator-hugegraph by apache.

the class StoreCommandProcessor method processRequest.

@Override
public Message processRequest(StoreCommandRequest request, RpcRequestClosure done) {
    LOG.debug("Processing StoreCommandRequest: {}", request.getAction());
    RaftNode node = this.context.node();
    try {
        StoreCommand command = this.parseStoreCommand(request);
        RaftStoreClosure closure = new RaftStoreClosure(command);
        node.submitAndWait(command, closure);
        // TODO: return the submitAndWait() result to rpc client
        return StoreCommandResponse.newBuilder().setStatus(true).build();
    } catch (Throwable e) {
        LOG.warn("Failed to process StoreCommandRequest: {}", request.getAction(), e);
        StoreCommandResponse.Builder builder = StoreCommandResponse.newBuilder().setStatus(false);
        if (e.getMessage() != null) {
            builder.setMessage(e.getMessage());
        }
        return builder.build();
    }
}
Also used : StoreCommand(com.baidu.hugegraph.backend.store.raft.StoreCommand) RaftNode(com.baidu.hugegraph.backend.store.raft.RaftNode) RaftStoreClosure(com.baidu.hugegraph.backend.store.raft.RaftStoreClosure)

Aggregations

RaftNode (com.baidu.hugegraph.backend.store.raft.RaftNode)1 RaftStoreClosure (com.baidu.hugegraph.backend.store.raft.RaftStoreClosure)1 StoreCommand (com.baidu.hugegraph.backend.store.raft.StoreCommand)1