Skip to content

Commit

Permalink
S3UTILS-155: split the restoring and restored into current and nonCur…
Browse files Browse the repository at this point in the history
…rent
  • Loading branch information
williamlardier committed Mar 26, 2024
1 parent 5596b25 commit 461f8f3
Show file tree
Hide file tree
Showing 7 changed files with 756 additions and 384 deletions.
24 changes: 16 additions & 8 deletions CountItems/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ function consolidateDataMetrics(target, source) {
usedCapacity: {
current: 0,
nonCurrent: 0,
restored: 0,
restoring: 0,
currentCold: 0,
nonCurrentCold: 0,
currentRestored: 0,
currentRestoring: 0,
nonCurrentRestored: 0,
nonCurrentRestoring: 0,
},
});
}
Expand All @@ -25,8 +27,10 @@ function consolidateDataMetrics(target, source) {
nonCurrent: 0,
currentCold: 0,
nonCurrentCold: 0,
restored: 0,
restoring: 0,
currentRestored: 0,
currentRestoring: 0,
nonCurrentRestored: 0,
nonCurrentRestoring: 0,
deleteMarker: 0,
},
});
Expand All @@ -39,16 +43,20 @@ function consolidateDataMetrics(target, source) {
resTarget.usedCapacity.nonCurrent += usedCapacity && usedCapacity.nonCurrent ? usedCapacity.nonCurrent : 0;
resTarget.usedCapacity.currentCold += usedCapacity && usedCapacity.currentCold ? usedCapacity.currentCold : 0;
resTarget.usedCapacity.nonCurrentCold += usedCapacity && usedCapacity.nonCurrentCold ? usedCapacity.nonCurrentCold : 0;
resTarget.usedCapacity.restoring += usedCapacity && usedCapacity.restoring ? usedCapacity.restoring : 0;
resTarget.usedCapacity.restored += usedCapacity && usedCapacity.restored ? usedCapacity.restored : 0;
resTarget.usedCapacity.currentRestoring += usedCapacity && usedCapacity.currentRestoring ? usedCapacity.currentRestoring : 0;
resTarget.usedCapacity.currentRestored += usedCapacity && usedCapacity.currentRestored ? usedCapacity.currentRestored : 0;
resTarget.usedCapacity.nonCurrentRestoring += usedCapacity && usedCapacity.nonCurrentRestoring ? usedCapacity.nonCurrentRestoring : 0;
resTarget.usedCapacity.nonCurrentRestored += usedCapacity && usedCapacity.nonCurrentRestored ? usedCapacity.nonCurrentRestored : 0;

resTarget.objectCount.current += objectCount && objectCount.current ? objectCount.current : 0;
resTarget.objectCount.nonCurrent += objectCount && objectCount.nonCurrent ? objectCount.nonCurrent : 0;
resTarget.objectCount.deleteMarker += objectCount && objectCount.deleteMarker ? objectCount.deleteMarker : 0;
resTarget.objectCount.currentCold += objectCount && objectCount.currentCold ? objectCount.currentCold : 0;
resTarget.objectCount.nonCurrentCold += objectCount && objectCount.nonCurrentCold ? objectCount.nonCurrentCold : 0;
resTarget.objectCount.restoring += objectCount && objectCount.restoring ? objectCount.restoring : 0;
resTarget.objectCount.restored += objectCount && objectCount.restored ? objectCount.restored : 0;
resTarget.objectCount.currentRestoring += objectCount && objectCount.currentRestoring ? objectCount.currentRestoring : 0;
resTarget.objectCount.currentRestored += objectCount && objectCount.currentRestored ? objectCount.currentRestored : 0;
resTarget.objectCount.nonCurrentRestoring += objectCount && objectCount.nonCurrentRestoring ? objectCount.nonCurrentRestoring : 0;
resTarget.objectCount.nonCurrentRestored += objectCount && objectCount.nonCurrentRestored ? objectCount.nonCurrentRestored : 0;
return resTarget;
}

Expand Down
12 changes: 8 additions & 4 deletions DataReport/collectBucketMetricsAndUpdateBucketCapacityInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ function isValidBucketStorageMetrics(bucketMetric) {
&& bucketMetric.usedCapacity.nonCurrent > -1
&& (typeof bucketMetric.usedCapacity.currentCold === 'undefined' || (bucketMetric.usedCapacity.currentCold > -1))
&& (typeof bucketMetric.usedCapacity.nonCurrentCold === 'undefined' || (bucketMetric.usedCapacity.nonCurrentCold > -1))
&& (typeof bucketMetric.usedCapacity.restoring === 'undefined' || (bucketMetric.usedCapacity.restoring > -1))
&& (typeof bucketMetric.usedCapacity.restored === 'undefined' || (bucketMetric.usedCapacity.restored > -1));
&& (typeof bucketMetric.usedCapacity.currentRestoring === 'undefined' || (bucketMetric.usedCapacity.currentRestoring > -1))
&& (typeof bucketMetric.usedCapacity.currentRestored === 'undefined' || (bucketMetric.usedCapacity.currentRestored > -1))
&& (typeof bucketMetric.usedCapacity.nonCurrentRestoring === 'undefined' || (bucketMetric.usedCapacity.nonCurrentRestoring > -1))
&& (typeof bucketMetric.usedCapacity.nonCurrentRestored === 'undefined' || (bucketMetric.usedCapacity.nonCurrentRestored > -1));
}

function isValidCapacityValue(capacity) {
Expand Down Expand Up @@ -83,8 +85,10 @@ function collectBucketMetricsAndUpdateBucketCapacityInfo(mongoClient, log, callb
// Do not count the objects in cold for SOSAPI
bucketStorageUsed = storageMetricDoc.usedCapacity.current
+ storageMetricDoc.usedCapacity.nonCurrent
+ (storageMetricDoc.usedCapacity.restoring || 0)
+ (storageMetricDoc.usedCapacity.restored || 0);
+ (storageMetricDoc.usedCapacity.currentRestoring || 0)
+ (storageMetricDoc.usedCapacity.nonCurrentRestoring || 0)
+ (storageMetricDoc.usedCapacity.currentRestored || 0)
+ (storageMetricDoc.usedCapacity.nonCurrentRestored || 0);
}
// read Capacity from bucket._capabilities
const { Capacity } = bucket.getCapabilities().VeeamSOSApi.CapacityInfo;
Expand Down
Loading

0 comments on commit 461f8f3

Please sign in to comment.