2021-03-15 13:09:27 +00:00
|
|
|
package engine
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
2023-05-19 08:17:19 +00:00
|
|
|
|
2024-06-24 14:12:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/metrics"
|
2023-06-14 08:00:44 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
2021-03-15 13:09:27 +00:00
|
|
|
)
|
|
|
|
|
2025-01-13 09:52:02 +00:00
|
|
|
type (
|
|
|
|
MetricRegister = metrics.EngineMetrics
|
|
|
|
GCMetrics = metrics.GCMetrics
|
|
|
|
WriteCacheMetrics = metrics.WriteCacheMetrics
|
|
|
|
NullBool = metrics.NullBool
|
|
|
|
)
|
2021-03-15 13:09:27 +00:00
|
|
|
|
2023-06-13 16:48:15 +00:00
|
|
|
func elapsed(method string, addFunc func(method string, d time.Duration)) func() {
|
2021-03-15 13:09:27 +00:00
|
|
|
t := time.Now()
|
|
|
|
|
|
|
|
return func() {
|
2023-06-13 16:48:15 +00:00
|
|
|
addFunc(method, time.Since(t))
|
2021-03-15 13:09:27 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-29 14:32:13 +00:00
|
|
|
|
|
|
|
type gcMetrics struct {
|
|
|
|
storage metrics.GCMetrics
|
|
|
|
shardID string
|
|
|
|
}
|
|
|
|
|
2024-02-13 06:09:47 +00:00
|
|
|
func (m *gcMetrics) SetShardID(id string) {
|
|
|
|
m.shardID = id
|
|
|
|
}
|
|
|
|
|
2023-05-29 14:32:13 +00:00
|
|
|
func (m *gcMetrics) AddRunDuration(d time.Duration, success bool) {
|
|
|
|
m.storage.AddRunDuration(m.shardID, d, success)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *gcMetrics) AddDeletedCount(deleted, failed uint64) {
|
|
|
|
m.storage.AddDeletedCount(m.shardID, deleted, failed)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *gcMetrics) AddExpiredObjectCollectionDuration(d time.Duration, success bool, objectType string) {
|
|
|
|
m.storage.AddExpiredObjectCollectionDuration(m.shardID, d, success, objectType)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *gcMetrics) AddInhumedObjectCount(count uint64, objectType string) {
|
|
|
|
m.storage.AddInhumedObjectCount(m.shardID, count, objectType)
|
|
|
|
}
|
2024-10-03 07:40:56 +00:00
|
|
|
|
|
|
|
type (
|
|
|
|
noopMetrics struct{}
|
|
|
|
noopWriteCacheMetrics struct{}
|
|
|
|
noopGCMetrics struct{}
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2025-01-13 09:52:02 +00:00
|
|
|
_ MetricRegister = noopMetrics{}
|
|
|
|
_ WriteCacheMetrics = noopWriteCacheMetrics{}
|
|
|
|
_ GCMetrics = noopGCMetrics{}
|
2024-10-03 07:40:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (noopMetrics) AddMethodDuration(string, time.Duration) {}
|
|
|
|
func (noopMetrics) SetObjectCounter(string, string, uint64) {}
|
|
|
|
func (noopMetrics) AddToObjectCounter(string, string, int) {}
|
|
|
|
func (noopMetrics) SetMode(string, mode.Mode) {}
|
|
|
|
func (noopMetrics) AddToContainerSize(string, int64) {}
|
|
|
|
func (noopMetrics) DeleteContainerSize(string) {}
|
|
|
|
func (noopMetrics) DeleteContainerCount(string) {}
|
|
|
|
func (noopMetrics) AddToPayloadCounter(string, int64) {}
|
|
|
|
func (noopMetrics) IncErrorCounter(string) {}
|
|
|
|
func (noopMetrics) ClearErrorCounter(string) {}
|
|
|
|
func (noopMetrics) DeleteShardMetrics(string) {}
|
|
|
|
func (noopMetrics) SetContainerObjectCounter(string, string, string, uint64) {}
|
|
|
|
func (noopMetrics) IncContainerObjectCounter(string, string, string) {}
|
|
|
|
func (noopMetrics) SubContainerObjectCounter(string, string, string, uint64) {}
|
|
|
|
func (noopMetrics) IncRefillObjectsCount(string, string, int, bool) {}
|
|
|
|
func (noopMetrics) SetRefillPercent(string, string, uint32) {}
|
|
|
|
func (noopMetrics) SetRefillStatus(string, string, string) {}
|
|
|
|
func (noopMetrics) SetEvacuationInProgress(string, bool) {}
|
2025-01-13 09:52:02 +00:00
|
|
|
func (noopMetrics) WriteCache() WriteCacheMetrics { return noopWriteCacheMetrics{} }
|
|
|
|
func (noopMetrics) GC() GCMetrics { return noopGCMetrics{} }
|
2024-10-03 07:40:56 +00:00
|
|
|
|
|
|
|
func (noopWriteCacheMetrics) AddMethodDuration(string, string, string, string, bool, time.Duration) {}
|
|
|
|
func (noopWriteCacheMetrics) SetActualCount(string, string, string, uint64) {}
|
|
|
|
func (noopWriteCacheMetrics) SetEstimateSize(string, string, string, uint64) {}
|
|
|
|
func (noopWriteCacheMetrics) SetMode(string, string) {}
|
|
|
|
func (noopWriteCacheMetrics) IncOperationCounter(string, string, string, string, metrics.NullBool) {}
|
|
|
|
func (noopWriteCacheMetrics) Close(string, string) {}
|
|
|
|
|
|
|
|
func (noopGCMetrics) AddRunDuration(string, time.Duration, bool) {}
|
|
|
|
func (noopGCMetrics) AddDeletedCount(string, uint64, uint64) {}
|
|
|
|
func (noopGCMetrics) AddExpiredObjectCollectionDuration(string, time.Duration, bool, string) {}
|
|
|
|
func (noopGCMetrics) AddInhumedObjectCount(string, uint64, string) {}
|