mirror of
https://github.com/minio/minio.git
synced 2025-11-28 13:09:09 -05:00
fix: remove unusued PerfInfoHandler code (#9328)
- Removes PerfInfo admin API as its not OBDInfo - Keep the drive path without the metaBucket in OBD global latency map. - Remove all the unused code related to PerfInfo API - Do not redefined global mib,gib constants use humanize.MiByte and humanize.GiByte instead always
This commit is contained in:
@@ -20,25 +20,10 @@ package madmin
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/minio/minio/pkg/cpu"
|
||||
"github.com/minio/minio/pkg/disk"
|
||||
"github.com/minio/minio/pkg/mem"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultNetPerfSize - default payload size used for network performance.
|
||||
DefaultNetPerfSize = 100 * humanize.MiByte
|
||||
// DefaultDrivePerfSize - default file size for testing drive performance
|
||||
DefaultDrivePerfSize = 100 * humanize.MiByte
|
||||
)
|
||||
|
||||
// BackendType - represents different backend types.
|
||||
@@ -251,200 +236,6 @@ func (adm *AdminClient) AccountingUsageInfo(ctx context.Context) (map[string]Buc
|
||||
return accountingUsageInfo, nil
|
||||
}
|
||||
|
||||
// ServerDrivesPerfInfo holds informantion about address and write speed of
|
||||
// all drives in a single server node
|
||||
type ServerDrivesPerfInfo struct {
|
||||
Addr string `json:"addr"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Perf []disk.Performance `json:"perf"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// ServerDrivesPerfInfo - Returns drive's read and write performance information
|
||||
func (adm *AdminClient) ServerDrivesPerfInfo(ctx context.Context, size int64) ([]ServerDrivesPerfInfo, error) {
|
||||
v := url.Values{}
|
||||
v.Set("perfType", string("drive"))
|
||||
|
||||
v.Set("size", strconv.FormatInt(size, 10))
|
||||
|
||||
resp, err := adm.executeMethod(ctx, http.MethodGet,
|
||||
requestData{
|
||||
relPath: adminAPIPrefix + "/performance",
|
||||
queryValues: v,
|
||||
},
|
||||
)
|
||||
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Check response http status code
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, httpRespToErrorResponse(resp)
|
||||
}
|
||||
|
||||
// Unmarshal the server's json response
|
||||
var info []ServerDrivesPerfInfo
|
||||
|
||||
respBytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(respBytes, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
// ServerCPULoadInfo holds information about address and cpu load of
|
||||
// a single server node
|
||||
type ServerCPULoadInfo struct {
|
||||
Addr string `json:"addr"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Load []cpu.Load `json:"load"`
|
||||
HistoricLoad []cpu.Load `json:"historicLoad"`
|
||||
}
|
||||
|
||||
// ServerCPULoadInfo - Returns cpu utilization information
|
||||
func (adm *AdminClient) ServerCPULoadInfo(ctx context.Context) ([]ServerCPULoadInfo, error) {
|
||||
v := url.Values{}
|
||||
v.Set("perfType", string("cpu"))
|
||||
resp, err := adm.executeMethod(ctx,
|
||||
http.MethodGet, requestData{
|
||||
relPath: adminAPIPrefix + "/performance",
|
||||
queryValues: v,
|
||||
},
|
||||
)
|
||||
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Check response http status code
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, httpRespToErrorResponse(resp)
|
||||
}
|
||||
|
||||
// Unmarshal the server's json response
|
||||
var info []ServerCPULoadInfo
|
||||
|
||||
respBytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(respBytes, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
// ServerMemUsageInfo holds information about address and memory utilization of
|
||||
// a single server node
|
||||
type ServerMemUsageInfo struct {
|
||||
Addr string `json:"addr"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Usage []mem.Usage `json:"usage"`
|
||||
HistoricUsage []mem.Usage `json:"historicUsage"`
|
||||
}
|
||||
|
||||
// ServerMemUsageInfo - Returns mem utilization information
|
||||
func (adm *AdminClient) ServerMemUsageInfo(ctx context.Context) ([]ServerMemUsageInfo, error) {
|
||||
v := url.Values{}
|
||||
v.Set("perfType", string("mem"))
|
||||
resp, err := adm.executeMethod(ctx,
|
||||
http.MethodGet,
|
||||
requestData{
|
||||
relPath: adminAPIPrefix + "/performance",
|
||||
queryValues: v,
|
||||
},
|
||||
)
|
||||
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Check response http status code
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, httpRespToErrorResponse(resp)
|
||||
}
|
||||
|
||||
// Unmarshal the server's json response
|
||||
var info []ServerMemUsageInfo
|
||||
|
||||
respBytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(respBytes, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
// NetPerfInfo network performance information.
|
||||
type NetPerfInfo struct {
|
||||
Addr string `json:"addr"`
|
||||
ReadThroughput uint64 `json:"readThroughput"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// NetPerfInfo - Returns network performance information of all cluster nodes.
|
||||
func (adm *AdminClient) NetPerfInfo(ctx context.Context, size int) (map[string][]NetPerfInfo, error) {
|
||||
v := url.Values{}
|
||||
v.Set("perfType", "net")
|
||||
if size > 0 {
|
||||
v.Set("size", strconv.Itoa(size))
|
||||
}
|
||||
resp, err := adm.executeMethod(ctx,
|
||||
http.MethodGet,
|
||||
requestData{
|
||||
relPath: adminAPIPrefix + "/performance",
|
||||
queryValues: v,
|
||||
},
|
||||
)
|
||||
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Check response http status code
|
||||
if resp.StatusCode == http.StatusMethodNotAllowed {
|
||||
return nil, errors.New("NetPerfInfo is meant for multi-node MinIO deployments")
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, httpRespToErrorResponse(resp)
|
||||
}
|
||||
|
||||
// Unmarshal the server's json response
|
||||
info := map[string][]NetPerfInfo{}
|
||||
|
||||
respBytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(respBytes, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
// InfoMessage container to hold server admin related information.
|
||||
type InfoMessage struct {
|
||||
Mode string `json:"mode,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user