Search in sources :

Example 1 with JRaftException

use of com.alibaba.nacos.core.distributed.raft.exception.JRaftException in project nacos by alibaba.

the class JRaftServer method start.

synchronized void start() {
    if (!isStarted) {
        Loggers.RAFT.info("========= The raft protocol is starting... =========");
        try {
            // init raft group node
            com.alipay.sofa.jraft.NodeManager raftNodeManager = com.alipay.sofa.jraft.NodeManager.getInstance();
            for (String address : raftConfig.getMembers()) {
                PeerId peerId = PeerId.parsePeer(address);
                conf.addPeer(peerId);
                raftNodeManager.addAddress(peerId.getEndpoint());
            }
            nodeOptions.setInitialConf(conf);
            rpcServer = JRaftUtils.initRpcServer(this, localPeerId);
            if (!this.rpcServer.init(null)) {
                Loggers.RAFT.error("Fail to init [BaseRpcServer].");
                throw new RuntimeException("Fail to init [BaseRpcServer].");
            }
            // Initialize multi raft group service framework
            isStarted = true;
            createMultiRaftGroup(processors);
            Loggers.RAFT.info("========= The raft protocol start finished... =========");
        } catch (Exception e) {
            Loggers.RAFT.error("raft protocol start failure, cause: ", e);
            throw new JRaftException(e);
        }
    }
}
Also used : JRaftException(com.alibaba.nacos.core.distributed.raft.exception.JRaftException) JRaftException(com.alibaba.nacos.core.distributed.raft.exception.JRaftException) ConsistencyException(com.alibaba.nacos.consistency.exception.ConsistencyException) DuplicateRaftGroupException(com.alibaba.nacos.core.distributed.raft.exception.DuplicateRaftGroupException) NoLeaderException(com.alibaba.nacos.core.distributed.raft.exception.NoLeaderException) NoSuchRaftGroupException(com.alibaba.nacos.core.distributed.raft.exception.NoSuchRaftGroupException) PeerId(com.alipay.sofa.jraft.entity.PeerId)

Aggregations

ConsistencyException (com.alibaba.nacos.consistency.exception.ConsistencyException)1 DuplicateRaftGroupException (com.alibaba.nacos.core.distributed.raft.exception.DuplicateRaftGroupException)1 JRaftException (com.alibaba.nacos.core.distributed.raft.exception.JRaftException)1 NoLeaderException (com.alibaba.nacos.core.distributed.raft.exception.NoLeaderException)1 NoSuchRaftGroupException (com.alibaba.nacos.core.distributed.raft.exception.NoSuchRaftGroupException)1 PeerId (com.alipay.sofa.jraft.entity.PeerId)1