Compare commits

...

5 Commits

Author SHA1 Message Date
Anurag Mittal fff956b02b
added console log statements for putObject 2020-01-21 15:19:32 +01:00
Anurag Mittal 2c0d6c9c13
added get object console.log 2020-01-20 18:53:40 +01:00
Anurag Mittal bf84e8b525
updated arsenal 2020-01-20 18:08:20 +01:00
Anurag Mittal a8e585c2e6
udpdated console.log 2020-01-20 17:53:59 +01:00
Anurag Mittal 1bcf735e3d
added debug statements 2020-01-20 17:33:12 +01:00
1 changed files with 92 additions and 54 deletions

View File

@ -228,6 +228,8 @@ class MongoClientInterface {
}
getBucketAttributes(bucketName, log, cb) {
log.debug('entered getBucketAttributes',
{ database: bucketName });
const m = this.getCollection(METASTORE);
m.findOne({
_id: bucketName,
@ -245,11 +247,15 @@ class MongoClientInterface {
// that properly inits w/o JSON.parse()
const bucketMDStr = JSON.stringify(doc.value);
const bucketMD = BucketInfo.deSerialize(bucketMDStr);
log.debug('exiting getBucketAttributes',
{ database: bucketName });
return cb(null, bucketMD);
});
}
getBucketAndObject(bucketName, objName, params, log, cb) {
log.debug('entered getBucketAndObject',
{ database: bucketName, object: objName });
this.getBucketAttributes(bucketName, log, (err, bucket) => {
if (err) {
log.error(
@ -260,8 +266,11 @@ class MongoClientInterface {
this.getObject(bucketName, objName, params, log, (err, obj) => {
if (err) {
if (err === errors.NoSuchKey) {
log.debug('exiting getBucketAndObject with no such key',
{ database: bucketName, object: objName });
return cb(null,
{ bucket:
{
bucket:
BucketInfo.fromObj(bucket).serialize(),
});
}
@ -269,6 +278,8 @@ class MongoClientInterface {
{ error: err.message });
return cb(err);
}
log.debug('exiting getBucketAndObject',
{ database: bucketName, object: objName });
return cb(null, {
bucket: BucketInfo.fromObj(bucket).serialize(),
obj: JSON.stringify(obj),
@ -618,26 +629,44 @@ class MongoClientInterface {
putObject(bucketName, objName, objVal, params, log, cb) {
MongoUtils.serialize(objVal);
log.debug('entered putObject',
{ database: bucketName, object: objName });
const c = this.getCollection(bucketName);
log.debug('inside putObject, got the collection name',
{ database: bucketName, object: objName });
if (params && params.versioning && !params.versionId) {
log.debug('inside putObject, case: putObjectVerCase1',
{ database: bucketName, object: objName });
return this.putObjectVerCase1(c, bucketName, objName, objVal,
params, log, cb);
} else if (params && params.versionId === '') {
log.debug('inside putObject, case: putObjectVerCase2',
{ database: bucketName, object: objName });
return this.putObjectVerCase2(c, bucketName, objName, objVal,
params, log, cb);
} else if (params && params.versionId && !params.repairMaster) {
log.debug('inside putObject, case: putObjectVerCase3',
{ database: bucketName, object: objName });
return this.putObjectVerCase3(c, bucketName, objName, objVal,
params, log, cb);
} else if (params && params.versionId && params.repairMaster) {
log.debug('inside putObject, case: putObjectVerCase4',
{ database: bucketName, object: objName });
return this.putObjectVerCase4(c, bucketName, objName, objVal,
params, log, cb);
}
log.debug('inside putObject, case: noversion',
{ database: bucketName, object: objName });
return this.putObjectNoVer(c, bucketName, objName, objVal,
params, log, cb);
}
getObject(bucketName, objName, params, log, cb) {
log.debug('entered getObject',
{ database: bucketName, object: objName });
const c = this.getCollection(bucketName);
log.debug('inside getObject, got the collection',
{ database: bucketName, object: objName });
if (params && params.versionId) {
// eslint-disable-next-line
objName = formatVersionKey(objName, params.versionId);
@ -645,12 +674,17 @@ class MongoClientInterface {
c.findOne({
_id: objName,
}, {}, (err, doc) => {
log.debug('inside getObject, inside the cb for findOne query',
{ database: bucketName, object: objName });
if (err) {
log.error('findOne: error getting object',
{ error: err.message });
return cb(errors.InternalError);
}
if (!doc) {
log.debug('inside getObject, got reply from database, obj not found',
{ database: bucketName, object: objName });
return cb(errors.NoSuchKey);
}
if (doc.value.isPHD) {
@ -660,11 +694,15 @@ class MongoClientInterface {
{ error: err.message });
return cb(err);
}
log.debug('exited in PHD getObject',
{ database: bucketName, object: objName });
return cb(null, value);
});
return undefined;
}
MongoUtils.unserialize(doc.value);
log.debug('exited getObject',
{ database: bucketName, object: objName });
return cb(null, doc.value);
});
}