diff --git a/weed/server/master_ui/templates.go b/weed/server/master_ui/templates.go
index b674e3f82..46fbbe3db 100644
--- a/weed/server/master_ui/templates.go
+++ b/weed/server/master_ui/templates.go
@@ -76,6 +76,7 @@ var StatusTpl = template.Must(template.New("status").Parse(`
Rack |
RemoteAddr |
#Volumes |
+ Volumes ID |
#ErasureCodingShards |
Max |
@@ -89,6 +90,7 @@ var StatusTpl = template.Must(template.New("status").Parse(`
{{ $rack.Id }} |
{{ $dn.Url }} |
{{ $dn.Volumes }} |
+ {{ $dn.VolumesID}} |
{{ $dn.EcShards }} |
{{ $dn.Max }} |
diff --git a/weed/topology/data_node.go b/weed/topology/data_node.go
index 617341e54..3538fe75e 100644
--- a/weed/topology/data_node.go
+++ b/weed/topology/data_node.go
@@ -2,6 +2,7 @@ package topology
import (
"fmt"
+ "sort"
"strconv"
"sync"
@@ -166,6 +167,7 @@ func (dn *DataNode) ToMap() interface{} {
ret := make(map[string]interface{})
ret["Url"] = dn.Url()
ret["Volumes"] = dn.GetVolumeCount()
+ ret["VolumesID"] = dn.GetVolumesID()
ret["EcShards"] = dn.GetEcShardCount()
ret["Max"] = dn.GetMaxVolumeCount()
ret["Free"] = dn.FreeSpace()
@@ -173,6 +175,52 @@ func (dn *DataNode) ToMap() interface{} {
return ret
}
+func (dn *DataNode) GetVolumesID() string {
+ ids := make([]int, 0, len(dn.volumes))
+
+ for k := range dn.volumes {
+ ids = append(ids, int(k))
+ }
+
+ return JoinInts(ids...)
+}
+
+func JoinInts(ids ...int) string {
+ sort.Ints(ids)
+
+ s := ""
+ start := 0
+ last := 0
+
+ for i, v := range ids {
+ if i == 0 {
+ start = v
+ last = v
+ s = fmt.Sprintf("%d", v)
+ continue
+ }
+
+ if last+1 == v {
+ last = v
+ continue
+ }
+
+ if last > start {
+ s += fmt.Sprintf("-%d", last)
+ }
+
+ s += fmt.Sprintf(" %d", v)
+ start = v
+ last = v
+ }
+
+ if last != start {
+ s += fmt.Sprintf("-%d", last)
+ }
+
+ return s
+}
+
func (dn *DataNode) ToDataNodeInfo() *master_pb.DataNodeInfo {
m := &master_pb.DataNodeInfo{
Id: string(dn.Id()),
diff --git a/weed/topology/data_node_test.go b/weed/topology/data_node_test.go
new file mode 100644
index 000000000..33ce3ff8d
--- /dev/null
+++ b/weed/topology/data_node_test.go
@@ -0,0 +1,14 @@
+package topology
+
+import (
+ assert2 "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestJoinInts(t *testing.T) {
+ assert2.Equal(t, "1-3", JoinInts(1, 2, 3))
+ assert2.Equal(t, "1 3", JoinInts(1, 3))
+ assert2.Equal(t, "1 3 5", JoinInts(5, 1, 3))
+ assert2.Equal(t, "1-3 5", JoinInts(1, 2, 3, 5))
+ assert2.Equal(t, "1-3 5 7-9", JoinInts(7, 9, 8, 1, 2, 3, 5))
+}