Browse Source

Add deleted bytes to total_disk_size (#5161)

pull/5054/merge
Seyed Mahdi Sadegh Shobeiri 10 months ago
committed by GitHub
parent
commit
ecc154fa9e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 7
      weed/storage/store.go

7
weed/storage/store.go

@ -251,6 +251,7 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
maxVolumeCounts := make(map[string]uint32) maxVolumeCounts := make(map[string]uint32)
var maxFileKey NeedleId var maxFileKey NeedleId
collectionVolumeSize := make(map[string]int64) collectionVolumeSize := make(map[string]int64)
collectionVolumeDeletedBytes := make(map[string]int64)
collectionVolumeReadOnlyCount := make(map[string]map[string]uint8) collectionVolumeReadOnlyCount := make(map[string]map[string]uint8)
for _, location := range s.Locations { for _, location := range s.Locations {
var deleteVids []needle.VolumeId var deleteVids []needle.VolumeId
@ -283,9 +284,11 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
if _, exist := collectionVolumeSize[v.Collection]; !exist { if _, exist := collectionVolumeSize[v.Collection]; !exist {
collectionVolumeSize[v.Collection] = 0 collectionVolumeSize[v.Collection] = 0
collectionVolumeDeletedBytes[v.Collection] = 0
} }
if !shouldDeleteVolume { if !shouldDeleteVolume {
collectionVolumeSize[v.Collection] += int64(volumeMessage.Size) collectionVolumeSize[v.Collection] += int64(volumeMessage.Size)
collectionVolumeDeletedBytes[v.Collection] += int64(volumeMessage.DeletedByteCount)
} else { } else {
collectionVolumeSize[v.Collection] -= int64(volumeMessage.Size) collectionVolumeSize[v.Collection] -= int64(volumeMessage.Size)
if collectionVolumeSize[v.Collection] <= 0 { if collectionVolumeSize[v.Collection] <= 0 {
@ -342,6 +345,10 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
stats.VolumeServerDiskSizeGauge.WithLabelValues(col, "normal").Set(float64(size)) stats.VolumeServerDiskSizeGauge.WithLabelValues(col, "normal").Set(float64(size))
} }
for col, deletedBytes := range collectionVolumeDeletedBytes{
stats.VolumeServerDiskSizeGauge.WithLabelValues(col, "deleted_bytes").Set(float64(deletedBytes))
}
for col, types := range collectionVolumeReadOnlyCount { for col, types := range collectionVolumeReadOnlyCount {
for t, count := range types { for t, count := range types {
stats.VolumeServerReadOnlyVolumeGauge.WithLabelValues(col, t).Set(float64(count)) stats.VolumeServerReadOnlyVolumeGauge.WithLabelValues(col, t).Set(float64(count))

Loading…
Cancel
Save