MCPcopy
hub / github.com/NVIDIA/aistore / abortSortHandler

Function abortSortHandler

dsort/handler.go:589–612  ·  view source on GitHub ↗

abortSortHandler is the handler called for the HTTP endpoint /v1/sort/abort. A valid DELETE to this endpoint aborts currently running sort job and cleans up the state.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

587// A valid DELETE to this endpoint aborts currently running sort job and cleans
588// up the state.
589func abortSortHandler(w http.ResponseWriter, r *http.Request) {
590 if !checkHTTPMethod(w, r, http.MethodDelete) {
591 return
592 }
593 apiItems, err := checkRESTItems(w, r, 1, apc.URLPathdSortAbort.L)
594 if err != nil {
595 return
596 }
597
598 managerUUID := apiItems[0]
599 dsortManager, exists := Managers.Get(managerUUID, true /*allowPersisted*/)
600 if !exists {
601 s := fmt.Sprintf("invalid request: job %q does not exist", managerUUID)
602 cmn.WriteErrMsg(w, r, s, http.StatusNotFound)
603 return
604 }
605 if dsortManager.Metrics.Archived.Load() {
606 s := fmt.Sprintf("invalid request: %s job %q has already finished", DSortName, managerUUID)
607 cmn.WriteErrMsg(w, r, s, http.StatusGone)
608 return
609 }
610
611 dsortManager.abort(fmt.Errorf("%s has been aborted via API (remotely)", DSortName))
612}
613
614func removeSortHandler(w http.ResponseWriter, r *http.Request) {
615 if !checkHTTPMethod(w, r, http.MethodDelete) {

Callers 1

SortHandlerFunction · 0.85

Calls 6

WriteErrMsgFunction · 0.92
checkHTTPMethodFunction · 0.85
checkRESTItemsFunction · 0.70
GetMethod · 0.65
abortMethod · 0.65
LoadMethod · 0.45

Tested by

no test coverage detected