Search in sources :

Example 1 with GrpcRaftRpcFactory

use of com.alipay.sofa.jraft.rpc.impl.GrpcRaftRpcFactory in project nacos by alibaba.

the class JRaftUtils method initRpcServer.

public static RpcServer initRpcServer(JRaftServer server, PeerId peerId) {
    GrpcRaftRpcFactory raftRpcFactory = (GrpcRaftRpcFactory) RpcFactoryHelper.rpcFactory();
    raftRpcFactory.registerProtobufSerializer(Log.class.getName(), Log.getDefaultInstance());
    raftRpcFactory.registerProtobufSerializer(GetRequest.class.getName(), GetRequest.getDefaultInstance());
    raftRpcFactory.registerProtobufSerializer(WriteRequest.class.getName(), WriteRequest.getDefaultInstance());
    raftRpcFactory.registerProtobufSerializer(ReadRequest.class.getName(), ReadRequest.getDefaultInstance());
    raftRpcFactory.registerProtobufSerializer(Response.class.getName(), Response.getDefaultInstance());
    MarshallerRegistry registry = raftRpcFactory.getMarshallerRegistry();
    registry.registerResponseInstance(Log.class.getName(), Response.getDefaultInstance());
    registry.registerResponseInstance(GetRequest.class.getName(), Response.getDefaultInstance());
    registry.registerResponseInstance(WriteRequest.class.getName(), Response.getDefaultInstance());
    registry.registerResponseInstance(ReadRequest.class.getName(), Response.getDefaultInstance());
    final RpcServer rpcServer = raftRpcFactory.createRpcServer(peerId.getEndpoint());
    RaftRpcServerFactory.addRaftRequestProcessors(rpcServer, RaftExecutor.getRaftCoreExecutor(), RaftExecutor.getRaftCliServiceExecutor());
    // Deprecated
    rpcServer.registerProcessor(new NacosLogProcessor(server, SerializeFactory.getDefault()));
    // Deprecated
    rpcServer.registerProcessor(new NacosGetRequestProcessor(server, SerializeFactory.getDefault()));
    rpcServer.registerProcessor(new NacosWriteRequestProcessor(server, SerializeFactory.getDefault()));
    rpcServer.registerProcessor(new NacosReadRequestProcessor(server, SerializeFactory.getDefault()));
    return rpcServer;
}
Also used : Response(com.alibaba.nacos.consistency.entity.Response) NacosWriteRequestProcessor(com.alibaba.nacos.core.distributed.raft.processor.NacosWriteRequestProcessor) MarshallerRegistry(com.alipay.sofa.jraft.rpc.impl.MarshallerRegistry) NacosReadRequestProcessor(com.alibaba.nacos.core.distributed.raft.processor.NacosReadRequestProcessor) NacosGetRequestProcessor(com.alibaba.nacos.core.distributed.raft.processor.NacosGetRequestProcessor) Log(com.alibaba.nacos.consistency.entity.Log) WriteRequest(com.alibaba.nacos.consistency.entity.WriteRequest) GetRequest(com.alibaba.nacos.consistency.entity.GetRequest) RpcServer(com.alipay.sofa.jraft.rpc.RpcServer) NacosLogProcessor(com.alibaba.nacos.core.distributed.raft.processor.NacosLogProcessor) GrpcRaftRpcFactory(com.alipay.sofa.jraft.rpc.impl.GrpcRaftRpcFactory) ReadRequest(com.alibaba.nacos.consistency.entity.ReadRequest)

Aggregations

GetRequest (com.alibaba.nacos.consistency.entity.GetRequest)1 Log (com.alibaba.nacos.consistency.entity.Log)1 ReadRequest (com.alibaba.nacos.consistency.entity.ReadRequest)1 Response (com.alibaba.nacos.consistency.entity.Response)1 WriteRequest (com.alibaba.nacos.consistency.entity.WriteRequest)1 NacosGetRequestProcessor (com.alibaba.nacos.core.distributed.raft.processor.NacosGetRequestProcessor)1 NacosLogProcessor (com.alibaba.nacos.core.distributed.raft.processor.NacosLogProcessor)1 NacosReadRequestProcessor (com.alibaba.nacos.core.distributed.raft.processor.NacosReadRequestProcessor)1 NacosWriteRequestProcessor (com.alibaba.nacos.core.distributed.raft.processor.NacosWriteRequestProcessor)1 RpcServer (com.alipay.sofa.jraft.rpc.RpcServer)1 GrpcRaftRpcFactory (com.alipay.sofa.jraft.rpc.impl.GrpcRaftRpcFactory)1 MarshallerRegistry (com.alipay.sofa.jraft.rpc.impl.MarshallerRegistry)1