Peer.initConfig(config); messagePool = new MessagePool(config, stats);
/** * Decrement the reference count. When the reference count reaches 0, it is returned to the pool. */ public void release() { int n = refCount.decrementAndGet(); if (n == 0) { tracingInfo = null; pool.checkin(this); } assert n >= 0 : String.format("Message is over-released: type=%d from=%d", getType(), getFromMemberId()); }
/** * @param rid non-null object containing the leader's latest term and index. */ public void sendHeartbeatRequest(Rid rid) { Message message = pool.checkout(); try { message.heartbeat(memberId, currentTerm, rid, commitIndex); peers.forEach(p -> p.send(message, rid.index - 1)); } finally { message.release(); } lastSentTs = clock.now(); }
gondola.getHostId(), memberId, leaderId, currentTerm, commitIndex, sentRid.term, sentRid.index, votedFor, pool.size(), pool.createdCount)); logger.info(String.format("[%s-%d] - storage %.1f/s ti=(%d,%d) saveQ=%d gap=%d done=%d", gondola.getHostId(), memberId,
gondola.getHostId(), memberId, leaderId, currentTerm, commitIndex, sentRid.term, sentRid.index, votedFor, pool.size(), pool.createdCount)); logger.info(String.format("[%s-%d] - storage %.1f/s ti=(%d,%d) saveQ=%d gap=%d done=%d", gondola.getHostId(), memberId,
public void run() { while (true) { Message message = pool.checkout(); try { CoreCmd ccmd = commandQueue.take();
/** * Decrement the reference count. When the reference count reaches 0, it is returned to the pool. */ public void release() { int n = refCount.decrementAndGet(); if (n == 0) { tracingInfo = null; pool.checkin(this); } assert n >= 0 : String.format("Message is over-released: type=%d from=%d", getType(), getFromMemberId()); }
/** * @param hostId the non-null id of the current host on which to start Gondola. */ public Gondola(Config config, String hostId) throws GondolaException { this.config = config; this.hostId = hostId; try { // Initialize static config values CoreCmd.initConfig(config); Message.initConfig(config); Peer.initConfig(config); ExceptionLogger.initConfig(config); messagePool = new MessagePool(config, stats); init(); } catch (Exception e) { throw new GondolaException(e); } }
public void run() { while (true) { Message message = pool.checkout(); try { CoreCmd ccmd = commandQueue.take();
/** * @param rid non-null object containing the leader's latest term and index. */ public void sendHeartbeatRequest(Rid rid) { Message message = pool.checkout(); try { message.heartbeat(memberId, currentTerm, rid, commitIndex); peers.forEach((id, p) -> p.send(message, rid.index - 1)); // Send to peers but also check if peer has been inactive long now = clock.now(); for (Iterator<Peer> it = slaves.iterator(); it.hasNext(); ) { Peer slave = it.next(); if (now - slave.getLastReceivedTs() > slaveInactivityTimeout) { // Slave is inactive so stop and remove it logger.info("[{}-{}] Removing slave {} because of inactivity for {}ms", gondola.getHostId(), memberId, slave.peerId, slaveInactivityTimeout); slave.stop(); it.remove(); } slave.send(message, rid.index - 1); } } finally { message.release(); } lastSentTs = clock.now(); }
/** * 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(); } }
Message message = pool.checkout(); try {
/** * 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(); } }
Message message = pool.checkout(); try {
void handleCommand(CoreCmd ccmd) throws Exception { if (isLeader()) { Message message = pool.checkout(); try { int prevLogIndex = sentRid.index;
void handleCommand(CoreCmd ccmd) { if (isLeader()) { Message message = pool.checkout(); try { int prevLogIndex = sentRid.index;