mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-05 20:52:50 +08:00
change topology mapping definition, improve spelling
This commit is contained in:
parent
6f882eb354
commit
58f2dd6740
@ -48,7 +48,7 @@ func (ms *MasterServer) collectionDeleteHandler(w http.ResponseWriter, r *http.R
|
|||||||
func (ms *MasterServer) dirStatusHandler(w http.ResponseWriter, r *http.Request) {
|
func (ms *MasterServer) dirStatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["Version"] = util.Version()
|
m["Version"] = util.Version()
|
||||||
m["Topology"] = ms.Topo.ToMap()
|
m["Topology"] = ms.Topo.ToInfo()
|
||||||
writeJsonQuiet(w, r, http.StatusOK, m)
|
writeJsonQuiet(w, r, http.StatusOK, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ func (ms *MasterServer) uiStatusHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
VolumeSizeLimitMB uint32
|
VolumeSizeLimitMB uint32
|
||||||
}{
|
}{
|
||||||
util.Version(),
|
util.Version(),
|
||||||
ms.Topo.ToMap(),
|
ms.Topo.ToInfo(),
|
||||||
ms.Topo.RaftServer,
|
ms.Topo.RaftServer,
|
||||||
infos,
|
infos,
|
||||||
serverStats,
|
serverStats,
|
||||||
@ -43,7 +43,7 @@ func (ms *MasterServer) uiStatusHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
VolumeSizeLimitMB uint32
|
VolumeSizeLimitMB uint32
|
||||||
}{
|
}{
|
||||||
util.Version(),
|
util.Version(),
|
||||||
ms.Topo.ToMap(),
|
ms.Topo.ToInfo(),
|
||||||
ms.Topo.HashicorpRaft,
|
ms.Topo.HashicorpRaft,
|
||||||
infos,
|
infos,
|
||||||
serverStats,
|
serverStats,
|
||||||
|
@ -31,25 +31,24 @@ func (dc *DataCenter) GetOrCreateRack(rackName string) *Rack {
|
|||||||
return rack
|
return rack
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataCenterMap struct {
|
type DataCenterInfo struct {
|
||||||
Id NodeId `json:"Id"`
|
Id NodeId `json:"Id"`
|
||||||
Racks []RackMap `json:"Racks"`
|
Racks []RackInfo `json:"Racks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *DataCenter) ToMap() DataCenterMap {
|
func (dc *DataCenter) ToInfo() (info DataCenterInfo) {
|
||||||
m := DataCenterMap{}
|
info.Id = dc.Id()
|
||||||
m.Id = dc.Id()
|
var racks []RackInfo
|
||||||
var racks []RackMap
|
|
||||||
for _, c := range dc.Children() {
|
for _, c := range dc.Children() {
|
||||||
rack := c.(*Rack)
|
rack := c.(*Rack)
|
||||||
racks = append(racks, rack.ToMap())
|
racks = append(racks, rack.ToInfo())
|
||||||
}
|
}
|
||||||
|
|
||||||
slices.SortFunc(racks, func(a, b RackMap) bool {
|
slices.SortFunc(racks, func(a, b RackInfo) bool {
|
||||||
return a.Id < b.Id
|
return a.Id < b.Id
|
||||||
})
|
})
|
||||||
m.Racks = racks
|
info.Racks = racks
|
||||||
return m
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *DataCenter) ToDataCenterInfo() *master_pb.DataCenterInfo {
|
func (dc *DataCenter) ToDataCenterInfo() *master_pb.DataCenterInfo {
|
||||||
|
@ -217,7 +217,7 @@ func (dn *DataNode) ServerAddress() pb.ServerAddress {
|
|||||||
return pb.NewServerAddress(dn.Ip, dn.Port, dn.GrpcPort)
|
return pb.NewServerAddress(dn.Ip, dn.Port, dn.GrpcPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataNodeMap struct {
|
type DataNodeInfo struct {
|
||||||
Url string `json:"Url"`
|
Url string `json:"Url"`
|
||||||
PublicUrl string `json:"PublicUrl"`
|
PublicUrl string `json:"PublicUrl"`
|
||||||
Volumes int64 `json:"Volumes"`
|
Volumes int64 `json:"Volumes"`
|
||||||
@ -226,10 +226,9 @@ type DataNodeMap struct {
|
|||||||
VolumeIds string `json:"VolumeIds"`
|
VolumeIds string `json:"VolumeIds"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dn *DataNode) ToMap() DataNodeMap {
|
func (dn *DataNode) ToInfo() (info DataNodeInfo) {
|
||||||
ret := DataNodeMap{}
|
info.Url = dn.Url()
|
||||||
ret.Url = dn.Url()
|
info.PublicUrl = dn.PublicUrl
|
||||||
ret.PublicUrl = dn.PublicUrl
|
|
||||||
|
|
||||||
// aggregated volume info
|
// aggregated volume info
|
||||||
var volumeCount, ecShardCount, maxVolumeCount int64
|
var volumeCount, ecShardCount, maxVolumeCount int64
|
||||||
@ -245,12 +244,12 @@ func (dn *DataNode) ToMap() DataNodeMap {
|
|||||||
volumeIds += " " + d.GetVolumeIds()
|
volumeIds += " " + d.GetVolumeIds()
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.Volumes = volumeCount
|
info.Volumes = volumeCount
|
||||||
ret.EcShards = ecShardCount
|
info.EcShards = ecShardCount
|
||||||
ret.Max = maxVolumeCount
|
info.Max = maxVolumeCount
|
||||||
ret.VolumeIds = volumeIds
|
info.VolumeIds = volumeIds
|
||||||
|
|
||||||
return ret
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dn *DataNode) ToDataNodeInfo() *master_pb.DataNodeInfo {
|
func (dn *DataNode) ToDataNodeInfo() *master_pb.DataNodeInfo {
|
||||||
|
@ -54,26 +54,25 @@ func (r *Rack) GetOrCreateDataNode(ip string, port int, grpcPort int, publicUrl
|
|||||||
return dn
|
return dn
|
||||||
}
|
}
|
||||||
|
|
||||||
type RackMap struct {
|
type RackInfo struct {
|
||||||
Id NodeId `json:"Id"`
|
Id NodeId `json:"Id"`
|
||||||
DataNodes []DataNodeMap `json:"DataNodes"`
|
DataNodes []DataNodeInfo `json:"DataNodes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Rack) ToMap() RackMap {
|
func (r *Rack) ToInfo() (info RackInfo) {
|
||||||
m := RackMap{}
|
info.Id = r.Id()
|
||||||
m.Id = r.Id()
|
var dns []DataNodeInfo
|
||||||
var dns []DataNodeMap
|
|
||||||
for _, c := range r.Children() {
|
for _, c := range r.Children() {
|
||||||
dn := c.(*DataNode)
|
dn := c.(*DataNode)
|
||||||
dns = append(dns, dn.ToMap())
|
dns = append(dns, dn.ToInfo())
|
||||||
}
|
}
|
||||||
|
|
||||||
slices.SortFunc(dns, func(a, b DataNodeMap) bool {
|
slices.SortFunc(dns, func(a, b DataNodeInfo) bool {
|
||||||
return a.Url < b.Url
|
return a.Url < b.Url
|
||||||
})
|
})
|
||||||
|
|
||||||
m.DataNodes = dns
|
info.DataNodes = dns
|
||||||
return m
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Rack) ToRackInfo() *master_pb.RackInfo {
|
func (r *Rack) ToRackInfo() *master_pb.RackInfo {
|
||||||
|
@ -5,41 +5,40 @@ import (
|
|||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TopologyMap struct {
|
type TopologyInfo struct {
|
||||||
Max int64 `json:"Max"`
|
Max int64 `json:"Max"`
|
||||||
Free int64 `json:"Free"`
|
Free int64 `json:"Free"`
|
||||||
DataCenters []DataCenterMap `json:"DataCenters"`
|
DataCenters []DataCenterInfo `json:"DataCenters"`
|
||||||
Layouts []interface{} `json:"Layouts"`
|
Layouts []VolumeLayoutInfo `json:"Layouts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Topology) ToMap() interface{} {
|
func (t *Topology) ToInfo() (info TopologyInfo) {
|
||||||
m := TopologyMap{}
|
info.Max = t.diskUsages.GetMaxVolumeCount()
|
||||||
m.Max = t.diskUsages.GetMaxVolumeCount()
|
info.Free = t.diskUsages.FreeSpace()
|
||||||
m.Free = t.diskUsages.FreeSpace()
|
var dcs []DataCenterInfo
|
||||||
var dcs []DataCenterMap
|
|
||||||
for _, c := range t.Children() {
|
for _, c := range t.Children() {
|
||||||
dc := c.(*DataCenter)
|
dc := c.(*DataCenter)
|
||||||
dcs = append(dcs, dc.ToMap())
|
dcs = append(dcs, dc.ToInfo())
|
||||||
}
|
}
|
||||||
|
|
||||||
slices.SortFunc(dcs, func(a, b DataCenterMap) bool {
|
slices.SortFunc(dcs, func(a, b DataCenterInfo) bool {
|
||||||
return a.Id < b.Id
|
return a.Id < b.Id
|
||||||
})
|
})
|
||||||
|
|
||||||
m.DataCenters = dcs
|
info.DataCenters = dcs
|
||||||
var layouts []interface{}
|
var layouts []VolumeLayoutInfo
|
||||||
for _, col := range t.collectionMap.Items() {
|
for _, col := range t.collectionMap.Items() {
|
||||||
c := col.(*Collection)
|
c := col.(*Collection)
|
||||||
for _, layout := range c.storageType2VolumeLayout.Items() {
|
for _, layout := range c.storageType2VolumeLayout.Items() {
|
||||||
if layout != nil {
|
if layout != nil {
|
||||||
tmp := layout.(*VolumeLayout).ToMap()
|
tmp := layout.(*VolumeLayout).ToInfo()
|
||||||
tmp["collection"] = c.Name
|
tmp.Collection = c.Name
|
||||||
layouts = append(layouts, tmp)
|
layouts = append(layouts, tmp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Layouts = layouts
|
info.Layouts = layouts
|
||||||
return m
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Topology) ToVolumeMap() interface{} {
|
func (t *Topology) ToVolumeMap() interface{} {
|
@ -473,13 +473,19 @@ func (vl *VolumeLayout) SetVolumeCrowded(vid needle.VolumeId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vl *VolumeLayout) ToMap() map[string]interface{} {
|
type VolumeLayoutInfo struct {
|
||||||
m := make(map[string]interface{})
|
Replication string `json:"replication"`
|
||||||
m["replication"] = vl.rp.String()
|
TTL string `json:"ttl"`
|
||||||
m["ttl"] = vl.ttl.String()
|
Writables []needle.VolumeId `json:"writables"`
|
||||||
m["writables"] = vl.writables
|
Collection string `json:"collection"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (vl *VolumeLayout) ToInfo() (info VolumeLayoutInfo) {
|
||||||
|
info.Replication = vl.rp.String()
|
||||||
|
info.TTL = vl.ttl.String()
|
||||||
|
info.Writables = vl.writables
|
||||||
//m["locations"] = vl.vid2location
|
//m["locations"] = vl.vid2location
|
||||||
return m
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vl *VolumeLayout) Stats() *VolumeLayoutStats {
|
func (vl *VolumeLayout) Stats() *VolumeLayoutStats {
|
||||||
|
Loading…
Reference in New Issue
Block a user