diff options
| author | bingoohuang <bingoo.huang@gmail.com> | 2021-02-18 13:57:34 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-18 13:57:34 +0800 |
| commit | c8f56f5712c1efffc46de95a8057ed09c21da2db (patch) | |
| tree | bc3330e274901d782395b7396cb54d7cc42608b1 /weed/topology/rack.go | |
| parent | 12a78335860c4b1e220748e4adc4097050af5272 (diff) | |
| parent | 3575d41009e4367658e75e6ae780c6260b80daf9 (diff) | |
| download | seaweedfs-c8f56f5712c1efffc46de95a8057ed09c21da2db.tar.xz seaweedfs-c8f56f5712c1efffc46de95a8057ed09c21da2db.zip | |
Merge pull request #2 from chrislusf/master
Diffstat (limited to 'weed/topology/rack.go')
| -rw-r--r-- | weed/topology/rack.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/weed/topology/rack.go b/weed/topology/rack.go index 1921c0c05..8eb2a717c 100644 --- a/weed/topology/rack.go +++ b/weed/topology/rack.go @@ -2,6 +2,7 @@ package topology import ( "github.com/chrislusf/seaweedfs/weed/pb/master_pb" + "github.com/chrislusf/seaweedfs/weed/storage/types" "strconv" "time" ) @@ -14,6 +15,7 @@ func NewRack(id string) *Rack { r := &Rack{} r.id = NodeId(id) r.nodeType = "Rack" + r.diskUsages = newDiskUsages() r.children = make(map[NodeId]Node) r.NodeImpl.value = r return r @@ -28,7 +30,7 @@ func (r *Rack) FindDataNode(ip string, port int) *DataNode { } return nil } -func (r *Rack) GetOrCreateDataNode(ip string, port int, publicUrl string, maxVolumeCount int64) *DataNode { +func (r *Rack) GetOrCreateDataNode(ip string, port int, publicUrl string, maxVolumeCounts map[string]uint32) *DataNode { for _, c := range r.Children() { dn := c.(*DataNode) if dn.MatchLocation(ip, port) { @@ -40,17 +42,19 @@ func (r *Rack) GetOrCreateDataNode(ip string, port int, publicUrl string, maxVol dn.Ip = ip dn.Port = port dn.PublicUrl = publicUrl - dn.maxVolumeCount = maxVolumeCount dn.LastSeen = time.Now().Unix() r.LinkChildNode(dn) + for diskType, maxVolumeCount := range maxVolumeCounts { + disk := NewDisk(diskType) + disk.diskUsages.getOrCreateDisk(types.ToDiskType(diskType)).maxVolumeCount = int64(maxVolumeCount) + dn.LinkChildNode(disk) + } return dn } func (r *Rack) ToMap() interface{} { m := make(map[string]interface{}) m["Id"] = r.Id() - m["Max"] = r.GetMaxVolumeCount() - m["Free"] = r.FreeSpace() var dns []interface{} for _, c := range r.Children() { dn := c.(*DataNode) @@ -62,12 +66,8 @@ func (r *Rack) ToMap() interface{} { func (r *Rack) ToRackInfo() *master_pb.RackInfo { m := &master_pb.RackInfo{ - Id: string(r.Id()), - VolumeCount: uint64(r.GetVolumeCount()), - MaxVolumeCount: uint64(r.GetMaxVolumeCount()), - FreeVolumeCount: uint64(r.FreeSpace()), - ActiveVolumeCount: uint64(r.GetActiveVolumeCount()), - RemoteVolumeCount: uint64(r.GetRemoteVolumeCount()), + Id: string(r.Id()), + DiskInfos: r.diskUsages.ToDiskInfo(), } for _, c := range r.Children() { dn := c.(*DataNode) |
