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

Function proxyMetricsSortHandler

dsort/handler.go:186–227  ·  view source on GitHub ↗

GET /v1/sort?id=...

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

Source from the content-addressed store, hash-verified

184
185// GET /v1/sort?id=...
186func proxyMetricsSortHandler(w http.ResponseWriter, r *http.Request) {
187 var (
188 smap = ctx.smapOwner.Get()
189 query = r.URL.Query()
190 managerUUID = query.Get(apc.QparamUUID)
191 path = apc.URLPathdSortMetrics.Join(managerUUID)
192 responses = broadcastTargets(http.MethodGet, path, nil, nil, smap)
193 )
194
195 notFound := 0
196 allMetrics := make(map[string]*Metrics, smap.CountActiveTargets())
197 for _, resp := range responses {
198 if resp.statusCode == http.StatusNotFound {
199 // Probably new target which does not know anything about this dsort op.
200 notFound++
201 continue
202 }
203 if resp.err != nil {
204 cmn.WriteErr(w, r, resp.err, resp.statusCode)
205 return
206 }
207 metrics := &Metrics{}
208 if err := js.Unmarshal(resp.res, &metrics); err != nil {
209 cmn.WriteErr(w, r, err, http.StatusInternalServerError)
210 return
211 }
212 allMetrics[resp.si.ID()] = metrics
213 }
214
215 if notFound == len(responses) && notFound > 0 {
216 msg := fmt.Sprintf("%s job %q not found", DSortName, managerUUID)
217 cmn.WriteErrMsg(w, r, msg, http.StatusNotFound)
218 return
219 }
220
221 body, err := js.Marshal(allMetrics)
222 if err != nil {
223 cmn.WriteErr(w, r, err, http.StatusInternalServerError)
224 return
225 }
226 w.Write(body)
227}
228
229// DELETE /v1/sort/abort
230func ProxyAbortSortHandler(w http.ResponseWriter, r *http.Request) {

Callers 1

ProxyGetHandlerFunction · 0.85

Calls 9

WriteErrFunction · 0.92
WriteErrMsgFunction · 0.92
broadcastTargetsFunction · 0.85
JoinMethod · 0.80
CountActiveTargetsMethod · 0.80
MarshalMethod · 0.80
GetMethod · 0.65
IDMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected