/** * So far we use a simple implementation for catchup checking: * 1. If the latest rpc time of the remote peer is before 3 * max_timeout, * the peer made no progress for that long. We should fail the whole * setConfiguration request. * 2. If the peer's matching index is just behind for a small gap, and the * peer was updated recently (within max_timeout), declare the peer as * caught-up. * 3. Otherwise the peer is making progressing. Keep waiting. */ private BootStrapProgress checkProgress(FollowerInfo follower, long committed) { Preconditions.assertTrue(!follower.isAttendingVote()); final Timestamp progressTime = new Timestamp().addTimeMs(-server.getMaxTimeoutMs()); final Timestamp timeoutTime = new Timestamp().addTimeMs(-3*server.getMaxTimeoutMs()); if (follower.getLastRpcResponseTime().compareTo(timeoutTime) < 0) { LOG.debug("{} detects a follower {} timeout for bootstrapping," + " timeoutTime: {}", server.getId(), follower, timeoutTime); return BootStrapProgress.NOPROGRESS; } else if (follower.getMatchIndex() + stagingCatchupGap > committed && follower.getLastRpcResponseTime().compareTo(progressTime) > 0) { return BootStrapProgress.CAUGHTUP; } else { return BootStrapProgress.PROGRESSING; } }
/** * So far we use a simple implementation for catchup checking: * 1. If the latest rpc time of the remote peer is before 3 * max_timeout, * the peer made no progress for that long. We should fail the whole * setConfiguration request. * 2. If the peer's matching index is just behind for a small gap, and the * peer was updated recently (within max_timeout), declare the peer as * caught-up. * 3. Otherwise the peer is making progressing. Keep waiting. */ private BootStrapProgress checkProgress(FollowerInfo follower, long committed) { Preconditions.assertTrue(!follower.isAttendingVote()); final Timestamp progressTime = Timestamp.currentTime().addTimeMs(-server.getMaxTimeoutMs()); final Timestamp timeoutTime = Timestamp.currentTime().addTimeMs(-3*server.getMaxTimeoutMs()); if (follower.getLastRpcResponseTime().compareTo(timeoutTime) < 0) { LOG.debug("{} detects a follower {} timeout for bootstrapping," + " timeoutTime: {}", server.getId(), follower, timeoutTime); return BootStrapProgress.NOPROGRESS; } else if (follower.getMatchIndex() + stagingCatchupGap > committed && follower.getLastRpcResponseTime().compareTo(progressTime) > 0) { return BootStrapProgress.CAUGHTUP; } else { return BootStrapProgress.PROGRESSING; } }
ls.getLogAppenders().map(LogAppender::getFollower).forEach(f -> leader.addFollowerInfo(ServerProtoUtils.toServerRpcProto( f.getPeer(), f.getLastRpcResponseTime().elapsedTimeMs()))); roleInfo.setLeaderInfo(leader); });