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)
| 587 | // A valid DELETE to this endpoint aborts currently running sort job and cleans |
| 588 | // up the state. |
| 589 | func 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 | |
| 614 | func removeSortHandler(w http.ResponseWriter, r *http.Request) { |
| 615 | if !checkHTTPMethod(w, r, http.MethodDelete) { |
no test coverage detected