From 53e2e73de2ed2d7145a7e60ca822d5ccdc3c10b9 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 22 Apr 2019 12:32:10 -0700 Subject: [PATCH] fix metrics fix https://github.com/chrislusf/seaweedfs/issues/935 --- weed/storage/needle_map_metric.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/weed/storage/needle_map_metric.go b/weed/storage/needle_map_metric.go index 5c251793c..55b877db6 100644 --- a/weed/storage/needle_map_metric.go +++ b/weed/storage/needle_map_metric.go @@ -28,33 +28,33 @@ func (mm *mapMetric) logPut(key NeedleId, oldSize uint32, newSize uint32) { mm.LogDeletionCounter(oldSize) } } -func (mm mapMetric) LogFileCounter(newSize uint32) { +func (mm *mapMetric) LogFileCounter(newSize uint32) { atomic.AddUint32(&mm.FileCounter, 1) atomic.AddUint64(&mm.FileByteCounter, uint64(newSize)) } -func (mm mapMetric) LogDeletionCounter(oldSize uint32) { +func (mm *mapMetric) LogDeletionCounter(oldSize uint32) { if oldSize > 0 { atomic.AddUint32(&mm.DeletionCounter, 1) atomic.AddUint64(&mm.DeletionByteCounter, uint64(oldSize)) } } -func (mm mapMetric) ContentSize() uint64 { +func (mm *mapMetric) ContentSize() uint64 { return atomic.LoadUint64(&mm.FileByteCounter) } -func (mm mapMetric) DeletedSize() uint64 { +func (mm *mapMetric) DeletedSize() uint64 { return atomic.LoadUint64(&mm.DeletionByteCounter) } -func (mm mapMetric) FileCount() int { +func (mm *mapMetric) FileCount() int { return int(atomic.LoadUint32(&mm.FileCounter)) } -func (mm mapMetric) DeletedCount() int { +func (mm *mapMetric) DeletedCount() int { return int(atomic.LoadUint32(&mm.DeletionCounter)) } -func (mm mapMetric) MaxFileKey() NeedleId { +func (mm *mapMetric) MaxFileKey() NeedleId { t := uint64(mm.MaximumFileKey) return NeedleId(t) } -func (mm mapMetric) MaybeSetMaxFileKey(key NeedleId) { +func (mm *mapMetric) MaybeSetMaxFileKey(key NeedleId) { if key > mm.MaxFileKey() { atomic.StoreUint64(&mm.MaximumFileKey, uint64(key)) }