add Volume Ids column only for max 100 volumes for convenience in the master ui.

This commit is contained in:
bingoohuang
2020-05-29 15:37:58 +08:00
parent b4e93b639d
commit 1a642b9876
4 changed files with 77 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package topology
import (
"fmt"
"github.com/chrislusf/seaweedfs/weed/util"
"strconv"
"sync"
@@ -166,6 +167,7 @@ func (dn *DataNode) ToMap() interface{} {
ret := make(map[string]interface{})
ret["Url"] = dn.Url()
ret["Volumes"] = dn.GetVolumeCount()
ret["VolumeIds"] = dn.GetVolumeIds()
ret["EcShards"] = dn.GetEcShardCount()
ret["Max"] = dn.GetMaxVolumeCount()
ret["Free"] = dn.FreeSpace()
@@ -190,3 +192,19 @@ func (dn *DataNode) ToDataNodeInfo() *master_pb.DataNodeInfo {
}
return m
}
// GetVolumeIds returns the human readable volume ids limited to count of max 100.
func (dn *DataNode) GetVolumeIds() string {
volumesLen := len(dn.volumes)
if volumesLen > 100 {
return "..."
}
ids := make([]int, 0, volumesLen)
for k := range dn.volumes {
ids = append(ids, int(k))
}
return util.HumanReadableInts(ids...)
}