2021-01-19 05:35:38 +01:00
|
|
|
/*
|
|
|
|
* MinIO Cloud Storage, (C) 2020 MinIO, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2021-02-04 21:26:58 +01:00
|
|
|
"github.com/minio/minio/pkg/madmin"
|
2021-01-19 05:35:38 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// GetTotalCapacity gets the total capacity in the cluster.
|
2021-02-04 21:26:58 +01:00
|
|
|
func GetTotalCapacity(diskInfo []madmin.Disk) (capacity uint64) {
|
|
|
|
|
|
|
|
for _, disk := range diskInfo {
|
|
|
|
capacity += disk.TotalSpace
|
2021-01-19 05:35:38 +01:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetTotalUsableCapacity gets the total usable capacity in the cluster.
|
2021-01-22 21:09:24 +01:00
|
|
|
// This value is not an accurate representation of total usable in a multi-tenant deployment.
|
2021-02-04 21:26:58 +01:00
|
|
|
func GetTotalUsableCapacity(diskInfo []madmin.Disk, s StorageInfo) (capacity float64) {
|
|
|
|
raw := GetTotalCapacity(diskInfo)
|
2021-01-22 21:09:24 +01:00
|
|
|
var approxDataBlocks float64
|
|
|
|
var actualDisks float64
|
|
|
|
for _, scData := range s.Backend.StandardSCData {
|
|
|
|
approxDataBlocks += float64(scData)
|
|
|
|
actualDisks += float64(scData + s.Backend.StandardSCParity)
|
|
|
|
}
|
|
|
|
ratio := approxDataBlocks / actualDisks
|
2021-01-19 05:35:38 +01:00
|
|
|
return float64(raw) * ratio
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetTotalCapacityFree gets the total capacity free in the cluster.
|
2021-02-04 21:26:58 +01:00
|
|
|
func GetTotalCapacityFree(diskInfo []madmin.Disk) (capacity uint64) {
|
|
|
|
for _, d := range diskInfo {
|
|
|
|
capacity += d.AvailableSpace
|
2021-01-19 05:35:38 +01:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetTotalUsableCapacityFree gets the total usable capacity free in the cluster.
|
2021-01-22 21:09:24 +01:00
|
|
|
// This value is not an accurate representation of total free in a multi-tenant deployment.
|
2021-02-04 21:26:58 +01:00
|
|
|
func GetTotalUsableCapacityFree(diskInfo []madmin.Disk, s StorageInfo) (capacity float64) {
|
|
|
|
raw := GetTotalCapacityFree(diskInfo)
|
2021-01-22 21:09:24 +01:00
|
|
|
var approxDataBlocks float64
|
|
|
|
var actualDisks float64
|
|
|
|
for _, scData := range s.Backend.StandardSCData {
|
|
|
|
approxDataBlocks += float64(scData)
|
|
|
|
actualDisks += float64(scData + s.Backend.StandardSCParity)
|
|
|
|
}
|
|
|
|
ratio := approxDataBlocks / actualDisks
|
2021-01-19 05:35:38 +01:00
|
|
|
return float64(raw) * ratio
|
|
|
|
}
|