private String getLeaderEndpoint(){ for(ClusterServer server : this.configuration.getServers()){ if(server.getId() == this.leaderId){ return server.getEndpoint(); } } logger.info("no endpoint could be found for leader %d, that usually means no leader is elected, retry the first one", this.leaderId); this.randomLeader = true; this.leaderId = this.configuration.getServers().get(0).getId(); return this.configuration.getServers().get(0).getEndpoint(); } }
private String getLeaderEndpoint(){ for(ClusterServer server : this.configuration.getServers()){ if(server.getId() == this.leaderId){ return server.getEndpoint(); } } logger.info("no endpoint could be found for leader %d, that usually means no leader is elected, retry the first one", this.leaderId); this.randomLeader = true; this.leaderId = this.configuration.getServers().get(0).getId(); return this.configuration.getServers().get(0).getEndpoint(); } }
private String getLeaderEndpoint(){ for(ClusterServer server : this.configuration.getServers()){ if(server.getId() == this.leaderId){ return server.getEndpoint(); } } logger.info("no endpoint could be found for leader %d, that usually means no leader is elected, retry the first one", this.leaderId); this.randomLeader = true; this.leaderId = this.configuration.getServers().get(0).getId(); return this.configuration.getServers().get(0).getEndpoint(); } }
rpcClient = this.server.context.getRpcClientFactory().createRpcClient(leader.getEndpoint()); this.rpcClients.put(leaderId, rpcClient);
rpcClient = this.server.context.getRpcClientFactory().createRpcClient(leader.getEndpoint()); this.rpcClients.put(leaderId, rpcClient);
rpcClient = this.server.context.getRpcClientFactory().createRpcClient(leader.getEndpoint()); this.rpcClients.put(leaderId, rpcClient);
public PeerServer(ClusterServer server, RaftContext context, final Consumer<PeerServer> heartbeatConsumer){ this.clusterConfig = server; this.rpcClient = context.getRpcClientFactory().createRpcClient(server.getEndpoint()); this.busyFlag = new AtomicInteger(0); this.pendingCommitFlag = new AtomicInteger(0); this.heartbeatInterval = this.currentHeartbeatInterval = context.getRaftParameters().getHeartbeatInterval(); this.maxHeartbeatInterval = context.getRaftParameters().getMaxHeartbeatInterval(); this.rpcBackoffInterval = context.getRaftParameters().getRpcFailureBackoff(); this.heartbeatTask = null; this.snapshotSyncContext = null; this.nextLogIndex = 1; this.matchedIndex = 0; this.heartbeatEnabled = false; this.executor = context.getScheduledExecutor(); PeerServer self = this; this.heartbeatTimeoutHandler = new Callable<Void>(){ @Override public Void call() throws Exception { heartbeatConsumer.accept(self); return null; }}; }
port = Integer.parseInt(args[2]); URI localEndpoint = new URI(config.getServer(stateManager.getServerId()).getEndpoint()); RaftParameters raftParameters = new RaftParameters() .withElectionTimeoutUpper(5000)
port = Integer.parseInt(args[2]); URI localEndpoint = new URI(config.getServer(stateManager.getServerId()).getEndpoint()); RaftParameters raftParameters = new RaftParameters() .withElectionTimeoutUpper(5000)
public PeerServer(ClusterServer server, RaftContext context, final Consumer<PeerServer> heartbeatConsumer){ this.clusterConfig = server; this.rpcClient = context.getRpcClientFactory().createRpcClient(server.getEndpoint()); this.busyFlag = new AtomicInteger(0); this.pendingCommitFlag = new AtomicInteger(0); this.heartbeatInterval = this.currentHeartbeatInterval = context.getRaftParameters().getHeartbeatInterval(); this.maxHeartbeatInterval = context.getRaftParameters().getMaxHeartbeatInterval(); this.rpcBackoffInterval = context.getRaftParameters().getRpcFailureBackoff(); this.heartbeatTask = null; this.snapshotSyncContext = null; this.nextLogIndex = 1; this.matchedIndex = 0; this.heartbeatEnabled = false; this.executor = context.getScheduledExecutor(); PeerServer self = this; this.heartbeatTimeoutHandler = new Callable<Void>(){ @Override public Void call() throws Exception { heartbeatConsumer.accept(self); return null; }}; }
public PeerServer(ClusterServer server, RaftContext context, final Consumer<PeerServer> heartbeatConsumer){ this.clusterConfig = server; this.rpcClient = context.getRpcClientFactory().createRpcClient(server.getEndpoint()); this.busyFlag = new AtomicInteger(0); this.pendingCommitFlag = new AtomicInteger(0); this.heartbeatInterval = this.currentHeartbeatInterval = context.getRaftParameters().getHeartbeatInterval(); this.maxHeartbeatInterval = context.getRaftParameters().getMaxHeartbeatInterval(); this.rpcBackoffInterval = context.getRaftParameters().getRpcFailureBackoff(); this.heartbeatTask = null; this.snapshotSyncContext = null; this.nextLogIndex = 1; this.matchedIndex = 0; this.heartbeatEnabled = false; this.executor = context.getScheduledExecutor(); PeerServer self = this; this.heartbeatTimeoutHandler = new Callable<Void>(){ @Override public Void call() throws Exception { heartbeatConsumer.accept(self); return null; }}; }