类 JRaftServer


  • public class JRaftServer
    extends java.lang.Object
    JRaft server instance, away from Spring IOC management.

    Why do we need to create a raft group based on the value of LogProcessor group (), that is, each function module has its own state machine. Because each LogProcessor corresponds to a different functional module, such as Nacos's naming module and config module, these two modules are independent of each other and do not affect each other. If we have only one state machine, it is equal to the log of all functional modules The processing is loaded together. Any module that has an exception during the log processing and a long block operation will affect the normal operation of other functional modules.

    作者:
    liaochuntao
    • 构造器概要

      构造器 
      构造器 说明
      JRaftServer()  
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      void applyOperation​(com.alipay.sofa.jraft.Node node, com.google.protobuf.Message data, FailoverClosure closure)  
      java.util.concurrent.CompletableFuture<com.alibaba.nacos.consistency.entity.Response> commit​(java.lang.String group, com.google.protobuf.Message data, java.util.concurrent.CompletableFuture<com.alibaba.nacos.consistency.entity.Response> future)  
      (专用程序包) void createMultiRaftGroup​(java.util.Collection<com.alibaba.nacos.consistency.cp.RequestProcessor4CP> processors)  
      com.alipay.sofa.jraft.Node findNodeByGroup​(java.lang.String group)  
      JRaftServer.RaftGroupTuple findTupleByGroup​(java.lang.String group)  
      (专用程序包) java.util.concurrent.CompletableFuture<com.alibaba.nacos.consistency.entity.Response> get​(com.alibaba.nacos.consistency.entity.ReadRequest request)  
      (专用程序包) com.alipay.sofa.jraft.CliService getCliService()  
      protected com.alipay.sofa.jraft.entity.PeerId getLeader​(java.lang.String raftGroupId)  
      (专用程序包) java.util.Map<java.lang.String,​JRaftServer.RaftGroupTuple> getMultiRaftGroup()  
      (专用程序包) void init​(RaftConfig config)  
      private void invokeToLeader​(java.lang.String group, com.google.protobuf.Message request, int timeoutMillis, FailoverClosure closure)  
      (专用程序包) void mockMultiRaftGroup​(java.util.Map<java.lang.String,​JRaftServer.RaftGroupTuple> map)  
      (专用程序包) boolean peerChange​(JRaftMaintainService maintainService, java.util.Set<java.lang.String> newPeers)  
      void readFromLeader​(com.alibaba.nacos.consistency.entity.ReadRequest request, java.util.concurrent.CompletableFuture<com.alibaba.nacos.consistency.entity.Response> future)  
      (专用程序包) void refreshRouteTable​(java.lang.String group)  
      (专用程序包) void registerSelfToCluster​(java.lang.String groupId, com.alipay.sofa.jraft.entity.PeerId selfIp, com.alipay.sofa.jraft.conf.Configuration conf)
      Add yourself to the Raft cluster
      void setFailoverRetries​(int failoverRetries)  
      (专用程序包) void shutdown()  
      (专用程序包) void start()  
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • rpcServer

        private com.alipay.sofa.jraft.rpc.RpcServer rpcServer
      • cliClientService

        private com.alipay.sofa.jraft.rpc.impl.cli.CliClientServiceImpl cliClientService
      • cliService

        private com.alipay.sofa.jraft.CliService cliService
      • isStarted

        private volatile boolean isStarted
      • isShutdown

        private volatile boolean isShutdown
      • conf

        private com.alipay.sofa.jraft.conf.Configuration conf
      • userProcessor

        private com.alipay.sofa.jraft.rpc.RpcProcessor userProcessor
      • nodeOptions

        private com.alipay.sofa.jraft.option.NodeOptions nodeOptions
      • serializer

        private com.alibaba.nacos.consistency.Serializer serializer
      • processors

        private java.util.Collection<com.alibaba.nacos.consistency.cp.RequestProcessor4CP> processors
      • selfIp

        private java.lang.String selfIp
      • selfPort

        private int selfPort
      • localPeerId

        private com.alipay.sofa.jraft.entity.PeerId localPeerId
      • failoverRetries

        private int failoverRetries
      • rpcRequestTimeoutMs

        private int rpcRequestTimeoutMs
    • 构造器详细资料

      • JRaftServer

        public JRaftServer()
    • 方法详细资料

      • setFailoverRetries

        public void setFailoverRetries​(int failoverRetries)
      • start

        void start()
      • createMultiRaftGroup

        void createMultiRaftGroup​(java.util.Collection<com.alibaba.nacos.consistency.cp.RequestProcessor4CP> processors)
      • get

        java.util.concurrent.CompletableFuture<com.alibaba.nacos.consistency.entity.Response> get​(com.alibaba.nacos.consistency.entity.ReadRequest request)
      • readFromLeader

        public void readFromLeader​(com.alibaba.nacos.consistency.entity.ReadRequest request,
                                   java.util.concurrent.CompletableFuture<com.alibaba.nacos.consistency.entity.Response> future)
      • commit

        public java.util.concurrent.CompletableFuture<com.alibaba.nacos.consistency.entity.Response> commit​(java.lang.String group,
                                                                                                            com.google.protobuf.Message data,
                                                                                                            java.util.concurrent.CompletableFuture<com.alibaba.nacos.consistency.entity.Response> future)
      • registerSelfToCluster

        void registerSelfToCluster​(java.lang.String groupId,
                                   com.alipay.sofa.jraft.entity.PeerId selfIp,
                                   com.alipay.sofa.jraft.conf.Configuration conf)
        Add yourself to the Raft cluster
        参数:
        groupId - raft group
        selfIp - local raft node address
        conf - Configuration without self info
      • getLeader

        protected com.alipay.sofa.jraft.entity.PeerId getLeader​(java.lang.String raftGroupId)
      • shutdown

        void shutdown()
      • applyOperation

        public void applyOperation​(com.alipay.sofa.jraft.Node node,
                                   com.google.protobuf.Message data,
                                   FailoverClosure closure)
      • invokeToLeader

        private void invokeToLeader​(java.lang.String group,
                                    com.google.protobuf.Message request,
                                    int timeoutMillis,
                                    FailoverClosure closure)
      • peerChange

        boolean peerChange​(JRaftMaintainService maintainService,
                           java.util.Set<java.lang.String> newPeers)
      • refreshRouteTable

        void refreshRouteTable​(java.lang.String group)
      • findNodeByGroup

        public com.alipay.sofa.jraft.Node findNodeByGroup​(java.lang.String group)
      • getCliService

        com.alipay.sofa.jraft.CliService getCliService()