diff options
Diffstat (limited to 'weed/topology')
| -rw-r--r-- | weed/topology/data_node.go | 21 | ||||
| -rw-r--r-- | weed/topology/disk.go | 19 | ||||
| -rw-r--r-- | weed/topology/volume_growth.go | 22 |
3 files changed, 32 insertions, 30 deletions
diff --git a/weed/topology/data_node.go b/weed/topology/data_node.go index 1a0ebf761..69f739dd5 100644 --- a/weed/topology/data_node.go +++ b/weed/topology/data_node.go @@ -207,7 +207,26 @@ func (dn *DataNode) ToMap() interface{} { ret := make(map[string]interface{}) ret["Url"] = dn.Url() ret["PublicUrl"] = dn.PublicUrl - ret["Disks"] = dn.diskUsages.ToMap() + + // aggregated volume info + var volumeCount, ecShardCount, maxVolumeCount int64 + var volumeIds string + for _, diskUsage := range dn.diskUsages.usages { + volumeCount += diskUsage.volumeCount + ecShardCount += diskUsage.ecShardCount + maxVolumeCount += diskUsage.maxVolumeCount + } + + for _, disk := range dn.Children() { + d := disk.(*Disk) + volumeIds += " " + d.GetVolumeIds() + } + + ret["Volumes"] = volumeCount + ret["EcShards"] = ecShardCount + ret["Max"] = maxVolumeCount + ret["VolumeIds"] = volumeIds + return ret } diff --git a/weed/topology/disk.go b/weed/topology/disk.go index 37d5e1272..a085f8dff 100644 --- a/weed/topology/disk.go +++ b/weed/topology/disk.go @@ -58,16 +58,6 @@ func (d *DiskUsages) negative() *DiskUsages { return t } -func (d *DiskUsages) ToMap() interface{} { - d.RLock() - defer d.RUnlock() - ret := make(map[string]interface{}) - for diskType, diskUsage := range d.usages { - ret[diskType.String()] = diskUsage.ToMap() - } - return ret -} - func (d *DiskUsages) ToDiskInfo() map[string]*master_pb.DiskInfo { ret := make(map[string]*master_pb.DiskInfo) for diskType, diskUsageCounts := range d.usages { @@ -135,15 +125,6 @@ func (a *DiskUsageCounts) minus(b *DiskUsageCounts) *DiskUsageCounts { } } -func (diskUsage *DiskUsageCounts) ToMap() interface{} { - ret := make(map[string]interface{}) - ret["Volumes"] = diskUsage.volumeCount - ret["EcShards"] = diskUsage.ecShardCount - ret["Max"] = diskUsage.maxVolumeCount - ret["Free"] = diskUsage.FreeSpace() - return ret -} - func (du *DiskUsages) getOrCreateDisk(diskType types.DiskType) *DiskUsageCounts { du.Lock() defer du.Unlock() diff --git a/weed/topology/volume_growth.go b/weed/topology/volume_growth.go index 4b0a4837e..8941a049b 100644 --- a/weed/topology/volume_growth.go +++ b/weed/topology/volume_growth.go @@ -1,6 +1,7 @@ package topology import ( + "encoding/json" "fmt" "github.com/chrislusf/seaweedfs/weed/storage/types" "math/rand" @@ -25,15 +26,15 @@ This package is created to resolve these replica placement issues: */ type VolumeGrowOption struct { - Collection string - ReplicaPlacement *super_block.ReplicaPlacement - Ttl *needle.TTL - DiskType types.DiskType - Prealloacte int64 - DataCenter string - Rack string - DataNode string - MemoryMapMaxSizeMb uint32 + Collection string `json:"collection,omitempty"` + ReplicaPlacement *super_block.ReplicaPlacement `json:"replication,omitempty"` + Ttl *needle.TTL `json:"ttl,omitempty"` + DiskType types.DiskType `json:"disk,omitempty"` + Prealloacte int64 `json:"prealloacte,omitempty"` + DataCenter string `json:"dataCenter,omitempty"` + Rack string `json:"rack,omitempty"` + DataNode string `json:"dataNode,omitempty"` + MemoryMapMaxSizeMb uint32 `json:"memoryMapMaxSizeMb,omitempty"` } type VolumeGrowth struct { @@ -41,7 +42,8 @@ type VolumeGrowth struct { } func (o *VolumeGrowOption) String() string { - return fmt.Sprintf("Collection:%s, ReplicaPlacement:%v, Ttl:%v, DataCenter:%s, Rack:%s, DataNode:%s", o.Collection, o.ReplicaPlacement, o.Ttl, o.DataCenter, o.Rack, o.DataNode) + blob, _ := json.Marshal(o) + return string(blob) } func NewDefaultVolumeGrowth() *VolumeGrowth { |
