public GrpcLogAppender(RaftServerImpl server, LeaderState leaderState, FollowerInfo f) { super(server, leaderState, f); this.rpcService = (GrpcService) server.getServerRpc(); maxPendingRequestsNum = GrpcConfigKeys.Server.leaderOutstandingAppendsMax( server.getProxy().getProperties()); requestTimeoutDuration = RaftServerConfigKeys.Rpc.requestTimeout(server.getProxy().getProperties()); pendingRequests = new ConcurrentHashMap<>(); }
synchronized void changeToLeader() { Preconditions.assertTrue(isCandidate()); shutdownElectionDaemon(); setRole(Role.LEADER, "changeToLeader"); state.becomeLeader(); // start sending AppendEntries RPC to followers leaderState = new LeaderState(this, getProxy().getProperties()); leaderState.start(); }
RaftServerImpl(RaftGroup group, StateMachine stateMachine, RaftServerProxy proxy) throws IOException { final RaftPeerId id = proxy.getId(); LOG.debug("{}: new RaftServerImpl for {}", id, group); this.groupId = group.getGroupId(); this.lifeCycle = new LifeCycle(id); this.stateMachine = stateMachine; final RaftProperties properties = proxy.getProperties(); minTimeoutMs = RaftServerConfigKeys.Rpc.timeoutMin(properties).toInt(TimeUnit.MILLISECONDS); maxTimeoutMs = RaftServerConfigKeys.Rpc.timeoutMax(properties).toInt(TimeUnit.MILLISECONDS); Preconditions.assertTrue(maxTimeoutMs > minTimeoutMs, "max timeout: %s, min timeout: %s", maxTimeoutMs, minTimeoutMs); this.proxy = proxy; this.state = new ServerState(id, group, properties, this, stateMachine); this.retryCache = initRetryCache(properties); this.jmxAdapter = new RaftServerJmxAdapter(); }
synchronized void changeToLeader() { Preconditions.assertTrue(isCandidate()); role.shutdownLeaderElection(); setRole(RaftPeerRole.LEADER, "changeToLeader"); state.becomeLeader(); // start sending AppendEntries RPC to followers final LogEntryProto e = role.startLeaderState(this, getProxy().getProperties()); getState().setRaftConf(e); }
public LogAppender(RaftServerImpl server, LeaderState leaderState, FollowerInfo f) { this.follower = f; this.server = server; this.leaderState = leaderState; this.raftLog = server.getState().getLog(); final RaftProperties properties = server.getProxy().getProperties(); this.snapshotChunkMaxSize = RaftServerConfigKeys.Log.Appender.snapshotChunkSizeMax(properties).getSizeInt(); this.halfMinTimeoutMs = server.getMinTimeoutMs() / 2; final SizeInBytes bufferByteLimit = RaftServerConfigKeys.Log.Appender.bufferByteLimit(properties); final int bufferElementLimit = RaftServerConfigKeys.Log.Appender.bufferElementLimit(properties); this.buffer = new DataQueue<>(this, bufferByteLimit, bufferElementLimit, EntryWithData::getSerializedSize); this.lifeCycle = new LifeCycle(this); }
public LogAppender(RaftServerImpl server, LeaderState leaderState, FollowerInfo f) { this.follower = f; this.server = server; this.leaderState = leaderState; this.raftLog = server.getState().getLog(); final RaftProperties properties = server.getProxy().getProperties(); this.maxBufferSize = RaftServerConfigKeys.Log.Appender.bufferCapacity(properties).getSizeInt(); this.batchSending = RaftServerConfigKeys.Log.Appender.batchEnabled(properties); this.snapshotChunkMaxSize = RaftServerConfigKeys.Log.Appender.snapshotChunkSizeMax(properties).getSizeInt(); this.halfMinTimeoutMs = server.getMinTimeoutMs() / 2; this.buffer = new LogEntryBuffer(); this.lifeCycle = new LifeCycle(this); }
RaftServerImpl(RaftGroup group, StateMachine stateMachine, RaftServerProxy proxy) throws IOException { final RaftPeerId id = proxy.getId(); LOG.info("{}: new RaftServerImpl for {} with {}", id, group, stateMachine); this.groupId = group.getGroupId(); this.lifeCycle = new LifeCycle(id); this.stateMachine = stateMachine; this.role = new RoleInfo(id); final RaftProperties properties = proxy.getProperties(); minTimeoutMs = RaftServerConfigKeys.Rpc.timeoutMin(properties).toIntExact(TimeUnit.MILLISECONDS); maxTimeoutMs = RaftServerConfigKeys.Rpc.timeoutMax(properties).toIntExact(TimeUnit.MILLISECONDS); rpcSlownessTimeoutMs = RaftServerConfigKeys.Rpc.slownessTimeout(properties).toIntExact(TimeUnit.MILLISECONDS); Preconditions.assertTrue(maxTimeoutMs > minTimeoutMs, "max timeout: %s, min timeout: %s", maxTimeoutMs, minTimeoutMs); this.proxy = proxy; this.state = new ServerState(id, group, properties, this, stateMachine); this.retryCache = initRetryCache(properties); this.jmxAdapter = new RaftServerJmxAdapter(); }