weed shell: list volumes
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package topology
|
||||
|
||||
import "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||
|
||||
type DataCenter struct {
|
||||
NodeImpl
|
||||
}
|
||||
@@ -38,3 +40,18 @@ func (dc *DataCenter) ToMap() interface{} {
|
||||
m["Racks"] = racks
|
||||
return m
|
||||
}
|
||||
|
||||
func (dc *DataCenter) ToDataCenterInfo() *master_pb.DataCenterInfo {
|
||||
m := &master_pb.DataCenterInfo{
|
||||
Id: string(dc.Id()),
|
||||
VolumeCount: uint64(dc.GetVolumeCount()),
|
||||
MaxVolumeCount: uint64(dc.GetMaxVolumeCount()),
|
||||
FreeVolumeCount: uint64(dc.FreeSpace()),
|
||||
ActiveVolumeCount: uint64(dc.GetActiveVolumeCount()),
|
||||
}
|
||||
for _, c := range dc.Children() {
|
||||
rack := c.(*Rack)
|
||||
m.RackInfos = append(m.RackInfos, rack.ToRackInfo())
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package topology
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||
"strconv"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
@@ -128,3 +129,17 @@ func (dn *DataNode) ToMap() interface{} {
|
||||
ret["PublicUrl"] = dn.PublicUrl
|
||||
return ret
|
||||
}
|
||||
|
||||
func (dn *DataNode) ToDataNodeInfo() *master_pb.DataNodeInfo {
|
||||
m := &master_pb.DataNodeInfo{
|
||||
Id: string(dn.Id()),
|
||||
VolumeCount: uint64(dn.GetVolumeCount()),
|
||||
MaxVolumeCount: uint64(dn.GetMaxVolumeCount()),
|
||||
FreeVolumeCount: uint64(dn.FreeSpace()),
|
||||
ActiveVolumeCount: uint64(dn.GetActiveVolumeCount()),
|
||||
}
|
||||
for _, v := range dn.GetVolumes() {
|
||||
m.VolumeInfos = append(m.VolumeInfos, v.ToVolumeInformationMessage())
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package topology
|
||||
|
||||
import (
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
@@ -58,3 +59,18 @@ func (r *Rack) ToMap() interface{} {
|
||||
m["DataNodes"] = dns
|
||||
return m
|
||||
}
|
||||
|
||||
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()),
|
||||
}
|
||||
for _, c := range r.Children() {
|
||||
dn := c.(*DataNode)
|
||||
m.DataNodeInfos = append(m.DataNodeInfos, dn.ToDataNodeInfo())
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
@@ -74,3 +74,18 @@ func (t *Topology) ToVolumeLocations() (volumeLocations []*master_pb.VolumeLocat
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (t *Topology) ToTopologyInfo() *master_pb.TopologyInfo {
|
||||
m := &master_pb.TopologyInfo{
|
||||
Id: string(t.Id()),
|
||||
VolumeCount: uint64(t.GetVolumeCount()),
|
||||
MaxVolumeCount: uint64(t.GetMaxVolumeCount()),
|
||||
FreeVolumeCount: uint64(t.FreeSpace()),
|
||||
ActiveVolumeCount: uint64(t.GetActiveVolumeCount()),
|
||||
}
|
||||
for _, c := range t.Children() {
|
||||
dc := c.(*DataCenter)
|
||||
m.DataCenterInfos = append(m.DataCenterInfos, dc.ToDataCenterInfo())
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user