Skip to content

Commit

Permalink
transfer a method sendProbeRequest. (sofastack#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
horizonzy authored Aug 6, 2021
1 parent 43f38b4 commit aad463d
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ public static ThreadId start(final ReplicatorOptions opts, final RaftOptions raf
r.lastRpcSendTimestamp = Utils.monotonicMs();
r.startHeartbeatTimer(Utils.nowMs());
// id.unlock in sendEmptyEntries
r.sendEmptyEntries(false);
r.sendProbeRequest();
return r.id;
}

Expand Down Expand Up @@ -989,7 +989,7 @@ static boolean continueSending(final ThreadId id, final int errCode) {
// _next_index otherwise the replicator is likely waits in executor.shutdown();
// _wait_more_entries and no further logs would be replicated even if the
// last_index of this followers is less than |next_index - 1|
r.sendEmptyEntries(false);
r.sendProbeRequest();
} else if (errCode != RaftError.ESTOP.getNumber()) {
// id is unlock in _send_entries
r.sendEntries();
Expand Down Expand Up @@ -1026,7 +1026,7 @@ void block(final long startTimeMs, @SuppressWarnings("unused") final int errorCo
this.blockTimer = null;
LOG.error("Fail to add timer", e);
// id unlock in sendEmptyEntries.
sendEmptyEntries(false);
sendProbeRequest();
}
}

Expand Down Expand Up @@ -1221,7 +1221,7 @@ static void onHeartbeatReturned(final ThreadId id, final Status status, final Ap
}
LOG.warn("Heartbeat to peer {} failure, try to send a probe request.", r.options.getPeerId());
doUnlock = false;
r.sendEmptyEntries(false);
r.sendProbeRequest();
r.startHeartbeatTimer(startTimeMs);
return;
}
Expand Down Expand Up @@ -1267,7 +1267,7 @@ static void onRpcReturned(final ThreadId id, final RequestType reqType, final St
holdingQueue.size(), r.options.getPeerId(), r.raftOptions.getMaxReplicatorInflightMsgs());
r.resetInflights();
r.setState(State.Probe);
r.sendEmptyEntries(false);
r.sendProbeRequest();
return;
}

Expand Down Expand Up @@ -1383,7 +1383,7 @@ private static boolean onAppendEntriesReturned(final ThreadId id, final Inflight
r.resetInflights();
r.setState(State.Probe);
// unlock id in sendEmptyEntries
r.sendEmptyEntries(false);
r.sendProbeRequest();
return false;
}
// record metrics
Expand Down Expand Up @@ -1475,7 +1475,7 @@ private static boolean onAppendEntriesReturned(final ThreadId id, final Inflight
}
}
// dummy_id is unlock in _send_heartbeat
r.sendEmptyEntries(false);
r.sendProbeRequest();
return false;
}
if (isLogDebugEnabled) {
Expand Down Expand Up @@ -1692,6 +1692,10 @@ private static void sendHeartbeat(final ThreadId id) {
r.sendEmptyEntries(true);
}

private void sendProbeRequest() {
sendEmptyEntries(false);
}

@SuppressWarnings("SameParameterValue")
private void sendTimeoutNow(final boolean unlockId, final boolean stopAfterFinish) {
sendTimeoutNow(unlockId, stopAfterFinish, -1);
Expand Down

0 comments on commit aad463d

Please sign in to comment.