Browse Source
Merge pull request #3348 from ningfdx/remote
Merge pull request #3348 from ningfdx/remote
optimiz: master ui will render data in orderpull/3354/head
Chris Lu
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 92 additions and 45 deletions
-
2weed/server/master_server_handlers_admin.go
-
4weed/server/master_server_handlers_ui.go
-
23weed/topology/data_center.go
-
26weed/topology/data_node.go
-
24weed/topology/rack.go
-
40weed/topology/topology_info.go
-
18weed/topology/volume_layout.go
@ -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{} { |
Write
Preview
Loading…
Cancel
Save
Reference in new issue