Compare commits
1 Commits
developmen
...
feature/ZE
Author | SHA1 | Date |
---|---|---|
Alexander Chan | 94fd17a221 |
|
@ -72,7 +72,6 @@ class DataCounter {
|
|||
this.objects = setVal.objects;
|
||||
this.versions = setVal.versions;
|
||||
this.buckets = setVal.buckets;
|
||||
this.bucketList = [...setVal.bucketList];
|
||||
this.dataManaged = deepCopyObject(setVal.dataManaged);
|
||||
this.populated = true;
|
||||
}
|
||||
|
@ -87,7 +86,6 @@ class DataCounter {
|
|||
objects: this.objects,
|
||||
versions: this.versions,
|
||||
buckets: this.buckets,
|
||||
bucketList: this.bucketList,
|
||||
dataManaged: this.dataManaged,
|
||||
};
|
||||
return deepCopyObject(obj);
|
||||
|
|
|
@ -114,7 +114,6 @@ class MongoClientInterface {
|
|||
this.replicationGroupId = replicationGroupId;
|
||||
this.database = database;
|
||||
this.lastItemScanTime = null;
|
||||
this.scanInProgress = false;
|
||||
this.dataCount = new DataCounter();
|
||||
if (config && config instanceof EventEmitter) {
|
||||
this.config = config;
|
||||
|
@ -1120,12 +1119,8 @@ class MongoClientInterface {
|
|||
}
|
||||
|
||||
countItems(log, cb) {
|
||||
if (this.scanInProgress || this.lastItemScanTime !== null &&
|
||||
(Date.now() - this.lastItemScanTime) <= itemScanRefreshDelay) {
|
||||
return process.nextTick(cb, null, this.dataCount.results());
|
||||
}
|
||||
|
||||
this.scanInProgress = true;
|
||||
const doFullScan = this.lastItemScanTime === null ||
|
||||
(Date.now() - this.lastItemScanTime) > itemScanRefreshDelay;
|
||||
|
||||
const res = {
|
||||
objects: 0,
|
||||
|
@ -1185,16 +1180,28 @@ class MongoClientInterface {
|
|||
});
|
||||
return next(errors.InternalError);
|
||||
}
|
||||
const retBucketInfo = {
|
||||
name: bucketName,
|
||||
location: bucketInfo.getLocationConstraint(),
|
||||
isVersioned:
|
||||
!!bucketInfo.getVersioningConfiguration(),
|
||||
ownerCanonicalId: bucketInfo.getOwner(),
|
||||
};
|
||||
res.bucketList.push(retBucketInfo);
|
||||
return next(null, bucketInfo);
|
||||
}),
|
||||
(bucketInfo, next) => this.getObjectMDStats(
|
||||
bucketName, bucketInfo, log, next),
|
||||
(bucketInfo, next) => {
|
||||
if (doFullScan) {
|
||||
return next(null, {});
|
||||
}
|
||||
this.getObjectMDStats(
|
||||
bucketName, bucketInfo, log, next);
|
||||
},
|
||||
], (err, results) => {
|
||||
if (err) {
|
||||
return next(errors.InternalError);
|
||||
}
|
||||
if (results.bucketList && results.dataManaged) {
|
||||
res.bucketList.push(results.bucketList);
|
||||
if (results.dataManaged) {
|
||||
res.objects += results.objects;
|
||||
res.versions += results.versions;
|
||||
consolidateData(results.dataManaged);
|
||||
|
@ -1205,10 +1212,16 @@ class MongoClientInterface {
|
|||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
if (doFullScan) {
|
||||
const cachedRes = this.dataCount.results();
|
||||
cachedRes.bucketList = [...res.bucketList];
|
||||
return cb(null, cachedRes);
|
||||
}
|
||||
|
||||
this.lastItemScanTime = Date.now();
|
||||
this.dataCount.set(res);
|
||||
this.scanInProgress = false;
|
||||
return cb(null, this.dataCount.results());
|
||||
return cb(null, res);
|
||||
});
|
||||
});
|
||||
return undefined;
|
||||
|
@ -1398,16 +1411,10 @@ class MongoClientInterface {
|
|||
|
||||
getObjectMDStats(bucketName, bucketInfo, log, callback) {
|
||||
const c = this.getCollection(bucketName);
|
||||
const retBucketInfo = {
|
||||
name: bucketName,
|
||||
location: bucketInfo.getLocationConstraint(),
|
||||
isVersioned: !!bucketInfo.getVersioningConfiguration(),
|
||||
ownerCanonicalId: bucketInfo.getOwner(),
|
||||
};
|
||||
let isTransient;
|
||||
if (this.config) {
|
||||
isTransient = this.config
|
||||
.getLocationConstraint(retBucketInfo.location)
|
||||
.getLocationConstraint(bucketInfo.getLocationConstraint())
|
||||
.isTransient;
|
||||
}
|
||||
const mstFilter = {
|
||||
|
@ -1443,7 +1450,6 @@ class MongoClientInterface {
|
|||
const isVer = (bucketStatus && (bucketStatus.Status === 'Enabled' ||
|
||||
bucketStatus.Status === 'Suspended'));
|
||||
const retResult = this._handleResults(resObj, isVer);
|
||||
retResult.bucketList = retBucketInfo;
|
||||
return callback(null, retResult);
|
||||
});
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -15,7 +15,6 @@ const refZeroObj = {
|
|||
objects: 0,
|
||||
versions: 0,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 0, prev: 0 },
|
||||
byLocation: {},
|
||||
|
@ -26,7 +25,6 @@ const refSingleObj = {
|
|||
objects: 2,
|
||||
versions: 0,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 200, prev: 0 },
|
||||
byLocation: {
|
||||
|
@ -39,7 +37,6 @@ const refSingleObjVer = {
|
|||
objects: 1,
|
||||
versions: 1,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 100, prev: 100 },
|
||||
byLocation: {
|
||||
|
@ -52,7 +49,6 @@ const refMultiObjVer = {
|
|||
objects: 1,
|
||||
versions: 1,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 200, prev: 200 },
|
||||
byLocation: {
|
||||
|
@ -66,7 +62,6 @@ const refMultiObj = {
|
|||
objects: 2,
|
||||
versions: 0,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 400, prev: 0 },
|
||||
byLocation: {
|
||||
|
|
|
@ -18,7 +18,6 @@ const zeroRef = {
|
|||
objects: 0,
|
||||
versions: 0,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 0, prev: 0 },
|
||||
byLocation: {},
|
||||
|
@ -29,7 +28,6 @@ const startRef = {
|
|||
objects: 10,
|
||||
versions: 10,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 1000, prev: 1000 },
|
||||
byLocation: {
|
||||
|
@ -147,7 +145,6 @@ describe('MongoClientInterface::dataCount', () => {
|
|||
objects: 1,
|
||||
versions: 0,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 400, prev: 0 },
|
||||
byLocation: {
|
||||
|
@ -177,7 +174,6 @@ describe('MongoClientInterface::dataCount', () => {
|
|||
objects: 10,
|
||||
versions: 10,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 1300, prev: 1000 },
|
||||
byLocation: {
|
||||
|
@ -207,7 +203,6 @@ describe('MongoClientInterface::dataCount', () => {
|
|||
objects: 10,
|
||||
versions: 11,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 1300, prev: 1100 },
|
||||
byLocation: {
|
||||
|
@ -237,7 +232,6 @@ describe('MongoClientInterface::dataCount', () => {
|
|||
objects: 10,
|
||||
versions: 10,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 1300, prev: 1000 },
|
||||
byLocation: {
|
||||
|
@ -275,7 +269,6 @@ describe('MongoClientInterface::dataCount', () => {
|
|||
objects: 10,
|
||||
versions: 10,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 1000, prev: 1100 },
|
||||
byLocation: {
|
||||
|
@ -288,7 +281,6 @@ describe('MongoClientInterface::dataCount', () => {
|
|||
objects: 10,
|
||||
versions: 10,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 1000, prev: 1200 },
|
||||
byLocation: {
|
||||
|
@ -329,7 +321,6 @@ describe('MongoClientInterface::dataCount', () => {
|
|||
objects: 10,
|
||||
versions: 10,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 1100, prev: 1000 },
|
||||
byLocation: {
|
||||
|
@ -342,7 +333,6 @@ describe('MongoClientInterface::dataCount', () => {
|
|||
objects: 10,
|
||||
versions: 10,
|
||||
buckets: 0,
|
||||
bucketList: [],
|
||||
dataManaged: {
|
||||
total: { curr: 1200, prev: 1000 },
|
||||
byLocation: {
|
||||
|
|
Loading…
Reference in New Issue