Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: filters out special collections #868

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions lib/storage/metadata/mongoclient/MongoClientInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,19 @@ class MongoClientInterface {
});
}

/*
* return true if it a special collection and therefore
* does not need to be collected for infos
*/
_isSpecialCollection(name) {
return name === METASTORE ||
name === INFOSTORE ||
name === USERSBUCKET ||
name === PENSIEVE ||
name.startsWith(constants.mpuBucketPrefix) ||
name.startsWith('__');
}

/*
* get bucket related information for count items, used by cloudserver
* and s3utils
Expand All @@ -1131,12 +1144,7 @@ class MongoClientInterface {
return cb(err);
}
return async.eachLimit(collInfos, 10, (value, next) => {
if (value.name === METASTORE ||
value.name === INFOSTORE ||
value.name === USERSBUCKET ||
value.name === PENSIEVE ||
value.name.startsWith(constants.mpuBucketPrefix)
) {
if (this.isSpecialCollection(value.name)) {
// skip
return next();
}
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/storage/metadata/mongoclient/MongoClientInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,17 @@ describe('MongoClientInterface::_handleMongo', () => {
});
});
});

describe('MongoClientInterface, misc', () => {
let s3ConfigObj;

beforeEach(() => {
s3ConfigObj = new DummyConfigObject();
});

it('should filter out collections with special names', () => {
const mongoClient = new MongoClientInterface({ config: s3ConfigObj });
assert.equal(mongoClient._isSpecialCollection('__foo'), true);
assert.equal(mongoClient._isSpecialCollection('bar'), false);
});
});