diff --git a/supernode/daemon/mgr/gc/gc_task.go b/supernode/daemon/mgr/gc/gc_task.go index 67660f391..0b126a4b8 100644 --- a/supernode/daemon/mgr/gc/gc_task.go +++ b/supernode/daemon/mgr/gc/gc_task.go @@ -111,7 +111,7 @@ func (gcm *Manager) gcCIDsByTaskID(ctx context.Context, taskID string) { func (gcm *Manager) gcCDNByTaskID(ctx context.Context, taskID string, full bool) { if err := gcm.cdnMgr.Delete(ctx, taskID, full); err != nil { - logrus.Errorf("gc task: failed to gc cdn meta taskID(%s): %v", taskID, err) + logrus.Errorf("gc task: failed to gc cdn meta taskID(%s) full(%t): %v", taskID, full, err) } } diff --git a/supernode/server/0.3_bridge.go b/supernode/server/0.3_bridge.go index 04aff271c..28e225548 100644 --- a/supernode/server/0.3_bridge.go +++ b/supernode/server/0.3_bridge.go @@ -264,3 +264,45 @@ func (s *Server) reportServiceDown(ctx context.Context, rw http.ResponseWriter, Code: constants.CodeGetPeerDown, }) } + +func (s *Server) reportPieceError(ctx context.Context, rw http.ResponseWriter, req *http.Request) (err error) { + logrus.Warnf("get report piece error request %v", req) + + params := req.URL.Query() + taskID := params.Get("taskId") + pieceRange := params.Get("range") + srcCid := params.Get("srcCid") + dstCid := params.Get("dstCid") + dstIP := params.Get("dstIp") + realMd5 := params.Get("realMd5") + expectedMd5 := params.Get("expectedMd5") + errorType := params.Get("errorType") + + // get peerID according to the CID and taskID + dstDfgetTask, err := s.DfgetTaskMgr.Get(ctx, dstCid, taskID) + if err != nil { + return nil + } + + request := &types.PieceErrorRequest{ + DstIP: dstIP, + DstPid: dstDfgetTask.PeerID, + ErrorType: errorType, + Range: pieceRange, + ExpectedMd5: expectedMd5, + RealMd5: realMd5, + SrcCid: srcCid, + TaskID: taskID, + } + + if stringutils.IsEmptyStr(request.DstPid) { + return errors.Wrap(errortypes.ErrEmptyValue, "dstPid") + } + + if err := s.PieceErrorMgr.HandlePieceError(ctx, request); err != nil { + return err + } + + rw.WriteHeader(http.StatusOK) + return nil +} diff --git a/supernode/server/router.go b/supernode/server/router.go index e0e12a21f..0f770fed4 100644 --- a/supernode/server/router.go +++ b/supernode/server/router.go @@ -47,6 +47,7 @@ func initRoute(s *Server) *mux.Router { {Method: http.MethodGet, Path: "/peer/task", HandlerFunc: s.pullPieceTask}, {Method: http.MethodGet, Path: "/peer/piece/suc", HandlerFunc: s.reportPiece}, {Method: http.MethodGet, Path: "/peer/service/down", HandlerFunc: s.reportServiceDown}, + {Method: http.MethodGet, Path: "/peer/piece/error", HandlerFunc: s.reportPieceError}, // v1 // peer