Skip to content

Commit

Permalink
feat: dfdaemon report successful piece before end of piece
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi committed Jan 14, 2022
1 parent dd0df3f commit 5b6db0e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions client/daemon/peer/peertask_conductor.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ func (pt *peerTaskConductor) pullSinglePiece() {
}

if result, err := pt.pieceManager.DownloadPiece(ctx, request); err == nil {
pt.PublishPieceInfo(request.piece.PieceNum, request.piece.RangeSize)
pt.reportSuccessResult(request, result)
pt.PublishPieceInfo(request.piece.PieceNum, request.piece.RangeSize)

span.SetAttributes(config.AttributePieceSuccess.Bool(true))
span.End()
Expand Down Expand Up @@ -924,8 +924,8 @@ func (pt *peerTaskConductor) downloadPieceWorker(id int32, requests chan *Downlo
continue
} else {
// broadcast success piece
pt.PublishPieceInfo(request.piece.PieceNum, request.piece.RangeSize)
pt.reportSuccessResult(request, result)
pt.PublishPieceInfo(request.piece.PieceNum, request.piece.RangeSize)
}

span.SetAttributes(config.AttributePieceSuccess.Bool(true))
Expand Down
2 changes: 1 addition & 1 deletion scheduler/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ func (s *scheduler) filterParents(peer *resource.Peer, blocklist set.SafeSet) []
}

parents = append(parents, parent)
peer.Log.Infof("parent %s is selected", parent.ID)
return true
})

peer.Log.Infof("candidate parents include %#v", parents)
return parents
}

Expand Down
2 changes: 0 additions & 2 deletions scheduler/service/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ func (c *callback) PieceFail(ctx context.Context, peer *resource.Peer, piece *rp
// It’s not a case of back-to-source downloading failed,
// to help peer to reschedule the parent node
switch piece.Code {
case base.Code_ClientWaitPieceReady:
return
case base.Code_ClientPieceDownloadFail, base.Code_PeerTaskNotFound, base.Code_CDNError, base.Code_CDNTaskDownloadFail:
if err := parent.FSM.Event(resource.PeerEventDownloadFailed); err != nil {
peer.Log.Errorf("peer fsm event failed: %v", err)
Expand Down
9 changes: 8 additions & 1 deletion scheduler/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,15 @@ func (s *service) HandlePiece(ctx context.Context, peer *resource.Peer, piece *r
}
}

// Handle piece download failed
// Handle piece download code
if piece.Code != base.Code_Success {
// FIXME(244372610) When dfdaemon download peer return empty, retry later.
if piece.Code == base.Code_ClientWaitPieceReady {
peer.Log.Infof("receive piece code %d and wait for dfdaemon piece ready", piece.Code)
return
}

// Handle piece download failed
peer.Log.Errorf("receive failed piece: %#v %#v", piece, piece.PieceInfo)
s.callback.PieceFail(ctx, peer, piece)
return
Expand Down

0 comments on commit 5b6db0e

Please sign in to comment.