Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
feature: add error handling for dfget
Browse files Browse the repository at this point in the history
Signed-off-by: Starnop <[email protected]>
  • Loading branch information
starnop committed Oct 24, 2019
1 parent 6bc6db4 commit 856dbb9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion supernode/daemon/mgr/gc/gc_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
42 changes: 42 additions & 0 deletions supernode/server/0.3_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions supernode/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 856dbb9

Please sign in to comment.