2024-03-12 14:36:26 +00:00
|
|
|
package blobovniczatree
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (b *Blobovniczas) ObjectsCount(ctx context.Context) (uint64, error) {
|
|
|
|
var (
|
|
|
|
success bool
|
|
|
|
startedAt = time.Now()
|
|
|
|
)
|
|
|
|
defer func() {
|
|
|
|
b.metrics.ObjectsCount(time.Since(startedAt), success)
|
|
|
|
}()
|
|
|
|
|
2024-10-21 08:20:17 +00:00
|
|
|
ctx, span := tracing.StartSpanFromContext(ctx, "Blobovniczas.ObjectsCount")
|
2024-03-12 14:36:26 +00:00
|
|
|
defer span.End()
|
|
|
|
|
|
|
|
var result uint64
|
|
|
|
err := b.iterateExistingDBPaths(ctx, func(p string) (bool, error) {
|
|
|
|
shDB := b.getBlobovniczaWithoutCaching(p)
|
2024-10-21 08:20:17 +00:00
|
|
|
blz, err := shDB.Open(ctx)
|
2024-03-12 14:36:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return true, err
|
|
|
|
}
|
|
|
|
defer shDB.Close()
|
|
|
|
|
|
|
|
result += blz.ObjectsCount()
|
|
|
|
return false, nil
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return result, nil
|
|
|
|
}
|