mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
app/vmstorage/main.go: reduce the difference with cluster version
This commit is contained in:
parent
8be5c0ab16
commit
c9e57d8000
1 changed files with 8 additions and 8 deletions
|
@ -74,7 +74,7 @@ func CheckTimeRange(tr storage.TimeRange) error {
|
|||
// Init initializes vmstorage.
|
||||
func Init(resetCacheIfNeeded func(mrs []storage.MetricRow)) {
|
||||
InitWithoutMetrics(resetCacheIfNeeded)
|
||||
registerStorageMetrics()
|
||||
registerStorageMetrics(Storage)
|
||||
}
|
||||
|
||||
// InitWithoutMetrics must be called instead of Init inside tests.
|
||||
|
@ -103,10 +103,10 @@ func InitWithoutMetrics(resetCacheIfNeeded func(mrs []storage.MetricRow)) {
|
|||
logger.Fatalf("cannot open a storage at %s with -retentionPeriod=%s: %s", *DataPath, retentionPeriod, err)
|
||||
}
|
||||
Storage = strg
|
||||
initStaleSnapshotsRemover()
|
||||
initStaleSnapshotsRemover(strg)
|
||||
|
||||
var m storage.Metrics
|
||||
Storage.UpdateMetrics(&m)
|
||||
strg.UpdateMetrics(&m)
|
||||
tm := &m.TableMetrics
|
||||
partsCount := tm.SmallPartsCount + tm.BigPartsCount
|
||||
blocksCount := tm.SmallBlocksCount + tm.BigBlocksCount
|
||||
|
@ -377,7 +377,7 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||
}
|
||||
}
|
||||
|
||||
func initStaleSnapshotsRemover() {
|
||||
func initStaleSnapshotsRemover(strg *storage.Storage) {
|
||||
staleSnapshotsRemoverCh = make(chan struct{})
|
||||
if *snapshotsMaxAge <= 0 {
|
||||
return
|
||||
|
@ -393,7 +393,7 @@ func initStaleSnapshotsRemover() {
|
|||
return
|
||||
case <-t.C:
|
||||
}
|
||||
if err := Storage.DeleteStaleSnapshots(*snapshotsMaxAge); err != nil {
|
||||
if err := strg.DeleteStaleSnapshots(*snapshotsMaxAge); err != nil {
|
||||
// Use logger.Errorf instead of logger.Fatalf in the hope the error is temporary.
|
||||
logger.Errorf("cannot delete stale snapshots: %s", err)
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ var (
|
|||
|
||||
var activeForceMerges = metrics.NewCounter("vm_active_force_merges")
|
||||
|
||||
func registerStorageMetrics() {
|
||||
func registerStorageMetrics(strg *storage.Storage) {
|
||||
mCache := &storage.Metrics{}
|
||||
var mCacheLock sync.Mutex
|
||||
var lastUpdateTime time.Time
|
||||
|
@ -425,7 +425,7 @@ func registerStorageMetrics() {
|
|||
return mCache
|
||||
}
|
||||
var mc storage.Metrics
|
||||
Storage.UpdateMetrics(&mc)
|
||||
strg.UpdateMetrics(&mc)
|
||||
mCache = &mc
|
||||
lastUpdateTime = time.Now()
|
||||
return mCache
|
||||
|
@ -446,7 +446,7 @@ func registerStorageMetrics() {
|
|||
return float64(minFreeDiskSpaceBytes.N)
|
||||
})
|
||||
metrics.NewGauge(fmt.Sprintf(`vm_storage_is_read_only{path=%q}`, *DataPath), func() float64 {
|
||||
if Storage.IsReadOnly() {
|
||||
if strg.IsReadOnly() {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
|
|
Loading…
Reference in a new issue