|
@ -103,44 +103,61 @@ func (c *commandVolumeList) writeTopologyInfo(writer io.Writer, t *master_pb.Top |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *commandVolumeList) writeDataCenterInfo(writer io.Writer, t *master_pb.DataCenterInfo, verbosityLevel int) statistics { |
|
|
func (c *commandVolumeList) writeDataCenterInfo(writer io.Writer, t *master_pb.DataCenterInfo, verbosityLevel int) statistics { |
|
|
output(verbosityLevel >= 1, writer, " DataCenter %s%s\n", t.Id, diskInfosToString(t.DiskInfos)) |
|
|
|
|
|
var s statistics |
|
|
var s statistics |
|
|
slices.SortFunc(t.RackInfos, func(a, b *master_pb.RackInfo) int { |
|
|
slices.SortFunc(t.RackInfos, func(a, b *master_pb.RackInfo) int { |
|
|
return strings.Compare(a.Id, b.Id) |
|
|
return strings.Compare(a.Id, b.Id) |
|
|
}) |
|
|
}) |
|
|
|
|
|
dataCenterInfoFound := false |
|
|
for _, r := range t.RackInfos { |
|
|
for _, r := range t.RackInfos { |
|
|
if *c.rack != "" && *c.rack != r.Id { |
|
|
if *c.rack != "" && *c.rack != r.Id { |
|
|
continue |
|
|
continue |
|
|
} |
|
|
} |
|
|
s = s.plus(c.writeRackInfo(writer, r, verbosityLevel)) |
|
|
|
|
|
|
|
|
s = s.plus(c.writeRackInfo(writer, r, verbosityLevel, func() { |
|
|
|
|
|
output(verbosityLevel >= 1, writer, " DataCenter %s%s\n", t.Id, diskInfosToString(t.DiskInfos)) |
|
|
|
|
|
})) |
|
|
|
|
|
if !dataCenterInfoFound && !s.isEmpty() { |
|
|
|
|
|
dataCenterInfoFound = true |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
output(verbosityLevel >= 1, writer, " DataCenter %s %+v \n", t.Id, s) |
|
|
|
|
|
|
|
|
output(dataCenterInfoFound && verbosityLevel >= 1, writer, " DataCenter %s %+v \n", t.Id, s) |
|
|
return s |
|
|
return s |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *commandVolumeList) writeRackInfo(writer io.Writer, t *master_pb.RackInfo, verbosityLevel int) statistics { |
|
|
|
|
|
output(verbosityLevel >= 2, writer, " Rack %s%s\n", t.Id, diskInfosToString(t.DiskInfos)) |
|
|
|
|
|
|
|
|
func (c *commandVolumeList) writeRackInfo(writer io.Writer, t *master_pb.RackInfo, verbosityLevel int, outCenterInfo func()) statistics { |
|
|
var s statistics |
|
|
var s statistics |
|
|
slices.SortFunc(t.DataNodeInfos, func(a, b *master_pb.DataNodeInfo) int { |
|
|
slices.SortFunc(t.DataNodeInfos, func(a, b *master_pb.DataNodeInfo) int { |
|
|
return strings.Compare(a.Id, b.Id) |
|
|
return strings.Compare(a.Id, b.Id) |
|
|
}) |
|
|
}) |
|
|
|
|
|
rackInfoFound := false |
|
|
for _, dn := range t.DataNodeInfos { |
|
|
for _, dn := range t.DataNodeInfos { |
|
|
if *c.dataNode != "" && *c.dataNode != dn.Id { |
|
|
if *c.dataNode != "" && *c.dataNode != dn.Id { |
|
|
continue |
|
|
continue |
|
|
} |
|
|
} |
|
|
s = s.plus(c.writeDataNodeInfo(writer, dn, verbosityLevel)) |
|
|
|
|
|
|
|
|
s = s.plus(c.writeDataNodeInfo(writer, dn, verbosityLevel, func() { |
|
|
|
|
|
outCenterInfo() |
|
|
|
|
|
output(verbosityLevel >= 2, writer, " Rack %s%s\n", t.Id, diskInfosToString(t.DiskInfos)) |
|
|
|
|
|
})) |
|
|
|
|
|
if !rackInfoFound && !s.isEmpty() { |
|
|
|
|
|
rackInfoFound = true |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
output(verbosityLevel >= 2, writer, " Rack %s %+v \n", t.Id, s) |
|
|
|
|
|
|
|
|
output(rackInfoFound && verbosityLevel >= 2, writer, " Rack %s %+v \n", t.Id, s) |
|
|
return s |
|
|
return s |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *commandVolumeList) writeDataNodeInfo(writer io.Writer, t *master_pb.DataNodeInfo, verbosityLevel int) statistics { |
|
|
|
|
|
output(verbosityLevel >= 3, writer, " DataNode %s%s\n", t.Id, diskInfosToString(t.DiskInfos)) |
|
|
|
|
|
|
|
|
func (c *commandVolumeList) writeDataNodeInfo(writer io.Writer, t *master_pb.DataNodeInfo, verbosityLevel int, outRackInfo func()) statistics { |
|
|
var s statistics |
|
|
var s statistics |
|
|
|
|
|
diskInfoFound := false |
|
|
for _, diskInfo := range t.DiskInfos { |
|
|
for _, diskInfo := range t.DiskInfos { |
|
|
s = s.plus(c.writeDiskInfo(writer, diskInfo, verbosityLevel)) |
|
|
|
|
|
|
|
|
s = s.plus(c.writeDiskInfo(writer, diskInfo, verbosityLevel, func() { |
|
|
|
|
|
outRackInfo() |
|
|
|
|
|
output(verbosityLevel >= 3, writer, " DataNode %s%s\n", t.Id, diskInfosToString(t.DiskInfos)) |
|
|
|
|
|
})) |
|
|
|
|
|
if !diskInfoFound && !s.isEmpty() { |
|
|
|
|
|
diskInfoFound = true |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
output(verbosityLevel >= 3, writer, " DataNode %s %+v \n", t.Id, s) |
|
|
|
|
|
|
|
|
output(diskInfoFound && verbosityLevel >= 3, writer, " DataNode %s %+v \n", t.Id, s) |
|
|
return s |
|
|
return s |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -159,27 +176,37 @@ func (c *commandVolumeList) isNotMatchDiskInfo(readOnly bool, collection string, |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *commandVolumeList) writeDiskInfo(writer io.Writer, t *master_pb.DiskInfo, verbosityLevel int) statistics { |
|
|
|
|
|
|
|
|
func (c *commandVolumeList) writeDiskInfo(writer io.Writer, t *master_pb.DiskInfo, verbosityLevel int, outNodeInfo func()) statistics { |
|
|
var s statistics |
|
|
var s statistics |
|
|
diskType := t.Type |
|
|
diskType := t.Type |
|
|
if diskType == "" { |
|
|
if diskType == "" { |
|
|
diskType = types.HddType |
|
|
diskType = types.HddType |
|
|
} |
|
|
} |
|
|
output(verbosityLevel >= 4, writer, " Disk %s(%s)\n", diskType, diskInfoToString(t)) |
|
|
|
|
|
slices.SortFunc(t.VolumeInfos, func(a, b *master_pb.VolumeInformationMessage) int { |
|
|
slices.SortFunc(t.VolumeInfos, func(a, b *master_pb.VolumeInformationMessage) int { |
|
|
return int(a.Id - b.Id) |
|
|
return int(a.Id - b.Id) |
|
|
}) |
|
|
}) |
|
|
|
|
|
volumeInfosFound := false |
|
|
for _, vi := range t.VolumeInfos { |
|
|
for _, vi := range t.VolumeInfos { |
|
|
if c.isNotMatchDiskInfo(vi.ReadOnly, vi.Collection, vi.Id) { |
|
|
if c.isNotMatchDiskInfo(vi.ReadOnly, vi.Collection, vi.Id) { |
|
|
continue |
|
|
continue |
|
|
} |
|
|
} |
|
|
|
|
|
if !volumeInfosFound { |
|
|
|
|
|
outNodeInfo() |
|
|
|
|
|
output(verbosityLevel >= 4, writer, " Disk %s(%s)\n", diskType, diskInfoToString(t)) |
|
|
|
|
|
volumeInfosFound = true |
|
|
|
|
|
} |
|
|
s = s.plus(writeVolumeInformationMessage(writer, vi, verbosityLevel)) |
|
|
s = s.plus(writeVolumeInformationMessage(writer, vi, verbosityLevel)) |
|
|
} |
|
|
} |
|
|
|
|
|
ecShardInfoFound := false |
|
|
for _, ecShardInfo := range t.EcShardInfos { |
|
|
for _, ecShardInfo := range t.EcShardInfos { |
|
|
if c.isNotMatchDiskInfo(false, ecShardInfo.Collection, ecShardInfo.Id) { |
|
|
if c.isNotMatchDiskInfo(false, ecShardInfo.Collection, ecShardInfo.Id) { |
|
|
continue |
|
|
continue |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !volumeInfosFound && !ecShardInfoFound { |
|
|
|
|
|
outNodeInfo() |
|
|
|
|
|
output(verbosityLevel >= 4, writer, " Disk %s(%s)\n", diskType, diskInfoToString(t)) |
|
|
|
|
|
ecShardInfoFound = true |
|
|
|
|
|
} |
|
|
var expireAtString string |
|
|
var expireAtString string |
|
|
destroyTime := ecShardInfo.ExpireAtSec |
|
|
destroyTime := ecShardInfo.ExpireAtSec |
|
|
if destroyTime > 0 { |
|
|
if destroyTime > 0 { |
|
@ -187,7 +214,7 @@ func (c *commandVolumeList) writeDiskInfo(writer io.Writer, t *master_pb.DiskInf |
|
|
} |
|
|
} |
|
|
output(verbosityLevel >= 5, writer, " ec volume id:%v collection:%v shards:%v %s\n", ecShardInfo.Id, ecShardInfo.Collection, erasure_coding.ShardBits(ecShardInfo.EcIndexBits).ShardIds(), expireAtString) |
|
|
output(verbosityLevel >= 5, writer, " ec volume id:%v collection:%v shards:%v %s\n", ecShardInfo.Id, ecShardInfo.Collection, erasure_coding.ShardBits(ecShardInfo.EcIndexBits).ShardIds(), expireAtString) |
|
|
} |
|
|
} |
|
|
output(verbosityLevel >= 4, writer, " Disk %s %+v \n", diskType, s) |
|
|
|
|
|
|
|
|
output((volumeInfosFound || ecShardInfoFound) && verbosityLevel >= 4, writer, " Disk %s %+v \n", diskType, s) |
|
|
return s |
|
|
return s |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -227,6 +254,10 @@ func (s statistics) plus(t statistics) statistics { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (s statistics) isEmpty() bool { |
|
|
|
|
|
return s.Size == 0 && s.FileCount == 0 && s.DeletedFileCount == 0 && s.DeletedBytes == 0 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func (s statistics) String() string { |
|
|
func (s statistics) String() string { |
|
|
if s.DeletedFileCount > 0 { |
|
|
if s.DeletedFileCount > 0 { |
|
|
return fmt.Sprintf("total size:%d file_count:%d deleted_file:%d deleted_bytes:%d", s.Size, s.FileCount, s.DeletedFileCount, s.DeletedBytes) |
|
|
return fmt.Sprintf("total size:%d file_count:%d deleted_file:%d deleted_bytes:%d", s.Size, s.FileCount, s.DeletedFileCount, s.DeletedBytes) |
|
|