NetperfHandler - perform mesh style network throughput test
(w http.ResponseWriter, r *http.Request)
| 1155 | |
| 1156 | // NetperfHandler - perform mesh style network throughput test |
| 1157 | func (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 |
| 1201 | func (a adminAPIHandlers) SpeedTestHandler(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected