MCPcopy Create free account
hub / github.com/AbelChe/evil_minio / NetperfHandler

Method NetperfHandler

cmd/admin-handlers.go:1157–1198  ·  view source on GitHub ↗

NetperfHandler - perform mesh style network throughput test

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

Source from the content-addressed store, hash-verified

1155
1156// NetperfHandler - perform mesh style network throughput test
1157func (a adminAPIHandlers) NetperfHandler(w http.ResponseWriter, r *http.Request) {
1158 ctx := newContext(r, w, "NetperfHandler")
1159
1160 defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
1161
1162 objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.HealthInfoAdminAction)
1163 if objectAPI == nil {
1164 return
1165 }
1166
1167 if !globalIsDistErasure {
1168 writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrNotImplemented), r.URL)
1169 return
1170 }
1171
1172 nsLock := objectAPI.NewNSLock(minioMetaBucket, "netperf")
1173 lkctx, err := nsLock.GetLock(ctx, globalOperationTimeout)
1174 if err != nil {
1175 writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(toAPIErrorCode(ctx, err)), r.URL)
1176 return
1177 }
1178 defer nsLock.Unlock(lkctx)
1179
1180 durationStr := r.Form.Get(peerRESTDuration)
1181 duration, err := time.ParseDuration(durationStr)
1182 if err != nil {
1183 duration = globalNetPerfMinDuration
1184 }
1185
1186 if duration < globalNetPerfMinDuration {
1187 // We need sample size of minimum 10 secs.
1188 duration = globalNetPerfMinDuration
1189 }
1190
1191 duration = duration.Round(time.Second)
1192
1193 results := globalNotificationSys.Netperf(ctx, duration)
1194 enc := json.NewEncoder(w)
1195 if err := enc.Encode(madmin.NetperfResult{NodeResults: results}); err != nil {
1196 return
1197 }
1198}
1199
1200// SpeedtestHandler - Deprecated. See ObjectSpeedTestHandler
1201func (a adminAPIHandlers) SpeedTestHandler(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 13

AuditLogFunction · 0.92
newContextFunction · 0.85
mustGetClaimsFromTokenFunction · 0.85
validateAdminReqFunction · 0.85
writeErrorResponseJSONFunction · 0.85
toAPIErrorCodeFunction · 0.85
ToAPIErrMethod · 0.80
EncodeMethod · 0.80
NewNSLockMethod · 0.65
GetLockMethod · 0.65
UnlockMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected