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

Function initSortHandler

dsort/handler.go:365–396  ·  view source on GitHub ↗

initSortHandler is the handler called for the HTTP endpoint /v1/sort/init. It is responsible for initializing the dSort manager so it will be ready to start receiving requests.

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

Source from the content-addressed store, hash-verified

363// It is responsible for initializing the dSort manager so it will be ready
364// to start receiving requests.
365func initSortHandler(w http.ResponseWriter, r *http.Request) {
366 if !checkHTTPMethod(w, r, http.MethodPost) {
367 return
368 }
369 apiItems, err := checkRESTItems(w, r, 1, apc.URLPathdSortInit.L)
370 if err != nil {
371 return
372 }
373 var rs *ParsedRequestSpec
374 b, err := io.ReadAll(r.Body)
375 if err != nil {
376 cmn.WriteErr(w, r, fmt.Errorf("could not read request body, err: %w", err))
377 return
378 }
379 if err = js.Unmarshal(b, &rs); err != nil {
380 err := fmt.Errorf(cmn.FmtErrUnmarshal, DSortName, "ParsedRequestSpec", cos.BHead(b), err)
381 cmn.WriteErr(w, r, err)
382 return
383 }
384
385 managerUUID := apiItems[0]
386 dsortManager, err := Managers.Add(managerUUID)
387 if err != nil {
388 cmn.WriteErr(w, r, err)
389 return
390 }
391 defer dsortManager.unlock()
392 if err = dsortManager.init(rs); err != nil {
393 cmn.WriteErr(w, r, err)
394 return
395 }
396}
397
398// startSortHandler is the handler called for the HTTP endpoint /v1/sort/start.
399// There are three major phases to this function:

Callers 1

SortHandlerFunction · 0.85

Calls 8

WriteErrFunction · 0.92
BHeadFunction · 0.92
checkHTTPMethodFunction · 0.85
ReadAllMethod · 0.80
checkRESTItemsFunction · 0.70
AddMethod · 0.65
initMethod · 0.65
unlockMethod · 0.45

Tested by

no test coverage detected