mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
volume.list display; fix updating maxVolumeCount for disk
This commit is contained in:
parent
3fe628f04e
commit
cb9cc29518
|
@ -44,7 +44,8 @@ func (dc *DataCenter) ToMap() interface{} {
|
||||||
|
|
||||||
func (dc *DataCenter) ToDataCenterInfo() *master_pb.DataCenterInfo {
|
func (dc *DataCenter) ToDataCenterInfo() *master_pb.DataCenterInfo {
|
||||||
m := &master_pb.DataCenterInfo{
|
m := &master_pb.DataCenterInfo{
|
||||||
Id: string(dc.Id()),
|
Id: string(dc.Id()),
|
||||||
|
DiskInfos: dc.diskUsages.ToDiskInfo(),
|
||||||
}
|
}
|
||||||
for _, c := range dc.Children() {
|
for _, c := range dc.Children() {
|
||||||
rack := c.(*Rack)
|
rack := c.(*Rack)
|
||||||
|
|
|
@ -128,6 +128,25 @@ func (dn *DataNode) DeltaUpdateVolumes(newVolumes, deletedVolumes []storage.Volu
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dn *DataNode) AdjustMaxVolumeCounts(maxVolumeCounts map[string]uint32) {
|
||||||
|
deltaDiskUsages := newDiskUsages()
|
||||||
|
for diskType, maxVolumeCount := range maxVolumeCounts {
|
||||||
|
if maxVolumeCount == 0 {
|
||||||
|
// the volume server may have set the max to zero
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
dt := types.ToDiskType(diskType)
|
||||||
|
currentDiskUsage := dn.diskUsages.getOrCreateDisk(dt)
|
||||||
|
if currentDiskUsage.maxVolumeCount == int64(maxVolumeCount) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
disk := dn.getOrCreateDisk(dt.String())
|
||||||
|
deltaDiskUsage := deltaDiskUsages.getOrCreateDisk(dt)
|
||||||
|
deltaDiskUsage.maxVolumeCount = int64(maxVolumeCount) - currentDiskUsage.maxVolumeCount
|
||||||
|
disk.UpAdjustDiskUsageDelta(deltaDiskUsages)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (dn *DataNode) GetVolumes() (ret []storage.VolumeInfo) {
|
func (dn *DataNode) GetVolumes() (ret []storage.VolumeInfo) {
|
||||||
dn.RLock()
|
dn.RLock()
|
||||||
for _, c := range dn.children {
|
for _, c := range dn.children {
|
||||||
|
|
|
@ -42,7 +42,7 @@ func newDiskUsages() *DiskUsages {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DiskUsages) negative() (*DiskUsages) {
|
func (d *DiskUsages) negative() *DiskUsages {
|
||||||
d.RLock()
|
d.RLock()
|
||||||
defer d.RUnlock()
|
defer d.RUnlock()
|
||||||
t := newDiskUsages()
|
t := newDiskUsages()
|
||||||
|
@ -68,6 +68,21 @@ func (d *DiskUsages) ToMap() interface{} {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DiskUsages) ToDiskInfo() (map[string]*master_pb.DiskInfo) {
|
||||||
|
ret := make(map[string]*master_pb.DiskInfo)
|
||||||
|
for diskType, diskUsageCounts := range d.usages {
|
||||||
|
m := &master_pb.DiskInfo{
|
||||||
|
VolumeCount: uint64(diskUsageCounts.volumeCount),
|
||||||
|
MaxVolumeCount: uint64(diskUsageCounts.maxVolumeCount),
|
||||||
|
FreeVolumeCount: uint64(diskUsageCounts.maxVolumeCount - diskUsageCounts.volumeCount),
|
||||||
|
ActiveVolumeCount: uint64(diskUsageCounts.activeVolumeCount),
|
||||||
|
RemoteVolumeCount: uint64(diskUsageCounts.remoteVolumeCount),
|
||||||
|
}
|
||||||
|
ret[string(diskType)] = m
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DiskUsages) FreeSpace() (freeSpace int64) {
|
func (d *DiskUsages) FreeSpace() (freeSpace int64) {
|
||||||
d.RLock()
|
d.RLock()
|
||||||
defer d.RUnlock()
|
defer d.RUnlock()
|
||||||
|
@ -77,7 +92,6 @@ func (d *DiskUsages) FreeSpace() (freeSpace int64) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (d *DiskUsages) GetMaxVolumeCount() (maxVolumeCount int64) {
|
func (d *DiskUsages) GetMaxVolumeCount() (maxVolumeCount int64) {
|
||||||
d.RLock()
|
d.RLock()
|
||||||
defer d.RUnlock()
|
defer d.RUnlock()
|
||||||
|
@ -111,13 +125,13 @@ func (a *DiskUsageCounts) FreeSpace() int64 {
|
||||||
return freeVolumeSlotCount
|
return freeVolumeSlotCount
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *DiskUsageCounts) minus(b *DiskUsageCounts) (*DiskUsageCounts) {
|
func (a *DiskUsageCounts) minus(b *DiskUsageCounts) *DiskUsageCounts {
|
||||||
return &DiskUsageCounts{
|
return &DiskUsageCounts{
|
||||||
volumeCount: a.volumeCount - b.volumeCount,
|
volumeCount: a.volumeCount - b.volumeCount,
|
||||||
remoteVolumeCount: a.remoteVolumeCount - b.remoteVolumeCount,
|
remoteVolumeCount: a.remoteVolumeCount - b.remoteVolumeCount,
|
||||||
activeVolumeCount: a.activeVolumeCount - b.activeVolumeCount,
|
activeVolumeCount: a.activeVolumeCount - b.activeVolumeCount,
|
||||||
ecShardCount: a.ecShardCount - b.ecShardCount,
|
ecShardCount: a.ecShardCount - b.ecShardCount,
|
||||||
maxVolumeCount: a.maxVolumeCount - b.maxVolumeCount,
|
maxVolumeCount: a.maxVolumeCount - b.maxVolumeCount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +262,7 @@ func (d *Disk) ToDiskInfo() *master_pb.DiskInfo {
|
||||||
Type: string(d.Id()),
|
Type: string(d.Id()),
|
||||||
VolumeCount: uint64(diskUsage.volumeCount),
|
VolumeCount: uint64(diskUsage.volumeCount),
|
||||||
MaxVolumeCount: uint64(diskUsage.maxVolumeCount),
|
MaxVolumeCount: uint64(diskUsage.maxVolumeCount),
|
||||||
FreeVolumeCount: uint64(d.FreeSpace()),
|
FreeVolumeCount: uint64(diskUsage.maxVolumeCount - diskUsage.volumeCount),
|
||||||
ActiveVolumeCount: uint64(diskUsage.activeVolumeCount),
|
ActiveVolumeCount: uint64(diskUsage.activeVolumeCount),
|
||||||
RemoteVolumeCount: uint64(diskUsage.remoteVolumeCount),
|
RemoteVolumeCount: uint64(diskUsage.remoteVolumeCount),
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,22 +186,6 @@ func (n *NodeImpl) ReserveOneVolume(r int64, option *VolumeGrowOption) (assigned
|
||||||
return nil, errors.New("No free volume slot found!")
|
return nil, errors.New("No free volume slot found!")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NodeImpl) AdjustMaxVolumeCounts(maxVolumeCounts map[string]uint32) {
|
|
||||||
deltaDiskUsages := newDiskUsages()
|
|
||||||
for diskType, maxVolumeCount := range maxVolumeCounts {
|
|
||||||
if maxVolumeCount == 0 {
|
|
||||||
// the volume server may have set the max to zero
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
dt := types.ToDiskType(diskType)
|
|
||||||
deltaDiskUsage := deltaDiskUsages.getOrCreateDisk(dt)
|
|
||||||
currentDiskUsage := n.diskUsages.getOrCreateDisk(dt)
|
|
||||||
deltaDiskUsage.maxVolumeCount = int64(maxVolumeCount) - currentDiskUsage.maxVolumeCount
|
|
||||||
deltaDiskUsages.getOrCreateDisk(dt).maxVolumeCount = int64(maxVolumeCount)
|
|
||||||
}
|
|
||||||
n.UpAdjustDiskUsageDelta(deltaDiskUsages)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *NodeImpl) UpAdjustDiskUsageDelta(deltaDiskUsages *DiskUsages) { //can be negative
|
func (n *NodeImpl) UpAdjustDiskUsageDelta(deltaDiskUsages *DiskUsages) { //can be negative
|
||||||
for diskType, diskUsage := range deltaDiskUsages.usages {
|
for diskType, diskUsage := range deltaDiskUsages.usages {
|
||||||
existingDisk := n.getOrCreateDisk(diskType)
|
existingDisk := n.getOrCreateDisk(diskType)
|
||||||
|
|
|
@ -66,7 +66,8 @@ func (r *Rack) ToMap() interface{} {
|
||||||
|
|
||||||
func (r *Rack) ToRackInfo() *master_pb.RackInfo {
|
func (r *Rack) ToRackInfo() *master_pb.RackInfo {
|
||||||
m := &master_pb.RackInfo{
|
m := &master_pb.RackInfo{
|
||||||
Id: string(r.Id()),
|
Id: string(r.Id()),
|
||||||
|
DiskInfos: r.diskUsages.ToDiskInfo(),
|
||||||
}
|
}
|
||||||
for _, c := range r.Children() {
|
for _, c := range r.Children() {
|
||||||
dn := c.(*DataNode)
|
dn := c.(*DataNode)
|
||||||
|
|
|
@ -80,7 +80,8 @@ func (t *Topology) ToVolumeLocations() (volumeLocations []*master_pb.VolumeLocat
|
||||||
|
|
||||||
func (t *Topology) ToTopologyInfo() *master_pb.TopologyInfo {
|
func (t *Topology) ToTopologyInfo() *master_pb.TopologyInfo {
|
||||||
m := &master_pb.TopologyInfo{
|
m := &master_pb.TopologyInfo{
|
||||||
Id: string(t.Id()),
|
Id: string(t.Id()),
|
||||||
|
DiskInfos: t.diskUsages.ToDiskInfo(),
|
||||||
}
|
}
|
||||||
for _, c := range t.Children() {
|
for _, c := range t.Children() {
|
||||||
dc := c.(*DataCenter)
|
dc := c.(*DataCenter)
|
||||||
|
|
Loading…
Reference in a new issue