rafthttp: log health checking error early

This commit is contained in:
Xiang Li 2016-07-31 18:24:17 -07:00
parent 5a83f05e96
commit 9311d7b77e

View File

@ -25,6 +25,7 @@ var (
// Or the connection will time-out.
proberInterval = ConnReadTimeout - time.Second
statusMonitoringInterval = 30 * time.Second
statusErrorInterval = 5 * time.Second
)
func addPeerToProber(p probing.Prober, id string, us []string) {
@ -44,11 +45,16 @@ func addPeerToProber(p probing.Prober, id string, us []string) {
}
func monitorProbingStatus(s probing.Status, id string) {
// set the first interval short to log error early.
interval := statusErrorInterval
for {
select {
case <-time.After(statusMonitoringInterval):
case <-time.After(interval):
if !s.Health() {
plog.Warningf("health check for peer %s could not connect", id)
plog.Warningf("health check for peer %s could not connect: %v", id, s.Err())
interval = statusErrorInterval
} else {
interval = statusMonitoringInterval
}
if s.ClockDiff() > time.Second {
plog.Warningf("the clock difference against peer %s is too high [%v > %v]", id, s.ClockDiff(), time.Second)