refactor: scheduler end and begin of piece (#1189)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
9d41cee1ec
commit
1939ceff8f
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue