satellite/accounting/tally: calculate pending object count
Change-Id: I4ee6072f4c60fafd809e8184ada9c1abf7edd8aa
This commit is contained in:
parent
c559df6a1b
commit
aea3baf6a9
@ -12,6 +12,7 @@ type BucketTally struct {
|
|||||||
metabase.BucketLocation
|
metabase.BucketLocation
|
||||||
|
|
||||||
ObjectCount int64
|
ObjectCount int64
|
||||||
|
PendingObjectCount int64
|
||||||
TotalSegments int64
|
TotalSegments int64
|
||||||
TotalBytes int64
|
TotalBytes int64
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ type BucketTally struct {
|
|||||||
// Combine aggregates all the tallies.
|
// Combine aggregates all the tallies.
|
||||||
func (s *BucketTally) Combine(o *BucketTally) {
|
func (s *BucketTally) Combine(o *BucketTally) {
|
||||||
s.ObjectCount += o.ObjectCount
|
s.ObjectCount += o.ObjectCount
|
||||||
|
s.PendingObjectCount += o.PendingObjectCount
|
||||||
s.TotalSegments += o.TotalSegments
|
s.TotalSegments += o.TotalSegments
|
||||||
s.TotalBytes += o.TotalBytes
|
s.TotalBytes += o.TotalBytes
|
||||||
}
|
}
|
||||||
|
@ -232,6 +232,7 @@ func (service *Service) Tally(ctx context.Context) (err error) {
|
|||||||
monAccounting.IntVal("total_objects").Observe(total.ObjectCount) //mon:locked
|
monAccounting.IntVal("total_objects").Observe(total.ObjectCount) //mon:locked
|
||||||
monAccounting.IntVal("total_segments").Observe(total.Segments()) //mon:locked
|
monAccounting.IntVal("total_segments").Observe(total.Segments()) //mon:locked
|
||||||
monAccounting.IntVal("total_bytes").Observe(total.Bytes()) //mon:locked
|
monAccounting.IntVal("total_bytes").Observe(total.Bytes()) //mon:locked
|
||||||
|
monAccounting.IntVal("total_pending_objects").Observe(total.PendingObjectCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// return errors if something went wrong.
|
// return errors if something went wrong.
|
||||||
@ -319,6 +320,7 @@ func (observer *BucketTallyCollector) fillBucketTallies(ctx context.Context, sta
|
|||||||
bucket.TotalBytes = tally.TotalBytes
|
bucket.TotalBytes = tally.TotalBytes
|
||||||
bucket.MetadataSize = tally.MetadataSize
|
bucket.MetadataSize = tally.MetadataSize
|
||||||
bucket.ObjectCount = tally.ObjectCount
|
bucket.ObjectCount = tally.ObjectCount
|
||||||
|
bucket.PendingObjectCount = tally.PendingObjectCount
|
||||||
}
|
}
|
||||||
|
|
||||||
lastBucketLocation = bucketLocations[len(bucketLocations)-1]
|
lastBucketLocation = bucketLocations[len(bucketLocations)-1]
|
||||||
|
@ -412,6 +412,7 @@ type BucketTally struct {
|
|||||||
BucketLocation
|
BucketLocation
|
||||||
|
|
||||||
ObjectCount int64
|
ObjectCount int64
|
||||||
|
PendingObjectCount int64
|
||||||
|
|
||||||
TotalSegments int64
|
TotalSegments int64
|
||||||
TotalBytes int64
|
TotalBytes int64
|
||||||
@ -452,7 +453,10 @@ func (db *DB) CollectBucketTallies(ctx context.Context, opts CollectBucketTallie
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = withRows(db.db.QueryContext(ctx, `
|
err = withRows(db.db.QueryContext(ctx, `
|
||||||
SELECT project_id, bucket_name, SUM(total_encrypted_size), SUM(segment_count), COALESCE(SUM(length(encrypted_metadata)), 0), count(*)
|
SELECT
|
||||||
|
project_id, bucket_name,
|
||||||
|
SUM(total_encrypted_size), SUM(segment_count), COALESCE(SUM(length(encrypted_metadata)), 0),
|
||||||
|
count(*), count(*) FILTER (WHERE status = 1)
|
||||||
FROM objects
|
FROM objects
|
||||||
`+db.asOfTime(opts.AsOfSystemTime, opts.AsOfSystemInterval)+`
|
`+db.asOfTime(opts.AsOfSystemTime, opts.AsOfSystemInterval)+`
|
||||||
WHERE (project_id, bucket_name) BETWEEN ($1, $2) AND ($3, $4) AND
|
WHERE (project_id, bucket_name) BETWEEN ($1, $2) AND ($3, $4) AND
|
||||||
@ -467,6 +471,7 @@ func (db *DB) CollectBucketTallies(ctx context.Context, opts CollectBucketTallie
|
|||||||
&bucketTally.ProjectID, &bucketTally.BucketName,
|
&bucketTally.ProjectID, &bucketTally.BucketName,
|
||||||
&bucketTally.TotalBytes, &bucketTally.TotalSegments,
|
&bucketTally.TotalBytes, &bucketTally.TotalSegments,
|
||||||
&bucketTally.MetadataSize, &bucketTally.ObjectCount,
|
&bucketTally.MetadataSize, &bucketTally.ObjectCount,
|
||||||
|
&bucketTally.PendingObjectCount,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return Error.New("unable to query bucket tally: %w", err)
|
return Error.New("unable to query bucket tally: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -851,6 +851,7 @@ func TestCollectBucketTallies(t *testing.T) {
|
|||||||
BucketName: pending.BucketName,
|
BucketName: pending.BucketName,
|
||||||
},
|
},
|
||||||
ObjectCount: 1,
|
ObjectCount: 1,
|
||||||
|
PendingObjectCount: 1,
|
||||||
TotalSegments: 0,
|
TotalSegments: 0,
|
||||||
TotalBytes: 0,
|
TotalBytes: 0,
|
||||||
MetadataSize: 1024,
|
MetadataSize: 1024,
|
||||||
@ -861,6 +862,7 @@ func TestCollectBucketTallies(t *testing.T) {
|
|||||||
BucketName: committed.BucketName,
|
BucketName: committed.BucketName,
|
||||||
},
|
},
|
||||||
ObjectCount: 1,
|
ObjectCount: 1,
|
||||||
|
PendingObjectCount: 0,
|
||||||
TotalSegments: 1,
|
TotalSegments: 1,
|
||||||
TotalBytes: 1024,
|
TotalBytes: 1024,
|
||||||
MetadataSize: 0,
|
MetadataSize: 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user