Skip to content
Draft
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
174 changes: 92 additions & 82 deletions lib/algos/list/delimiterMaster.ts

Large diffs are not rendered by default.

62 changes: 46 additions & 16 deletions lib/storage/metadata/MetadataWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class MetadataWrapper {
authCredentials: params.mongodb.authCredentials,
shardCollections: params.mongodb.shardCollections,
config: params.config,
getLocationConstraints: params.getLocationConstraints,
logger,
});
this.implName = 'mongoclient';
Expand All @@ -160,6 +161,26 @@ class MetadataWrapper {
this.implName = 'cdmi';
}
this._listingParser = params.customListingParser || _parseListEntries;
// Clean read hides the object versions whose data is not localized
// yet: it is only supported by the mongodb backend for now, and
// silently ignoring it would expose those versions to the clients.
if (params.cleanRead && this.implName !== 'mongoclient') {
throw new Error(`clean read is not supported by the ${this.implName} backend`);
}
this._cleanRead = Boolean(params.cleanRead);
}

/**
* Adds the clean-read flag to the parameters of a read or listing call,
* when the deployment runs with clean read enabled.
* @param {object} [params] - call parameters
* @return {object} parameters carrying the flag
*/
_withCleanRead(params) {
if (!this._cleanRead) {
return params;
}
return Object.assign({}, params, { cleanRead: true });
}

setup(done) {
Expand Down Expand Up @@ -293,18 +314,24 @@ class MetadataWrapper {

getBucketAndObjectMD(bucketName, objName, params, log, cb) {
log.debug('getting bucket and object from metadata', { database: bucketName, object: objName });
this.client.getBucketAndObject(bucketName, objName, params, log, (err, data, raftSessionId) => {
if (err) {
log.debug('error from metadata', { implName: this.implName, err });
return cb(err);
}
log.debug('bucket and object retrieved from metadata', {
database: bucketName,
object: objName,
raftSessionId,
});
return cb(err, data, raftSessionId);
});
this.client.getBucketAndObject(
bucketName,
objName,
this._withCleanRead(params),
log,
(err, data, raftSessionId) => {
if (err) {
log.debug('error from metadata', { implName: this.implName, err });
return cb(err);
}
log.debug('bucket and object retrieved from metadata', {
database: bucketName,
object: objName,
raftSessionId,
});
return cb(err, data, raftSessionId);
},
);
}

getObjectsMD(bucketName, objNamesWithParams, log, cb) {
Expand All @@ -315,7 +342,10 @@ class MetadataWrapper {
return cb(errors.NotImplemented);
}
log.debug('getting objects from metadata', { objects: objNamesWithParams });
return this.client.getObjects(bucketName, objNamesWithParams, log, (err, data) => {
const objects = this._cleanRead
? objNamesWithParams.map(({ key, params }) => ({ key, params: this._withCleanRead(params) }))
: objNamesWithParams;
return this.client.getObjects(bucketName, objects, log, (err, data) => {
if (err) {
log.debug('error getting objects from metadata', {
implName: this.implName,
Expand All @@ -331,7 +361,7 @@ class MetadataWrapper {

getObjectMD(bucketName, objName, params, log, cb) {
log.debug('getting object from metadata');
this.client.getObject(bucketName, objName, params, log, (err, data) => {
this.client.getObject(bucketName, objName, this._withCleanRead(params), log, (err, data) => {
if (err) {
log.debug('error from metadata', { implName: this.implName, err });
return cb(err);
Expand Down Expand Up @@ -364,7 +394,7 @@ class MetadataWrapper {
if (listingParams.listingType === undefined) {
listingParams.listingType = 'Delimiter';
}
this.client.listObject(bucketName, listingParams, log, (err, data) => {
this.client.listObject(bucketName, this._withCleanRead(listingParams), log, (err, data) => {
log.debug('getting object listing from metadata');
if (err) {
log.debug('error from metadata', { implName: this.implName, err });
Expand Down Expand Up @@ -420,7 +450,7 @@ class MetadataWrapper {
}

listMultipartUploads(bucketName, listingParams, log, cb) {
this.client.listMultipartUploads(bucketName, listingParams, log, (err, data) => {
this.client.listMultipartUploads(bucketName, this._withCleanRead(listingParams), log, (err, data) => {
log.debug('getting mpu listing from metadata');
if (err) {
log.debug('error from metadata', { implName: this.implName, err });
Expand Down
Loading
Loading