XL total/free space calculation is done inside xl module (#2945)

master
Anis Elleuch 8 years ago committed by Harshavardhana
parent a681af6953
commit 334cdb5d64
  1. 10
      cmd/server-startup-msg.go
  2. 4
      cmd/server-startup-msg_test.go
  3. 4
      cmd/xl-v1.go

@ -133,13 +133,9 @@ func printObjectAPIMsg() {
// Get formatted disk/storage info message. // Get formatted disk/storage info message.
func getStorageInfoMsg(storageInfo StorageInfo) string { func getStorageInfoMsg(storageInfo StorageInfo) string {
freeSpace := uint64(storageInfo.Free) msg := fmt.Sprintf("%s %s Free, %s Total", colorBlue("Drive Capacity:"),
totalSpace := uint64(storageInfo.Total) humanize.IBytes(uint64(storageInfo.Free)),
if storageInfo.Backend.Type == XL { humanize.IBytes(uint64(storageInfo.Total)))
freeSpace /= 2
totalSpace /= 2
}
msg := fmt.Sprintf("%s %s Free, %s Total", colorBlue("Drive Capacity:"), humanize.IBytes(freeSpace), humanize.IBytes(totalSpace))
diskInfo := fmt.Sprintf(" %d Online, %d Offline. We can withstand [%d] more drive failure(s).", diskInfo := fmt.Sprintf(" %d Online, %d Offline. We can withstand [%d] more drive failure(s).",
storageInfo.Backend.OnlineDisks, storageInfo.Backend.OnlineDisks,
storageInfo.Backend.OfflineDisks, storageInfo.Backend.OfflineDisks,

@ -39,8 +39,8 @@ func TestStorageInfoMsg(t *testing.T) {
}{XL, 7, 1, 4, 5}, }{XL, 7, 1, 4, 5},
} }
if msg := getStorageInfoMsg(infoStorage); !strings.Contains(msg, "1.0 GiB Free, 5.0 GiB Total") || !strings.Contains(msg, "7 Online, 1 Offline") { if msg := getStorageInfoMsg(infoStorage); !strings.Contains(msg, "2.0 GiB Free, 10 GiB Total") || !strings.Contains(msg, "7 Online, 1 Offline") {
t.Fatal("Empty message string is not implemented", msg) t.Fatal("Unexpected storage info message, found:", msg)
} }
} }

@ -208,8 +208,8 @@ func getStorageInfo(disks []StorageAPI) StorageInfo {
// Free as the total aggregated values. Total capacity is always // Free as the total aggregated values. Total capacity is always
// the multiple of smallest disk among the disk list. // the multiple of smallest disk among the disk list.
storageInfo := StorageInfo{ storageInfo := StorageInfo{
Total: disksInfo[0].Total * int64(onlineDisks), Total: disksInfo[0].Total * int64(onlineDisks) / 2,
Free: disksInfo[0].Free * int64(onlineDisks), Free: disksInfo[0].Free * int64(onlineDisks) / 2,
} }
storageInfo.Backend.Type = XL storageInfo.Backend.Type = XL
storageInfo.Backend.OnlineDisks = onlineDisks storageInfo.Backend.OnlineDisks = onlineDisks

Loading…
Cancel
Save