if (cluster.getLocalMember().isLeader()) { logger.info(String.format("commits: %.2f/s latency: %.2f ms (%.2fms)", (requests.get() - start) / 5.0, avgLatency, latency.get()));
int prevLogTerm, int prevLogIndex, int commitIndex, boolean isHeartbeat, int entryTerm, byte[] buffer, int bufferOffset, int bufferLen, boolean lastCommand) throws Exception { latency.head(prevLogIndex + 1); electionTimeoutTs = clock.now() + electionTimeout; if (message.tracingInfo != null) {
byte[] buffer, int bufferOffset, int bufferLen, boolean lastCommand) throws InterruptedException, GondolaException { latency.head(prevLogIndex + 1); electionTimeoutTs = clock.now() + electionTimeout; if (message.tracingInfo != null) {
gondola.getHostId(), memberId, role, gondola.getProcessId(), waitMs, commandQueue.size(), waitQueue.size(), incomingQueue.size(), stats.incomingMessagesRps, stats.sentMessagesRps, CoreCmd.commitLatency.get(), latency.get())); logger.info(String.format("[%s-%d] - leader=%d cterm=%d ci=%d latest=(%d,%d) votedFor=%d msgPool=%d/%d", gondola.getHostId(), memberId, leaderId, currentTerm, commitIndex, peer.prevoteGranted ? " prevote" : "", peer.backfilling ? String.format(" bf=%d, bfa=%d", peer.backfillToIndex, peer.backfillAhead) : "", peer.latency.get()));
latency.tail(mnIndex);
latency.tail(mnIndex);
gondola.getProcessId(), waitMs, commandQueue.size(), waitQueue.size(), incomingQueue.size(), stats.incomingMessagesRps, stats.sentMessagesRps, CoreCmd.commitLatency.get(), latency.get())); logger.info(String.format("[%s-%d] - leader=%d cterm=%d ci=%d latest=(%d,%d) votedFor=%d msgPool=%d/%d", gondola.getHostId(), memberId, leaderId, currentTerm, commitIndex,
/** * Sends the message to the remote member. This version of send * increases nextIndex and backfillToIndex. Does not send if the * connection to remote member is not operational or being * backfilled. */ public void send(Message message, int prevLogIndex) { assert message.getType() == Message.TYPE_APPEND_ENTRY_REQ; lock.lock(); try { if (backfilling) { // Increase the backfill index to the new value backfillToIndex = prevLogIndex + 2; } else if (channel.isOperational() && (message.isHeartbeat() || nextIndex == prevLogIndex + 1)) { latency.head(prevLogIndex + 1); addOutQueue(message); // Increment nextIndex for each command nextIndex += message.numCommands(); } } finally { lock.unlock(); } }
/** * Called as a result of incoming append entry reply messages. * Attempts to release as many waiting commands as possible. */ void updateWaitingCommands() throws Exception { int index = commitIndex; if (isLeader()) { // Commit CoreCmd ccmd = waitQueue.peek(); while (ccmd != null && ccmd.index <= index) { latency.tail(ccmd.index); ccmd.update(Command.STATUS_OK, leaderId); waitQueue.poll(); ccmd = waitQueue.peek(); } } // Update the getters saveQueue.getLatest(savedRid, false); index = Math.min(commitIndex, savedRid.index); // The min is needed for followers commitQueue.updateCommitIndex(index); }
/** * Called as a result of incoming append entry reply messages. Attempts to release as many waiting commands as * possible. */ void updateWaitingCommands() { int index = commitIndex; if (isLeader()) { // Commit CoreCmd ccmd = waitQueue.peek(); while (ccmd != null && ccmd.index <= index) { latency.tail(ccmd.index); ccmd.update(Command.STATUS_OK, leaderId); waitQueue.poll(); ccmd = waitQueue.peek(); } } // Update the getters saveQueue.getLatest(savedRid); index = Math.min(commitIndex, savedRid.index); // The min is needed for followers commitQueue.updateCommitIndex(index); }
/** * Sends the message to the remote member. * This version of send increases nextIndex and backfillToIndex. * Does not send if the connection to remote member is not operational or being backfilled. */ public void send(Message message, int prevLogIndex) { assert message.getType() == Message.TYPE_APPEND_ENTRY_REQ; lock.lock(); try { if (backfilling && backfillAhead < BACKFILL_AHEAD_LIMIT) { // Increase the backfill index to the new value backfillToIndex = prevLogIndex + 2; } else if (channel.isOperational() && (message.isHeartbeat() || nextIndex == prevLogIndex + 1)) { latency.head(prevLogIndex + 1); addOutQueue(message); // Increment nextIndex for each command nextIndex += message.numCommands(); } } finally { lock.unlock(); } }
/** * Sent after follower has advanced the savedIndex. */ public void sendAppendEntryReply() { Peer leader = peers.get(leaderId); if (leader != null) { Message message = pool.checkout(); try { saveQueue.getLatest(savedRid); message.appendEntryReply(memberId, currentTerm, savedRid.index, true, false); leader.send(message); latency.tail(savedRid.index); } finally { message.release(); } // Disable this for now because new nodes are not being connected while there is load //lastSentTs = clock.now(); } }
/** * Sent after follower has advanced the savedIndex. */ public void sendAppendEntryReply() throws Exception { Peer leader = peerMap.get(leaderId); if (leader != null) { Message message = pool.checkout(); try { saveQueue.getLatest(savedRid, false); message.appendEntryReply(memberId, currentTerm, savedRid.index, true, false); leader.send(message); latency.tail(savedRid.index); } finally { message.release(); } lastSentTs = clock.now(); } }
private String peerInfo(Peer peer, boolean isSlave) { return String.format( "[%s-%d] - %s=%d %s in=%.1f/s|%.1fB/s out=%d|" + "%.1f/s|%.1fB/s ni=%d mi=%d vf=(%d,%d)%s%s lat=%.3fms", gondola.getHostId(), memberId, isSlave ? "slave" : "peer", peer.peerId, peer.isOperational() ? "U" : "D", peer.inMessages.getRps(), peer.inBytes.getRps(), peer.outQueue.size(), peer.outMessages.getRps(), peer.outBytes.getRps(), peer.nextIndex, peer.matchIndex, peer.votedTerm, peer.votedFor, peer.prevoteGranted ? " prevote" : "", peer.backfilling ? String.format(" bf=%d, bfa=%d", peer.backfillToIndex, peer.backfillAhead) : "", peer.latency.get()); }