Fix: [scheduler] destPeer keepalive when downloaded by other peer (#1865)

Signed-off-by: bigerous <cuidajun.cdj@alibaba-inc.com>
This commit is contained in:
cuidajun 2022-11-24 18:08:28 +08:00 committed by Gaius
parent 3af4cc7a0f
commit 51683c2fd9
No known key found for this signature in database
GPG Key ID: 8B4E5D1290FA2FFB
1 changed files with 8 additions and 1 deletions

View File

@ -234,9 +234,11 @@ func (s *Service) ReportPieceResult(stream schedulerv1.Scheduler_ReportPieceResu
if parent, loaded := s.resource.PeerManager().Load(piece.DstPid); loaded {
metrics.PeerHostTraffic.WithLabelValues(peer.Tag, peer.Application, metrics.PeerHostTrafficUploadType, parent.Host.ID, parent.Host.IP).Add(float64(piece.PieceInfo.RangeSize))
} else {
if piece.DstPid != "" { // not backSource piece
peer.Log.Warnf("dst peer %s not found for piece %#v %#v", piece.DstPid, piece, piece.PieceInfo)
}
}
}
// Collect traffic metrics.
if piece.DstPid != "" {
@ -748,6 +750,11 @@ func (s *Service) handlePieceSuccess(ctx context.Context, peer *resource.Peer, p
// peer.UpdateAt needs to be updated to prevent
// the peer from being GC during the download process.
peer.UpdateAt.Store(time.Now())
if piece.DstPid != "" {
if destPeer, ok := s.resource.PeerManager().Load(piece.DstPid); ok {
destPeer.UpdateAt.Store(time.Now())
}
}
// When the peer downloads back-to-source,
// piece downloads successfully updates the task piece info.