mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Merge pull request #3348 from ningfdx/remote
optimiz: master ui will render data in order
This commit is contained in:
commit
8d97add89c
|
@ -48,7 +48,7 @@ func (ms *MasterServer) collectionDeleteHandler(w http.ResponseWriter, r *http.R
|
|||
func (ms *MasterServer) dirStatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
m := make(map[string]interface{})
|
||||
m["Version"] = util.Version()
|
||||
m["Topology"] = ms.Topo.ToMap()
|
||||
m["Topology"] = ms.Topo.ToInfo()
|
||||
writeJsonQuiet(w, r, http.StatusOK, m)
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ func (ms *MasterServer) uiStatusHandler(w http.ResponseWriter, r *http.Request)
|
|||
VolumeSizeLimitMB uint32
|
||||
}{
|
||||
util.Version(),
|
||||
ms.Topo.ToMap(),
|
||||
ms.Topo.ToInfo(),
|
||||
ms.Topo.RaftServer,
|
||||
infos,
|
||||
serverStats,
|
||||
|
@ -43,7 +43,7 @@ func (ms *MasterServer) uiStatusHandler(w http.ResponseWriter, r *http.Request)
|
|||
VolumeSizeLimitMB uint32
|
||||
}{
|
||||
util.Version(),
|
||||
ms.Topo.ToMap(),
|
||||
ms.Topo.ToInfo(),
|
||||
ms.Topo.HashicorpRaft,
|
||||
infos,
|
||||
serverStats,
|
||||
|
|
|
@ -2,6 +2,7 @@ package topology
|
|||
|
||||
import (
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type DataCenter struct {
|
||||
|
@ -30,16 +31,24 @@ func (dc *DataCenter) GetOrCreateRack(rackName string) *Rack {
|
|||
return rack
|
||||
}
|
||||
|
||||
func (dc *DataCenter) ToMap() interface{} {
|
||||
m := make(map[string]interface{})
|
||||
m["Id"] = dc.Id()
|
||||
var racks []interface{}
|
||||
type DataCenterInfo struct {
|
||||
Id NodeId `json:"Id"`
|
||||
Racks []RackInfo `json:"Racks"`
|
||||
}
|
||||
|
||||
func (dc *DataCenter) ToInfo() (info DataCenterInfo) {
|
||||
info.Id = dc.Id()
|
||||
var racks []RackInfo
|
||||
for _, c := range dc.Children() {
|
||||
rack := c.(*Rack)
|
||||
racks = append(racks, rack.ToMap())
|
||||
racks = append(racks, rack.ToInfo())
|
||||
}
|
||||
m["Racks"] = racks
|
||||
return m
|
||||
|
||||
slices.SortFunc(racks, func(a, b RackInfo) bool {
|
||||
return a.Id < b.Id
|
||||
})
|
||||
info.Racks = racks
|
||||
return
|
||||
}
|
||||
|
||||
func (dc *DataCenter) ToDataCenterInfo() *master_pb.DataCenterInfo {
|
||||
|
|
|
@ -217,10 +217,18 @@ func (dn *DataNode) ServerAddress() pb.ServerAddress {
|
|||
return pb.NewServerAddress(dn.Ip, dn.Port, dn.GrpcPort)
|
||||
}
|
||||
|
||||
func (dn *DataNode) ToMap() interface{} {
|
||||
ret := make(map[string]interface{})
|
||||
ret["Url"] = dn.Url()
|
||||
ret["PublicUrl"] = dn.PublicUrl
|
||||
type DataNodeInfo struct {
|
||||
Url string `json:"Url"`
|
||||
PublicUrl string `json:"PublicUrl"`
|
||||
Volumes int64 `json:"Volumes"`
|
||||
EcShards int64 `json:"EcShards"`
|
||||
Max int64 `json:"Max"`
|
||||
VolumeIds string `json:"VolumeIds"`
|
||||
}
|
||||
|
||||
func (dn *DataNode) ToInfo() (info DataNodeInfo) {
|
||||
info.Url = dn.Url()
|
||||
info.PublicUrl = dn.PublicUrl
|
||||
|
||||
// aggregated volume info
|
||||
var volumeCount, ecShardCount, maxVolumeCount int64
|
||||
|
@ -236,12 +244,12 @@ func (dn *DataNode) ToMap() interface{} {
|
|||
volumeIds += " " + d.GetVolumeIds()
|
||||
}
|
||||
|
||||
ret["Volumes"] = volumeCount
|
||||
ret["EcShards"] = ecShardCount
|
||||
ret["Max"] = maxVolumeCount
|
||||
ret["VolumeIds"] = volumeIds
|
||||
info.Volumes = volumeCount
|
||||
info.EcShards = ecShardCount
|
||||
info.Max = maxVolumeCount
|
||||
info.VolumeIds = volumeIds
|
||||
|
||||
return ret
|
||||
return
|
||||
}
|
||||
|
||||
func (dn *DataNode) ToDataNodeInfo() *master_pb.DataNodeInfo {
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage/types"
|
||||
"github.com/chrislusf/seaweedfs/weed/util"
|
||||
"golang.org/x/exp/slices"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -53,16 +54,25 @@ func (r *Rack) GetOrCreateDataNode(ip string, port int, grpcPort int, publicUrl
|
|||
return dn
|
||||
}
|
||||
|
||||
func (r *Rack) ToMap() interface{} {
|
||||
m := make(map[string]interface{})
|
||||
m["Id"] = r.Id()
|
||||
var dns []interface{}
|
||||
type RackInfo struct {
|
||||
Id NodeId `json:"Id"`
|
||||
DataNodes []DataNodeInfo `json:"DataNodes"`
|
||||
}
|
||||
|
||||
func (r *Rack) ToInfo() (info RackInfo) {
|
||||
info.Id = r.Id()
|
||||
var dns []DataNodeInfo
|
||||
for _, c := range r.Children() {
|
||||
dn := c.(*DataNode)
|
||||
dns = append(dns, dn.ToMap())
|
||||
dns = append(dns, dn.ToInfo())
|
||||
}
|
||||
m["DataNodes"] = dns
|
||||
return m
|
||||
|
||||
slices.SortFunc(dns, func(a, b DataNodeInfo) bool {
|
||||
return a.Url < b.Url
|
||||
})
|
||||
|
||||
info.DataNodes = dns
|
||||
return
|
||||
}
|
||||
|
||||
func (r *Rack) ToRackInfo() *master_pb.RackInfo {
|
||||
|
|
|
@ -1,30 +1,44 @@
|
|||
package topology
|
||||
|
||||
import "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||
import (
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func (t *Topology) ToMap() interface{} {
|
||||
m := make(map[string]interface{})
|
||||
m["Max"] = t.diskUsages.GetMaxVolumeCount()
|
||||
m["Free"] = t.diskUsages.FreeSpace()
|
||||
var dcs []interface{}
|
||||
type TopologyInfo struct {
|
||||
Max int64 `json:"Max"`
|
||||
Free int64 `json:"Free"`
|
||||
DataCenters []DataCenterInfo `json:"DataCenters"`
|
||||
Layouts []VolumeLayoutInfo `json:"Layouts"`
|
||||
}
|
||||
|
||||
func (t *Topology) ToInfo() (info TopologyInfo) {
|
||||
info.Max = t.diskUsages.GetMaxVolumeCount()
|
||||
info.Free = t.diskUsages.FreeSpace()
|
||||
var dcs []DataCenterInfo
|
||||
for _, c := range t.Children() {
|
||||
dc := c.(*DataCenter)
|
||||
dcs = append(dcs, dc.ToMap())
|
||||
dcs = append(dcs, dc.ToInfo())
|
||||
}
|
||||
m["DataCenters"] = dcs
|
||||
var layouts []interface{}
|
||||
|
||||
slices.SortFunc(dcs, func(a, b DataCenterInfo) bool {
|
||||
return a.Id < b.Id
|
||||
})
|
||||
|
||||
info.DataCenters = dcs
|
||||
var layouts []VolumeLayoutInfo
|
||||
for _, col := range t.collectionMap.Items() {
|
||||
c := col.(*Collection)
|
||||
for _, layout := range c.storageType2VolumeLayout.Items() {
|
||||
if layout != nil {
|
||||
tmp := layout.(*VolumeLayout).ToMap()
|
||||
tmp["collection"] = c.Name
|
||||
tmp := layout.(*VolumeLayout).ToInfo()
|
||||
tmp.Collection = c.Name
|
||||
layouts = append(layouts, tmp)
|
||||
}
|
||||
}
|
||||
}
|
||||
m["Layouts"] = layouts
|
||||
return m
|
||||
info.Layouts = layouts
|
||||
return
|
||||
}
|
||||
|
||||
func (t *Topology) ToVolumeMap() interface{} {
|
|
@ -473,13 +473,19 @@ func (vl *VolumeLayout) SetVolumeCrowded(vid needle.VolumeId) {
|
|||
}
|
||||
}
|
||||
|
||||
func (vl *VolumeLayout) ToMap() map[string]interface{} {
|
||||
m := make(map[string]interface{})
|
||||
m["replication"] = vl.rp.String()
|
||||
m["ttl"] = vl.ttl.String()
|
||||
m["writables"] = vl.writables
|
||||
type VolumeLayoutInfo struct {
|
||||
Replication string `json:"replication"`
|
||||
TTL string `json:"ttl"`
|
||||
Writables []needle.VolumeId `json:"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
|
||||
return m
|
||||
return
|
||||
}
|
||||
|
||||
func (vl *VolumeLayout) Stats() *VolumeLayoutStats {
|
||||
|
|
Loading…
Reference in a new issue