diff --git a/client/daemon/peer/peertask_conductor.go b/client/daemon/peer/peertask_conductor.go index 09c5741eb4a..2bf970c17c2 100644 --- a/client/daemon/peer/peertask_conductor.go +++ b/client/daemon/peer/peertask_conductor.go @@ -1315,7 +1315,7 @@ func (pt *peerTaskConductor) done() { // send EOF piece result to scheduler err := pt.peerPacketStream.Send( - scheduler.NewEndPieceResult(pt.taskID, pt.peerID, pt.readyPieces.Settled())) + schedulerclient.NewEndOfPiece(pt.taskID, pt.peerID, pt.readyPieces.Settled())) pt.Debugf("end piece result sent: %v, peer task finished", err) err = pt.schedulerClient.ReportPeerResult( @@ -1362,7 +1362,7 @@ func (pt *peerTaskConductor) fail() { // send EOF piece result to scheduler err := pt.peerPacketStream.Send( - scheduler.NewEndPieceResult(pt.taskID, pt.peerID, pt.readyPieces.Settled())) + schedulerclient.NewEndOfPiece(pt.taskID, pt.peerID, pt.readyPieces.Settled())) pt.Debugf("end piece result sent: %v, peer task finished", err) ctx := trace.ContextWithSpan(context.Background(), trace.SpanFromContext(pt.ctx)) diff --git a/pkg/rpc/scheduler/client/client.go b/pkg/rpc/scheduler/client/client.go index 96e0f51d5a3..6e015b788d1 100644 --- a/pkg/rpc/scheduler/client/client.go +++ b/pkg/rpc/scheduler/client/client.go @@ -158,7 +158,7 @@ func (sc *schedulerClient) ReportPieceResult(ctx context.Context, taskID string, logger.With("peerId", ptr.PeerId, "errMsg", err).Infof("start to report piece result for taskID: %s", taskID) // trigger scheduling - return pps, pps.Send(scheduler.NewZeroPieceResult(taskID, ptr.PeerId)) + return pps, pps.Send(NewBeginOfPiece(taskID, ptr.PeerId)) } func (sc *schedulerClient) ReportPeerResult(ctx context.Context, pr *scheduler.PeerResult, opts ...grpc.CallOption) error { diff --git a/pkg/rpc/scheduler/scheduler.go b/pkg/rpc/scheduler/client/piece.go similarity index 65% rename from pkg/rpc/scheduler/scheduler.go rename to pkg/rpc/scheduler/client/piece.go index eda94ac2aa0..a956953ec94 100644 --- a/pkg/rpc/scheduler/scheduler.go +++ b/pkg/rpc/scheduler/client/piece.go @@ -14,40 +14,31 @@ * limitations under the License. */ -package scheduler +package client import ( "d7y.io/dragonfly/v2/pkg/rpc/base" "d7y.io/dragonfly/v2/pkg/rpc/base/common" + "d7y.io/dragonfly/v2/pkg/rpc/scheduler" ) -func NewZeroPieceResult(taskID, peerID string) *PieceResult { - return &PieceResult{ +func NewBeginOfPiece(taskID, peerID string) *scheduler.PieceResult { + return &scheduler.PieceResult{ TaskId: taskID, SrcPid: peerID, PieceInfo: &base.PieceInfo{ - PieceNum: common.BeginOfPiece, - RangeStart: 0, - RangeSize: 0, - PieceMd5: "", - PieceOffset: 0, - PieceStyle: 0, + PieceNum: common.BeginOfPiece, }, } } -func NewEndPieceResult(taskID, peerID string, finishedCount int32) *PieceResult { - return &PieceResult{ +func NewEndOfPiece(taskID, peerID string, finishedCount int32) *scheduler.PieceResult { + return &scheduler.PieceResult{ TaskId: taskID, SrcPid: peerID, FinishedCount: finishedCount, PieceInfo: &base.PieceInfo{ - PieceNum: common.EndOfPiece, - RangeStart: 0, - RangeSize: 0, - PieceMd5: "", - PieceOffset: 0, - PieceStyle: 0, + PieceNum: common.EndOfPiece, }, } }