Skip to content

Commit aad463d

Browse files
authored
transfer a method sendProbeRequest. (#651)
1 parent 43f38b4 commit aad463d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

jraft-core/src/main/java/com/alipay/sofa/jraft/core/Replicator.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ public static ThreadId start(final ReplicatorOptions opts, final RaftOptions raf
905905
r.lastRpcSendTimestamp = Utils.monotonicMs();
906906
r.startHeartbeatTimer(Utils.nowMs());
907907
// id.unlock in sendEmptyEntries
908-
r.sendEmptyEntries(false);
908+
r.sendProbeRequest();
909909
return r.id;
910910
}
911911

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

@@ -1221,7 +1221,7 @@ static void onHeartbeatReturned(final ThreadId id, final Status status, final Ap
12211221
}
12221222
LOG.warn("Heartbeat to peer {} failure, try to send a probe request.", r.options.getPeerId());
12231223
doUnlock = false;
1224-
r.sendEmptyEntries(false);
1224+
r.sendProbeRequest();
12251225
r.startHeartbeatTimer(startTimeMs);
12261226
return;
12271227
}
@@ -1267,7 +1267,7 @@ static void onRpcReturned(final ThreadId id, final RequestType reqType, final St
12671267
holdingQueue.size(), r.options.getPeerId(), r.raftOptions.getMaxReplicatorInflightMsgs());
12681268
r.resetInflights();
12691269
r.setState(State.Probe);
1270-
r.sendEmptyEntries(false);
1270+
r.sendProbeRequest();
12711271
return;
12721272
}
12731273

@@ -1383,7 +1383,7 @@ private static boolean onAppendEntriesReturned(final ThreadId id, final Inflight
13831383
r.resetInflights();
13841384
r.setState(State.Probe);
13851385
// unlock id in sendEmptyEntries
1386-
r.sendEmptyEntries(false);
1386+
r.sendProbeRequest();
13871387
return false;
13881388
}
13891389
// record metrics
@@ -1475,7 +1475,7 @@ private static boolean onAppendEntriesReturned(final ThreadId id, final Inflight
14751475
}
14761476
}
14771477
// dummy_id is unlock in _send_heartbeat
1478-
r.sendEmptyEntries(false);
1478+
r.sendProbeRequest();
14791479
return false;
14801480
}
14811481
if (isLogDebugEnabled) {
@@ -1692,6 +1692,10 @@ private static void sendHeartbeat(final ThreadId id) {
16921692
r.sendEmptyEntries(true);
16931693
}
16941694

1695+
private void sendProbeRequest() {
1696+
sendEmptyEntries(false);
1697+
}
1698+
16951699
@SuppressWarnings("SameParameterValue")
16961700
private void sendTimeoutNow(final boolean unlockId, final boolean stopAfterFinish) {
16971701
sendTimeoutNow(unlockId, stopAfterFinish, -1);

0 commit comments

Comments
 (0)