summaryrefslogtreecommitdiff
path: root/src/mongo/shell
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2016-05-28 17:55:12 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2016-05-28 17:55:12 -0400
commit6dcdd23dd37ef12c87e71cf59ef01cd82432efe0 (patch)
treec8cfb5acb62c80f375bc37e7d4350382deea6a37 /src/mongo/shell
parentd4ac5673ea3f6cef4ce9dbcec90e31813997a528 (diff)
downloadmongo-6dcdd23dd37ef12c87e71cf59ef01cd82432efe0.tar.gz
SERVER-23971 Clang-Format code
Diffstat (limited to 'src/mongo/shell')
-rw-r--r--src/mongo/shell/bench.cpp33
-rw-r--r--src/mongo/shell/bridge.js95
-rw-r--r--src/mongo/shell/bulk_api.js160
-rw-r--r--src/mongo/shell/collection.js108
-rw-r--r--src/mongo/shell/crud_api.js51
-rw-r--r--src/mongo/shell/db.js75
-rw-r--r--src/mongo/shell/dbshell.cpp3
-rw-r--r--src/mongo/shell/explain_query.js4
-rw-r--r--src/mongo/shell/explainable.js19
-rw-r--r--src/mongo/shell/linenoise.cpp16
-rw-r--r--src/mongo/shell/linenoise_utf8.cpp2
-rw-r--r--src/mongo/shell/mk_wcwidth.cpp375
-rw-r--r--src/mongo/shell/mongo.js4
-rw-r--r--src/mongo/shell/mr.js6
-rw-r--r--src/mongo/shell/query.js21
-rw-r--r--src/mongo/shell/replsettest.js61
-rw-r--r--src/mongo/shell/servers.js36
-rw-r--r--src/mongo/shell/shardingtest.js139
-rw-r--r--src/mongo/shell/shell_options.cpp93
-rw-r--r--src/mongo/shell/shell_utils.cpp4
-rw-r--r--src/mongo/shell/shell_utils_launcher.cpp21
-rw-r--r--src/mongo/shell/shell_utils_launcher.h2
-rw-r--r--src/mongo/shell/types.js5
-rw-r--r--src/mongo/shell/utils.js102
-rw-r--r--src/mongo/shell/utils_auth.js12
-rw-r--r--src/mongo/shell/utils_sh.js150
26 files changed, 542 insertions, 1055 deletions
diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp
index ae9c7b093d9..8413f12b731 100644
--- a/src/mongo/shell/bench.cpp
+++ b/src/mongo/shell/bench.cpp
@@ -34,8 +34,8 @@
#include "mongo/shell/bench.h"
-#include <pcrecpp.h>
#include <iostream>
+#include <pcrecpp.h>
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/namespace_string.h"
@@ -322,7 +322,8 @@ BenchRunOp opFromBson(const BSONObj& op) {
} else if (name == "query") {
uassert(34389,
str::stream() << "Field 'query' is only valid for findOne, find, update, and "
- "remove types. Type is " << opType,
+ "remove types. Type is "
+ << opType,
(opType == "findOne") || (opType == "query") ||
(opType == "find" || (opType == "update") || (opType == "delete") ||
(opType == "remove")));
@@ -886,8 +887,9 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) {
BSONObjBuilder builder;
builder.append("update", nsToCollectionSubstring(op.ns));
BSONArrayBuilder docBuilder(builder.subarrayStart("updates"));
- docBuilder.append(BSON("q" << query << "u" << update << "multi"
- << op.multi << "upsert" << op.upsert));
+ docBuilder.append(BSON(
+ "q" << query << "u" << update << "multi" << op.multi << "upsert"
+ << op.upsert));
docBuilder.done();
builder.append("writeConcern", op.writeConcern);
conn->runCommand(nsToDatabaseSubstring(op.ns).toString(),
@@ -1082,7 +1084,8 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) {
{
stats.trappedErrors.push_back(BSON("error" << ex.what() << "op"
<< opTypeName.find(op.op)->second
- << "count" << count));
+ << "count"
+ << count));
}
if (_config->breakOnTrap)
return;
@@ -1169,11 +1172,11 @@ void BenchRunner::start() {
if (_config->username != "") {
string errmsg;
if (!conn->auth("admin", _config->username, _config->password, errmsg)) {
- uasserted(16704,
- str::stream()
- << "User " << _config->username
- << " could not authenticate to admin db; admin db access is "
- "required to use benchRun with auth enabled");
+ uasserted(
+ 16704,
+ str::stream() << "User " << _config->username
+ << " could not authenticate to admin db; admin db access is "
+ "required to use benchRun with auth enabled");
}
}
@@ -1206,11 +1209,11 @@ void BenchRunner::stop() {
string errmsg;
// this can only fail if admin access was revoked since start of run
if (!conn->auth("admin", _config->username, _config->password, errmsg)) {
- uasserted(16705,
- str::stream()
- << "User " << _config->username
- << " could not authenticate to admin db; admin db access is "
- "still required to use benchRun with auth enabled");
+ uasserted(
+ 16705,
+ str::stream() << "User " << _config->username
+ << " could not authenticate to admin db; admin db access is "
+ "still required to use benchRun with auth enabled");
}
}
}
diff --git a/src/mongo/shell/bridge.js b/src/mongo/shell/bridge.js
index 7f621f14a52..74e6e674d71 100644
--- a/src/mongo/shell/bridge.js
+++ b/src/mongo/shell/bridge.js
@@ -36,7 +36,11 @@ function MongoBridge(options) {
// Start the mongobridge on port 'this.port' routing network traffic to 'this.dest'.
var args = ['mongobridge', '--port', this.port, '--dest', this.dest];
- var keysToSkip = ['dest', 'hostName', 'port', ];
+ var keysToSkip = [
+ 'dest',
+ 'hostName',
+ 'port',
+ ];
// Append any command line arguments that are optional for mongobridge.
Object.keys(options).forEach(function(key) {
@@ -95,14 +99,12 @@ function MongoBridge(options) {
// connection object that is equivalent to its 'host' property. Certain functions in
// ReplSetTest and ShardingTest use the 'name' property instead of the 'host' property, so
// we define it here for consistency.
- Object.defineProperty(userConn,
- 'name',
- {
- enumerable: true,
- get: function() {
- return this.host;
- },
- });
+ Object.defineProperty(userConn, 'name', {
+ enumerable: true,
+ get: function() {
+ return this.host;
+ },
+ });
controlConn = new Mongo(hostName + ':' + this.port);
};
@@ -229,12 +231,10 @@ function MongoBridge(options) {
bridges.forEach(throwErrorIfNotMongoBridgeInstance);
bridges.forEach(bridge => {
- var res = runBridgeCommand(controlConn,
- 'delayMessagesFrom',
- {
- host: bridge.dest,
- delay: delay,
- });
+ var res = runBridgeCommand(controlConn, 'delayMessagesFrom', {
+ host: bridge.dest,
+ delay: delay,
+ });
assert.commandWorked(res,
'failed to configure the mongobridge listening on port ' +
this.port + ' to delay messages from ' + bridge.dest + ' by ' +
@@ -256,12 +256,10 @@ function MongoBridge(options) {
bridges.forEach(throwErrorIfNotMongoBridgeInstance);
bridges.forEach(bridge => {
- var res = runBridgeCommand(controlConn,
- 'discardMessagesFrom',
- {
- host: bridge.dest,
- loss: lossProbability,
- });
+ var res = runBridgeCommand(controlConn, 'discardMessagesFrom', {
+ host: bridge.dest,
+ loss: lossProbability,
+ });
assert.commandWorked(res,
'failed to configure the mongobridge listening on port ' +
this.port + ' to discard messages from ' + bridge.dest +
@@ -272,32 +270,31 @@ function MongoBridge(options) {
// Use a Proxy to "extend" the underlying connection object. The C++ functions, e.g.
// runCommand(), require that they are called on the Mongo instance itself and so typical
// prototypical inheritance isn't possible.
- return new Proxy(this,
- {
- get: function get(target, property, receiver) {
- // If the property is defined on the MongoBridge instance itself, then
- // return it.
- // Otherwise, get the value of the property from the Mongo instance.
- if (target.hasOwnProperty(property)) {
- return target[property];
- }
- var value = userConn[property];
- if (typeof value === 'function') {
- return value.bind(userConn);
- }
- return value;
- },
-
- set: function set(target, property, value, receiver) {
- // Delegate setting the value of any property to the Mongo instance so
- // that it can be
- // accessed in functions acting on the Mongo instance directly instead of
- // this Proxy.
- // For example, the "slaveOk" property needs to be set on the Mongo
- // instance in order
- // for the query options bit to be set correctly.
- userConn[property] = value;
- return true;
- },
- });
+ return new Proxy(this, {
+ get: function get(target, property, receiver) {
+ // If the property is defined on the MongoBridge instance itself, then
+ // return it.
+ // Otherwise, get the value of the property from the Mongo instance.
+ if (target.hasOwnProperty(property)) {
+ return target[property];
+ }
+ var value = userConn[property];
+ if (typeof value === 'function') {
+ return value.bind(userConn);
+ }
+ return value;
+ },
+
+ set: function set(target, property, value, receiver) {
+ // Delegate setting the value of any property to the Mongo instance so
+ // that it can be
+ // accessed in functions acting on the Mongo instance directly instead of
+ // this Proxy.
+ // For example, the "slaveOk" property needs to be set on the Mongo
+ // instance in order
+ // for the query options bit to be set correctly.
+ userConn[property] = value;
+ return true;
+ },
+ });
}
diff --git a/src/mongo/shell/bulk_api.js b/src/mongo/shell/bulk_api.js
index 8ef10b5c976..2dfe15d65d2 100644
--- a/src/mongo/shell/bulk_api.js
+++ b/src/mongo/shell/bulk_api.js
@@ -22,14 +22,12 @@ var _bulk_api_module = (function() {
* Helper function to define properties
*/
var defineReadOnlyProperty = function(self, name, value) {
- Object.defineProperty(self,
- name,
- {
- enumerable: true,
- get: function() {
- return value;
- }
- });
+ Object.defineProperty(self, name, {
+ enumerable: true,
+ get: function() {
+ return value;
+ }
+ });
};
/**
@@ -543,26 +541,24 @@ var _bulk_api_module = (function() {
var batches = [];
var defineBatchTypeCounter = function(self, name, type) {
- Object.defineProperty(self,
- name,
- {
- enumerable: true,
- get: function() {
- var counter = 0;
-
- for (var i = 0; i < batches.length; i++) {
- if (batches[i].batchType == type) {
- counter += batches[i].operations.length;
- }
- }
-
- if (currentBatch && currentBatch.batchType == type) {
- counter += currentBatch.operations.length;
- }
-
- return counter;
- }
- });
+ Object.defineProperty(self, name, {
+ enumerable: true,
+ get: function() {
+ var counter = 0;
+
+ for (var i = 0; i < batches.length; i++) {
+ if (batches[i].batchType == type) {
+ counter += batches[i].operations.length;
+ }
+ }
+
+ if (currentBatch && currentBatch.batchType == type) {
+ counter += currentBatch.operations.length;
+ }
+
+ return counter;
+ }
+ });
};
defineBatchTypeCounter(this, "nInsertOps", INSERT);
@@ -634,9 +630,7 @@ var _bulk_api_module = (function() {
var addIdIfNeeded = function(obj) {
if (typeof(obj._id) == "undefined" && !Array.isArray(obj)) {
var tmp = obj; // don't want to modify input
- obj = {
- _id: new ObjectId()
- };
+ obj = {_id: new ObjectId()};
for (var key in tmp) {
obj[key] = tmp[key];
}
@@ -667,12 +661,8 @@ var _bulk_api_module = (function() {
// Set the top value for the update 0 = multi true, 1 = multi false
var upsert = typeof currentOp.upsert == 'boolean' ? currentOp.upsert : false;
// Establish the update command
- var document = {
- q: currentOp.selector,
- u: updateDocument,
- multi: true,
- upsert: upsert
- };
+ var document =
+ {q: currentOp.selector, u: updateDocument, multi: true, upsert: upsert};
// Copy over the collation, if we have one.
if (currentOp.hasOwnProperty('collation')) {
@@ -691,12 +681,8 @@ var _bulk_api_module = (function() {
// Set the top value for the update 0 = multi true, 1 = multi false
var upsert = typeof currentOp.upsert == 'boolean' ? currentOp.upsert : false;
// Establish the update command
- var document = {
- q: currentOp.selector,
- u: updateDocument,
- multi: false,
- upsert: upsert
- };
+ var document =
+ {q: currentOp.selector, u: updateDocument, multi: false, upsert: upsert};
// Copy over the collation, if we have one.
if (currentOp.hasOwnProperty('collation')) {
@@ -723,10 +709,7 @@ var _bulk_api_module = (function() {
collection._validateRemoveDoc(currentOp.selector);
// Establish the removeOne command
- var document = {
- q: currentOp.selector,
- limit: 1
- };
+ var document = {q: currentOp.selector, limit: 1};
// Copy over the collation, if we have one.
if (currentOp.hasOwnProperty('collation')) {
@@ -743,10 +726,7 @@ var _bulk_api_module = (function() {
collection._validateRemoveDoc(currentOp.selector);
// Establish the remove command
- var document = {
- q: currentOp.selector,
- limit: 0
- };
+ var document = {q: currentOp.selector, limit: 0};
// Copy over the collation, if we have one.
if (currentOp.hasOwnProperty('collation')) {
@@ -781,9 +761,7 @@ var _bulk_api_module = (function() {
if (selector == undefined)
throw Error("find() requires query criteria");
// Save a current selector
- currentOp = {
- selector: selector
- };
+ currentOp = {selector: selector};
// Return the find Operations
return findOperations;
@@ -857,11 +835,7 @@ var _bulk_api_module = (function() {
// Generate the right update
if (batch.batchType == UPDATE) {
- cmd = {
- update: coll.getName(),
- updates: batch.operations,
- ordered: ordered
- };
+ cmd = {update: coll.getName(), updates: batch.operations, ordered: ordered};
} else if (batch.batchType == INSERT) {
var transformedInserts = [];
batch.operations.forEach(function(insertDoc) {
@@ -869,17 +843,9 @@ var _bulk_api_module = (function() {
});
batch.operations = transformedInserts;
- cmd = {
- insert: coll.getName(),
- documents: batch.operations,
- ordered: ordered
- };
+ cmd = {insert: coll.getName(), documents: batch.operations, ordered: ordered};
} else if (batch.batchType == REMOVE) {
- cmd = {
- delete: coll.getName(),
- deletes: batch.operations,
- ordered: ordered
- };
+ cmd = {delete: coll.getName(), deletes: batch.operations, ordered: ordered};
}
// If we have a write concern
@@ -910,7 +876,8 @@ var _bulk_api_module = (function() {
-1 /* limit */,
0 /* skip */,
0 /* batchSize */,
- 0 /* flags */).next();
+ 0 /* flags */)
+ .next();
if (result.ok == 0) {
throw new WriteCommandError(result);
@@ -971,17 +938,11 @@ var _bulk_api_module = (function() {
var code = gleResponse.code;
var timeout = gleResponse.wtimeout ? true : false;
- var extractedErr = {
- writeError: null,
- wcError: null,
- unknownError: null
- };
+ var extractedErr = {writeError: null, wcError: null, unknownError: null};
if (err == 'norepl' || err == 'noreplset') {
// Know this is legacy gle and the repl not enforced - write concern error in 2.4.
- var errObj = {
- code: WRITE_CONCERN_FAILED
- };
+ var errObj = {code: WRITE_CONCERN_FAILED};
if (errMsg != '') {
errObj.errmsg = errMsg;
@@ -994,9 +955,7 @@ var _bulk_api_module = (function() {
extractedErr.wcError = errObj;
} else if (timeout) {
// Know there was not write error.
- var errObj = {
- code: WRITE_CONCERN_FAILED
- };
+ var errObj = {code: WRITE_CONCERN_FAILED};
if (errMsg != '') {
errObj.errmsg = errMsg;
@@ -1004,35 +963,21 @@ var _bulk_api_module = (function() {
errObj.errmsg = err;
}
- errObj.errInfo = {
- wtimeout: true
- };
+ errObj.errInfo = {wtimeout: true};
extractedErr.wcError = errObj;
} else if (code == 19900 || // No longer primary
code == 16805 || // replicatedToNum no longer primary
code == 14330 || // gle wmode changed; invalid
code == NOT_MASTER ||
code == UNKNOWN_REPL_WRITE_CONCERN || code == WRITE_CONCERN_FAILED) {
- extractedErr.wcError = {
- code: code,
- errmsg: errMsg
- };
+ extractedErr.wcError = {code: code, errmsg: errMsg};
} else if (!isOK) {
// This is a GLE failure we don't understand
- extractedErr.unknownError = {
- code: code,
- errmsg: errMsg
- };
+ extractedErr.unknownError = {code: code, errmsg: errMsg};
} else if (err != '') {
- extractedErr.writeError = {
- code: (code == 0) ? UNKNOWN_ERROR : code,
- errmsg: err
- };
+ extractedErr.writeError = {code: (code == 0) ? UNKNOWN_ERROR : code, errmsg: err};
} else if (jNote != '') {
- extractedErr.writeError = {
- code: WRITE_CONCERN_FAILED,
- errmsg: jNote
- };
+ extractedErr.writeError = {code: WRITE_CONCERN_FAILED, errmsg: jNote};
}
// Handling of writeback not needed for mongo shell.
@@ -1043,9 +988,7 @@ var _bulk_api_module = (function() {
* getLastErrorMethod that supports all write concerns
*/
var executeGetLastError = function(db, options) {
- var cmd = {
- getlasterror: 1
- };
+ var cmd = {getlasterror: 1};
cmd = Object.extend(cmd, options);
// Execute the getLastErrorCommand
return db.runCommand(cmd);
@@ -1054,11 +997,7 @@ var _bulk_api_module = (function() {
// Execute the operations, serially
var executeBatchWithLegacyOps = function(batch) {
- var batchResult = {
- n: 0,
- writeErrors: [],
- upserted: []
- };
+ var batchResult = {n: 0, writeErrors: [], upserted: []};
var extractedErr = null;
@@ -1234,10 +1173,7 @@ var _bulk_api_module = (function() {
var explainBatch = batches[0];
var writeCmd = buildBatchCmd(explainBatch);
- return {
- "explain": writeCmd,
- "verbosity": verbosity
- };
+ return {"explain": writeCmd, "verbosity": verbosity};
};
};
diff --git a/src/mongo/shell/collection.js b/src/mongo/shell/collection.js
index 72efdbaaf97..67f4d8327dc 100644
--- a/src/mongo/shell/collection.js
+++ b/src/mongo/shell/collection.js
@@ -192,27 +192,19 @@ DBCollection.prototype._massageObject = function(q) {
var type = typeof q;
if (type == "function")
- return {
- $where: q
- };
+ return {$where: q};
if (q.isObjectId)
- return {
- _id: q
- };
+ return {_id: q};
if (type == "object")
return q;
if (type == "string") {
if (q.length == 24)
- return {
- _id: q
- };
+ return {_id: q};
- return {
- $where: q
- };
+ return {$where: q};
}
throw Error("don't know how to massage : " + type);
@@ -369,9 +361,7 @@ DBCollection.prototype.insert = function(obj, options, _allow_dot) {
if (typeof(obj._id) == "undefined" && !Array.isArray(obj)) {
var tmp = obj; // don't want to modify input
- obj = {
- _id: new ObjectId()
- };
+ obj = {_id: new ObjectId()};
for (var key in tmp) {
obj[key] = tmp[key];
}
@@ -428,12 +418,7 @@ DBCollection.prototype._parseRemove = function(t, justOne) {
wc = this.getWriteConcern();
}
- return {
- "query": query,
- "justOne": justOne,
- "wc": wc,
- "collation": collation
- };
+ return {"query": query, "justOne": justOne, "wc": wc, "collation": collation};
};
DBCollection.prototype.remove = function(t, justOne) {
@@ -645,11 +630,7 @@ DBCollection.prototype._genIndexName = function(keys) {
};
DBCollection.prototype._indexSpec = function(keys, options) {
- var ret = {
- ns: this._fullName,
- key: keys,
- name: this._genIndexName(keys)
- };
+ var ret = {ns: this._fullName, key: keys, name: this._genIndexName(keys)};
if (!options) {
} else if (typeof(options) == "string")
@@ -710,15 +691,9 @@ DBCollection.prototype.createIndexes = function(keys, options) {
// Return the first error
var error = result.hasWriteErrors() ? result.getWriteErrors()[0]
: result.getWriteConcernError();
- return {
- ok: 0.0,
- code: error.code,
- errmsg: error.errmsg
- };
+ return {ok: 0.0, code: error.code, errmsg: error.errmsg};
} else {
- return {
- ok: 1.0
- };
+ return {ok: 1.0};
}
} else {
this._db.getCollection("system.indexes").insert(indexSpecs, 0, true);
@@ -771,9 +746,7 @@ DBCollection.prototype.drop = function() {
};
DBCollection.prototype.findAndModify = function(args) {
- var cmd = {
- findandmodify: this.getName()
- };
+ var cmd = {findandmodify: this.getName()};
for (var key in args) {
cmd[key] = args[key];
}
@@ -825,9 +798,7 @@ DBCollection.prototype._printExtraInfo = function(action, startTime) {
};
DBCollection.prototype.validate = function(full) {
- var cmd = {
- validate: this.getName()
- };
+ var cmd = {validate: this.getName()};
if (typeof(full) == 'object') // support arbitrary options here
Object.extend(cmd, full);
@@ -864,10 +835,7 @@ DBCollection.prototype.validate = function(full) {
* getDiskStorageStats provides a human-readable summary of the command output
*/
DBCollection.prototype.diskStorageStats = function(opt) {
- var cmd = {
- storageDetails: this.getName(),
- analyze: 'diskStorage'
- };
+ var cmd = {storageDetails: this.getName(), analyze: 'diskStorage'};
if (typeof(opt) == 'object')
Object.extend(cmd, opt);
@@ -894,11 +862,12 @@ DBCollection.prototype.getDiskStorageStats = function(params) {
var BAR_WIDTH = 70;
var formatSliceData = function(data) {
- var bar = _barFormat([
- [data.bsonBytes / data.onDiskBytes, "="],
- [(data.recBytes - data.bsonBytes) / data.onDiskBytes, "-"]
- ],
- BAR_WIDTH);
+ var bar = _barFormat(
+ [
+ [data.bsonBytes / data.onDiskBytes, "="],
+ [(data.recBytes - data.bsonBytes) / data.onDiskBytes, "-"]
+ ],
+ BAR_WIDTH);
return sh._dataFormat(data.onDiskBytes).pad(9) + " " + data.numEntries.toFixed(0).pad(10) +
" " + bar + " " + (data.bsonBytes / data.onDiskBytes).toPercentStr().pad(8) + " " +
@@ -943,10 +912,7 @@ DBCollection.prototype.getDiskStorageStats = function(params) {
* getPagesInRAM provides a human-readable summary of the command output
*/
DBCollection.prototype.pagesInRAM = function(opt) {
- var cmd = {
- storageDetails: this.getName(),
- analyze: 'pagesInRAM'
- };
+ var cmd = {storageDetails: this.getName(), analyze: 'pagesInRAM'};
if (typeof(opt) == 'object')
Object.extend(cmd, opt);
@@ -1031,9 +997,7 @@ DBCollection.prototype.getShardVersion = function() {
DBCollection.prototype._getIndexesSystemIndexes = function(filter) {
var si = this.getDB().getCollection("system.indexes");
- var query = {
- ns: this.getFullName()
- };
+ var query = {ns: this.getFullName()};
if (filter)
query = Object.extend(query, filter);
return si.find(query).toArray();
@@ -1081,10 +1045,7 @@ DBCollection.prototype.getIndexKeys = function() {
};
DBCollection.prototype.hashAllDocs = function() {
- var cmd = {
- dbhash: 1,
- collections: [this._shortName]
- };
+ var cmd = {dbhash: 1, collections: [this._shortName]};
var res = this._dbCommand(cmd);
var hash = res.collections[this._shortName];
assert(hash);
@@ -1296,9 +1257,7 @@ DBCollection.prototype.aggregate = function(pipeline, aggregateOptions) {
// Assign the cleaned up options
aggregateOptions = copy;
// Create the initial command document
- var cmd = {
- pipeline: pipeline
- };
+ var cmd = {pipeline: pipeline};
Object.extend(cmd, aggregateOptions);
if (!('cursor' in cmd)) {
@@ -1329,10 +1288,7 @@ DBCollection.prototype.aggregate = function(pipeline, aggregateOptions) {
if ('result' in res && !("cursor" in res)) {
// convert old-style output to cursor-style output
- res.cursor = {
- ns: '',
- id: NumberLong(0)
- };
+ res.cursor = {ns: '', id: NumberLong(0)};
res.cursor.firstBatch = res.result;
delete res.result;
}
@@ -1407,11 +1363,7 @@ DBCollection.prototype.convertToSingleObject = function(valueField) {
* @param optional object of optional fields;
*/
DBCollection.prototype.mapReduce = function(map, reduce, optionsOrOutString) {
- var c = {
- mapreduce: this._shortName,
- map: map,
- reduce: reduce
- };
+ var c = {mapreduce: this._shortName, map: map, reduce: reduce};
assert(optionsOrOutString, "need to supply an optionsOrOutString");
if (typeof(optionsOrOutString) == "string")
@@ -1776,11 +1728,7 @@ DBCollection.prototype.distinct = function(keyString, query, options) {
}
// Distinct command
- var cmd = {
- distinct: this.getName(),
- key: keyString,
- query: query || {}
- };
+ var cmd = {distinct: this.getName(), key: keyString, query: query || {}};
// Set maxTimeMS if provided
if (opts.maxTimeMS) {
@@ -1925,8 +1873,10 @@ PlanCache.prototype.clear = function() {
* List plans for a query shape.
*/
PlanCache.prototype.getPlansByQuery = function(query, projection, sort) {
- return this._runCommandThrowOnError("planCacheListPlans",
- this._parseQueryShape(query, projection, sort)).plans;
+ return this
+ ._runCommandThrowOnError("planCacheListPlans",
+ this._parseQueryShape(query, projection, sort))
+ .plans;
};
/**
diff --git a/src/mongo/shell/crud_api.js b/src/mongo/shell/crud_api.js
index 9a2d74ab62c..dafbb10510d 100644
--- a/src/mongo/shell/crud_api.js
+++ b/src/mongo/shell/crud_api.js
@@ -29,9 +29,7 @@ DBCollection.prototype._createWriteConcern = function(options) {
DBCollection.prototype.addIdIfNeeded = function(obj) {
if (typeof(obj._id) == "undefined" && !Array.isArray(obj)) {
var tmp = obj; // don't want to modify input
- obj = {
- _id: new ObjectId()
- };
+ obj = {_id: new ObjectId()};
for (var key in tmp) {
obj[key] = tmp[key];
@@ -74,9 +72,7 @@ DBCollection.prototype.bulkWrite = function(operations, options) {
var writeConcern = this._createWriteConcern(opts);
// Result
- var result = {
- acknowledged: (writeConcern && writeConcern.w == 0) ? false : true
- };
+ var result = {acknowledged: (writeConcern && writeConcern.w == 0) ? false : true};
// Use bulk operation API already in the shell
var bulkOp = opts.ordered ? this.initializeOrderedBulkOp() : this.initializeUnorderedBulkOp();
@@ -230,9 +226,7 @@ DBCollection.prototype.insertOne = function(document, options) {
var writeConcern = this._createWriteConcern(opts);
// Result
- var result = {
- acknowledged: (writeConcern && writeConcern.w == 0) ? false : true
- };
+ var result = {acknowledged: (writeConcern && writeConcern.w == 0) ? false : true};
// Use bulk operation API already in the shell
var bulk = this.initializeOrderedBulkOp();
@@ -289,9 +283,7 @@ DBCollection.prototype.insertMany = function(documents, options) {
var writeConcern = this._createWriteConcern(opts);
// Result
- var result = {
- acknowledged: (writeConcern && writeConcern.w == 0) ? false : true
- };
+ var result = {acknowledged: (writeConcern && writeConcern.w == 0) ? false : true};
// Use bulk operation API already in the shell
var bulk = opts.ordered ? this.initializeOrderedBulkOp() : this.initializeUnorderedBulkOp();
@@ -335,9 +327,7 @@ DBCollection.prototype.deleteOne = function(filter, options) {
var writeConcern = this._createWriteConcern(opts);
// Result
- var result = {
- acknowledged: (writeConcern && writeConcern.w == 0) ? false : true
- };
+ var result = {acknowledged: (writeConcern && writeConcern.w == 0) ? false : true};
// Use bulk operation API already in the shell
var bulk = this.initializeOrderedBulkOp();
@@ -392,9 +382,7 @@ DBCollection.prototype.deleteMany = function(filter, options) {
var writeConcern = this._createWriteConcern(opts);
// Result
- var result = {
- acknowledged: (writeConcern && writeConcern.w == 0) ? false : true
- };
+ var result = {acknowledged: (writeConcern && writeConcern.w == 0) ? false : true};
// Use bulk operation API already in the shell
var bulk = this.initializeOrderedBulkOp();
@@ -458,9 +446,7 @@ DBCollection.prototype.replaceOne = function(filter, replacement, options) {
var writeConcern = this._createWriteConcern(opts);
// Result
- var result = {
- acknowledged: (writeConcern && writeConcern.w == 0) ? false : true
- };
+ var result = {acknowledged: (writeConcern && writeConcern.w == 0) ? false : true};
// Use bulk operation API already in the shell
var bulk = this.initializeOrderedBulkOp();
@@ -537,9 +523,7 @@ DBCollection.prototype.updateOne = function(filter, update, options) {
var writeConcern = this._createWriteConcern(opts);
// Result
- var result = {
- acknowledged: (writeConcern && writeConcern.w == 0) ? false : true
- };
+ var result = {acknowledged: (writeConcern && writeConcern.w == 0) ? false : true};
// Use bulk operation API already in the shell
var bulk = this.initializeOrderedBulkOp();
@@ -616,9 +600,7 @@ DBCollection.prototype.updateMany = function(filter, update, options) {
var writeConcern = this._createWriteConcern(opts);
// Result
- var result = {
- acknowledged: (writeConcern && writeConcern.w == 0) ? false : true
- };
+ var result = {acknowledged: (writeConcern && writeConcern.w == 0) ? false : true};
// Use bulk operation API already in the shell
var bulk = this.initializeOrderedBulkOp();
@@ -680,10 +662,7 @@ DBCollection.prototype.updateMany = function(filter, update, options) {
DBCollection.prototype.findOneAndDelete = function(filter, options) {
var opts = Object.extend({}, options || {});
// Set up the command
- var cmd = {
- query: filter,
- remove: true
- };
+ var cmd = {query: filter, remove: true};
if (opts.sort) {
cmd.sort = opts.sort;
@@ -741,10 +720,7 @@ DBCollection.prototype.findOneAndReplace = function(filter, replacement, options
}
// Set up the command
- var cmd = {
- query: filter,
- update: replacement
- };
+ var cmd = {query: filter, update: replacement};
if (opts.sort) {
cmd.sort = opts.sort;
}
@@ -809,10 +785,7 @@ DBCollection.prototype.findOneAndUpdate = function(filter, update, options) {
}
// Set up the command
- var cmd = {
- query: filter,
- update: update
- };
+ var cmd = {query: filter, update: update};
if (opts.sort) {
cmd.sort = opts.sort;
}
diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js
index 6330b9abe32..4f98467f840 100644
--- a/src/mongo/shell/db.js
+++ b/src/mongo/shell/db.js
@@ -62,10 +62,7 @@ var DB;
// The server selection spec mandates that the key is '$query', but
// the shell has historically used 'query'. The server accepts both,
// so we maintain the existing behavior
- var cmdObjWithReadPref = {
- query: clonedCmdObj,
- $readPreference: readPref
- };
+ var cmdObjWithReadPref = {query: clonedCmdObj, $readPreference: readPref};
return cmdObjWithReadPref;
};
@@ -233,9 +230,7 @@ var DB;
options.flags = flags;
}
- var cmd = {
- create: name
- };
+ var cmd = {create: name};
Object.extend(cmd, options);
return this._dbCommand(cmd);
@@ -288,9 +283,7 @@ var DB;
return "shutdown command only works with the admin database; try 'use admin'";
}
- var cmd = {
- 'shutdown': 1
- };
+ var cmd = {'shutdown': 1};
opts = opts || {};
for (var o in opts) {
cmd[o] = opts[o];
@@ -531,9 +524,7 @@ var DB;
throw errorObject;
}
- var cmd = {
- profile: level
- };
+ var cmd = {profile: level};
if (isNumber(slowms))
cmd["slowms"] = slowms;
return assert.commandWorked(this._dbCommand(cmd));
@@ -566,9 +557,7 @@ var DB;
DB.prototype.eval = function(jsfunction) {
print("WARNING: db.eval is deprecated");
- var cmd = {
- $eval: jsfunction
- };
+ var cmd = {$eval: jsfunction};
if (arguments.length > 1) {
cmd.args = Array.from(arguments).slice(1);
}
@@ -697,9 +686,7 @@ var DB;
return res.err;
};
DB.prototype.getLastErrorObj = function(w, wtimeout) {
- var cmd = {
- getlasterror: 1
- };
+ var cmd = {getlasterror: 1};
if (w) {
cmd.w = w;
if (wtimeout)
@@ -825,9 +812,7 @@ var DB;
q["$all"] = true;
}
- var commandObj = {
- "currentOp": 1
- };
+ var commandObj = {"currentOp": 1};
Object.extend(commandObj, q);
var res = this.adminCommand(commandObj);
if (commandUnsupported(res)) {
@@ -1081,9 +1066,7 @@ var DB;
};
DB.prototype.serverStatus = function(options) {
- var cmd = {
- serverStatus: 1
- };
+ var cmd = {serverStatus: 1};
if (options) {
Object.extend(cmd, options);
}
@@ -1200,10 +1183,7 @@ var DB;
/////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
- var _defaultWriteConcern = {
- w: 'majority',
- wtimeout: 30 * 1000
- };
+ var _defaultWriteConcern = {w: 'majority', wtimeout: 30 * 1000};
function getUserObjString(userObj) {
var pwd = userObj.pwd;
@@ -1237,9 +1217,7 @@ var DB;
DB.prototype.createUser = function(userObj, writeConcern) {
var name = userObj["user"];
- var cmdObj = {
- createUser: name
- };
+ var cmdObj = {createUser: name};
cmdObj = Object.extend(cmdObj, userObj);
delete cmdObj["user"];
@@ -1299,9 +1277,7 @@ var DB;
};
DB.prototype.updateUser = function(name, updateObject, writeConcern) {
- var cmdObj = {
- updateUser: name
- };
+ var cmdObj = {updateUser: name};
cmdObj = Object.extend(cmdObj, updateObject);
cmdObj['writeConcern'] = writeConcern ? writeConcern : _defaultWriteConcern;
this._modifyCommandToDigestPasswordIfNecessary(cmdObj, name);
@@ -1412,10 +1388,7 @@ var DB;
DB.prototype._authOrThrow = function() {
var params;
if (arguments.length == 2) {
- params = {
- user: arguments[0],
- pwd: arguments[1]
- };
+ params = {user: arguments[0], pwd: arguments[1]};
} else if (arguments.length == 1) {
if (typeof(arguments[0]) != "object")
throw Error("Single-argument form of auth expects a parameter object");
@@ -1490,9 +1463,7 @@ var DB;
if (typeof username != "string") {
throw Error("User name for getUser shell helper must be a string");
}
- var cmdObj = {
- usersInfo: username
- };
+ var cmdObj = {usersInfo: username};
Object.extend(cmdObj, args);
var res = this.runCommand(cmdObj);
@@ -1507,9 +1478,7 @@ var DB;
};
DB.prototype.getUsers = function(args) {
- var cmdObj = {
- usersInfo: 1
- };
+ var cmdObj = {usersInfo: 1};
Object.extend(cmdObj, args);
var res = this.runCommand(cmdObj);
if (!res.ok) {
@@ -1528,9 +1497,7 @@ var DB;
DB.prototype.createRole = function(roleObj, writeConcern) {
var name = roleObj["role"];
- var cmdObj = {
- createRole: name
- };
+ var cmdObj = {createRole: name};
cmdObj = Object.extend(cmdObj, roleObj);
delete cmdObj["role"];
cmdObj["writeConcern"] = writeConcern ? writeConcern : _defaultWriteConcern;
@@ -1544,9 +1511,7 @@ var DB;
};
DB.prototype.updateRole = function(name, updateObject, writeConcern) {
- var cmdObj = {
- updateRole: name
- };
+ var cmdObj = {updateRole: name};
cmdObj = Object.extend(cmdObj, updateObject);
cmdObj['writeConcern'] = writeConcern ? writeConcern : _defaultWriteConcern;
var res = this.runCommand(cmdObj);
@@ -1638,9 +1603,7 @@ var DB;
if (typeof rolename != "string") {
throw Error("Role name for getRole shell helper must be a string");
}
- var cmdObj = {
- rolesInfo: rolename
- };
+ var cmdObj = {rolesInfo: rolename};
Object.extend(cmdObj, args);
var res = this.runCommand(cmdObj);
if (!res.ok) {
@@ -1654,9 +1617,7 @@ var DB;
};
DB.prototype.getRoles = function(args) {
- var cmdObj = {
- rolesInfo: 1
- };
+ var cmdObj = {rolesInfo: 1};
Object.extend(cmdObj, args);
var res = this.runCommand(cmdObj);
if (!res.ok) {
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index 5ef6f3f9982..1378ee263b4 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -748,7 +748,8 @@ int _main(int argc, char* argv[], char** envp) {
hasMongoRC = true;
if (!scope->execFile(rcLocation, false, true)) {
cout << "The \".mongorc.js\" file located in your home folder could not be "
- "executed" << endl;
+ "executed"
+ << endl;
return -5;
}
}
diff --git a/src/mongo/shell/explain_query.js b/src/mongo/shell/explain_query.js
index cb14b71f0cf..0670734891e 100644
--- a/src/mongo/shell/explain_query.js
+++ b/src/mongo/shell/explain_query.js
@@ -150,9 +150,7 @@ var DBExplainQuery = (function() {
innerCmd = this._query._convertToCommand(canAttachReadPref);
}
- var explainCmd = {
- explain: innerCmd
- };
+ var explainCmd = {explain: innerCmd};
explainCmd["verbosity"] = this._verbosity;
var explainDb = this._query._db;
diff --git a/src/mongo/shell/explainable.js b/src/mongo/shell/explainable.js
index 4f54694acd3..2fe8ce0de70 100644
--- a/src/mongo/shell/explainable.js
+++ b/src/mongo/shell/explainable.js
@@ -126,23 +126,15 @@ var Explainable = (function() {
this.findAndModify = function(params) {
var famCmd = Object.extend({"findAndModify": this._collection.getName()}, params);
- var explainCmd = {
- "explain": famCmd,
- "verbosity": this._verbosity
- };
+ var explainCmd = {"explain": famCmd, "verbosity": this._verbosity};
var explainResult = this._collection.runReadCommand(explainCmd);
return throwOrReturn(explainResult);
};
this.group = function(params) {
params.ns = this._collection.getName();
- var grpCmd = {
- "group": this._collection.getDB()._groupFixParms(params)
- };
- var explainCmd = {
- "explain": grpCmd,
- "verbosity": this._verbosity
- };
+ var grpCmd = {"group": this._collection.getDB()._groupFixParms(params)};
+ var explainCmd = {"explain": grpCmd, "verbosity": this._verbosity};
var explainResult = this._collection.runReadCommand(explainCmd);
return throwOrReturn(explainResult);
};
@@ -158,10 +150,7 @@ var Explainable = (function() {
distinctCmd.collation = options.collation;
}
- var explainCmd = {
- explain: distinctCmd,
- verbosity: this._verbosity
- };
+ var explainCmd = {explain: distinctCmd, verbosity: this._verbosity};
var explainResult = this._collection.runReadCommand(explainCmd);
return throwOrReturn(explainResult);
};
diff --git a/src/mongo/shell/linenoise.cpp b/src/mongo/shell/linenoise.cpp
index 03ca8bbf12f..f75028c8845 100644
--- a/src/mongo/shell/linenoise.cpp
+++ b/src/mongo/shell/linenoise.cpp
@@ -86,8 +86,8 @@
#ifdef _WIN32
#include <conio.h>
-#include <windows.h>
#include <io.h>
+#include <windows.h>
#define strcasecmp _stricmp
#define strdup _strdup
#define isatty _isatty
@@ -96,24 +96,24 @@
#else /* _WIN32 */
+#include <cctype>
#include <signal.h>
-#include <termios.h>
-#include <unistd.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/ioctl.h>
-#include <cctype>
+#include <sys/types.h>
+#include <termios.h>
+#include <unistd.h>
#include <wctype.h>
#endif /* _WIN32 */
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
#include "linenoise.h"
#include "linenoise_utf8.h"
#include "mk_wcwidth.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
#include <string>
#include <vector>
diff --git a/src/mongo/shell/linenoise_utf8.cpp b/src/mongo/shell/linenoise_utf8.cpp
index 73d8168ac56..055ac0cf793 100644
--- a/src/mongo/shell/linenoise_utf8.cpp
+++ b/src/mongo/shell/linenoise_utf8.cpp
@@ -30,9 +30,9 @@
#include "mongo/shell/linenoise_utf8.h"
#ifdef _WIN32
-#include <io.h>
#include "mongo/platform/windows_basic.h"
#include "mongo/util/text.h"
+#include <io.h>
#else
#include <unistd.h>
#endif
diff --git a/src/mongo/shell/mk_wcwidth.cpp b/src/mongo/shell/mk_wcwidth.cpp
index 58e3a368293..cb4674344f5 100644
--- a/src/mongo/shell/mk_wcwidth.cpp
+++ b/src/mongo/shell/mk_wcwidth.cpp
@@ -124,148 +124,43 @@ static int bisearch(int ucs, const struct interval* table, int max) {
int mk_wcwidth(int ucs) {
/* sorted list of non-overlapping intervals of non-spacing characters */
/* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
- static const struct interval combining[] = {{0x0300, 0x036F},
- {0x0483, 0x0486},
- {0x0488, 0x0489},
- {0x0591, 0x05BD},
- {0x05BF, 0x05BF},
- {0x05C1, 0x05C2},
- {0x05C4, 0x05C5},
- {0x05C7, 0x05C7},
- {0x0600, 0x0603},
- {0x0610, 0x0615},
- {0x064B, 0x065E},
- {0x0670, 0x0670},
- {0x06D6, 0x06E4},
- {0x06E7, 0x06E8},
- {0x06EA, 0x06ED},
- {0x070F, 0x070F},
- {0x0711, 0x0711},
- {0x0730, 0x074A},
- {0x07A6, 0x07B0},
- {0x07EB, 0x07F3},
- {0x0901, 0x0902},
- {0x093C, 0x093C},
- {0x0941, 0x0948},
- {0x094D, 0x094D},
- {0x0951, 0x0954},
- {0x0962, 0x0963},
- {0x0981, 0x0981},
- {0x09BC, 0x09BC},
- {0x09C1, 0x09C4},
- {0x09CD, 0x09CD},
- {0x09E2, 0x09E3},
- {0x0A01, 0x0A02},
- {0x0A3C, 0x0A3C},
- {0x0A41, 0x0A42},
- {0x0A47, 0x0A48},
- {0x0A4B, 0x0A4D},
- {0x0A70, 0x0A71},
- {0x0A81, 0x0A82},
- {0x0ABC, 0x0ABC},
- {0x0AC1, 0x0AC5},
- {0x0AC7, 0x0AC8},
- {0x0ACD, 0x0ACD},
- {0x0AE2, 0x0AE3},
- {0x0B01, 0x0B01},
- {0x0B3C, 0x0B3C},
- {0x0B3F, 0x0B3F},
- {0x0B41, 0x0B43},
- {0x0B4D, 0x0B4D},
- {0x0B56, 0x0B56},
- {0x0B82, 0x0B82},
- {0x0BC0, 0x0BC0},
- {0x0BCD, 0x0BCD},
- {0x0C3E, 0x0C40},
- {0x0C46, 0x0C48},
- {0x0C4A, 0x0C4D},
- {0x0C55, 0x0C56},
- {0x0CBC, 0x0CBC},
- {0x0CBF, 0x0CBF},
- {0x0CC6, 0x0CC6},
- {0x0CCC, 0x0CCD},
- {0x0CE2, 0x0CE3},
- {0x0D41, 0x0D43},
- {0x0D4D, 0x0D4D},
- {0x0DCA, 0x0DCA},
- {0x0DD2, 0x0DD4},
- {0x0DD6, 0x0DD6},
- {0x0E31, 0x0E31},
- {0x0E34, 0x0E3A},
- {0x0E47, 0x0E4E},
- {0x0EB1, 0x0EB1},
- {0x0EB4, 0x0EB9},
- {0x0EBB, 0x0EBC},
- {0x0EC8, 0x0ECD},
- {0x0F18, 0x0F19},
- {0x0F35, 0x0F35},
- {0x0F37, 0x0F37},
- {0x0F39, 0x0F39},
- {0x0F71, 0x0F7E},
- {0x0F80, 0x0F84},
- {0x0F86, 0x0F87},
- {0x0F90, 0x0F97},
- {0x0F99, 0x0FBC},
- {0x0FC6, 0x0FC6},
- {0x102D, 0x1030},
- {0x1032, 0x1032},
- {0x1036, 0x1037},
- {0x1039, 0x1039},
- {0x1058, 0x1059},
- {0x1160, 0x11FF},
- {0x135F, 0x135F},
- {0x1712, 0x1714},
- {0x1732, 0x1734},
- {0x1752, 0x1753},
- {0x1772, 0x1773},
- {0x17B4, 0x17B5},
- {0x17B7, 0x17BD},
- {0x17C6, 0x17C6},
- {0x17C9, 0x17D3},
- {0x17DD, 0x17DD},
- {0x180B, 0x180D},
- {0x18A9, 0x18A9},
- {0x1920, 0x1922},
- {0x1927, 0x1928},
- {0x1932, 0x1932},
- {0x1939, 0x193B},
- {0x1A17, 0x1A18},
- {0x1B00, 0x1B03},
- {0x1B34, 0x1B34},
- {0x1B36, 0x1B3A},
- {0x1B3C, 0x1B3C},
- {0x1B42, 0x1B42},
- {0x1B6B, 0x1B73},
- {0x1DC0, 0x1DCA},
- {0x1DFE, 0x1DFF},
- {0x200B, 0x200F},
- {0x202A, 0x202E},
- {0x2060, 0x2063},
- {0x206A, 0x206F},
- {0x20D0, 0x20EF},
- {0x302A, 0x302F},
- {0x3099, 0x309A},
- {0xA806, 0xA806},
- {0xA80B, 0xA80B},
- {0xA825, 0xA826},
- {0xFB1E, 0xFB1E},
- {0xFE00, 0xFE0F},
- {0xFE20, 0xFE23},
- {0xFEFF, 0xFEFF},
- {0xFFF9, 0xFFFB},
- {0x10A01, 0x10A03},
- {0x10A05, 0x10A06},
- {0x10A0C, 0x10A0F},
- {0x10A38, 0x10A3A},
- {0x10A3F, 0x10A3F},
- {0x1D167, 0x1D169},
- {0x1D173, 0x1D182},
- {0x1D185, 0x1D18B},
- {0x1D1AA, 0x1D1AD},
- {0x1D242, 0x1D244},
- {0xE0001, 0xE0001},
- {0xE0020, 0xE007F},
- {0xE0100, 0xE01EF}};
+ static const struct interval combining[] = {
+ {0x0300, 0x036F}, {0x0483, 0x0486}, {0x0488, 0x0489}, {0x0591, 0x05BD},
+ {0x05BF, 0x05BF}, {0x05C1, 0x05C2}, {0x05C4, 0x05C5}, {0x05C7, 0x05C7},
+ {0x0600, 0x0603}, {0x0610, 0x0615}, {0x064B, 0x065E}, {0x0670, 0x0670},
+ {0x06D6, 0x06E4}, {0x06E7, 0x06E8}, {0x06EA, 0x06ED}, {0x070F, 0x070F},
+ {0x0711, 0x0711}, {0x0730, 0x074A}, {0x07A6, 0x07B0}, {0x07EB, 0x07F3},
+ {0x0901, 0x0902}, {0x093C, 0x093C}, {0x0941, 0x0948}, {0x094D, 0x094D},
+ {0x0951, 0x0954}, {0x0962, 0x0963}, {0x0981, 0x0981}, {0x09BC, 0x09BC},
+ {0x09C1, 0x09C4}, {0x09CD, 0x09CD}, {0x09E2, 0x09E3}, {0x0A01, 0x0A02},
+ {0x0A3C, 0x0A3C}, {0x0A41, 0x0A42}, {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D},
+ {0x0A70, 0x0A71}, {0x0A81, 0x0A82}, {0x0ABC, 0x0ABC}, {0x0AC1, 0x0AC5},
+ {0x0AC7, 0x0AC8}, {0x0ACD, 0x0ACD}, {0x0AE2, 0x0AE3}, {0x0B01, 0x0B01},
+ {0x0B3C, 0x0B3C}, {0x0B3F, 0x0B3F}, {0x0B41, 0x0B43}, {0x0B4D, 0x0B4D},
+ {0x0B56, 0x0B56}, {0x0B82, 0x0B82}, {0x0BC0, 0x0BC0}, {0x0BCD, 0x0BCD},
+ {0x0C3E, 0x0C40}, {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, {0x0C55, 0x0C56},
+ {0x0CBC, 0x0CBC}, {0x0CBF, 0x0CBF}, {0x0CC6, 0x0CC6}, {0x0CCC, 0x0CCD},
+ {0x0CE2, 0x0CE3}, {0x0D41, 0x0D43}, {0x0D4D, 0x0D4D}, {0x0DCA, 0x0DCA},
+ {0x0DD2, 0x0DD4}, {0x0DD6, 0x0DD6}, {0x0E31, 0x0E31}, {0x0E34, 0x0E3A},
+ {0x0E47, 0x0E4E}, {0x0EB1, 0x0EB1}, {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC},
+ {0x0EC8, 0x0ECD}, {0x0F18, 0x0F19}, {0x0F35, 0x0F35}, {0x0F37, 0x0F37},
+ {0x0F39, 0x0F39}, {0x0F71, 0x0F7E}, {0x0F80, 0x0F84}, {0x0F86, 0x0F87},
+ {0x0F90, 0x0F97}, {0x0F99, 0x0FBC}, {0x0FC6, 0x0FC6}, {0x102D, 0x1030},
+ {0x1032, 0x1032}, {0x1036, 0x1037}, {0x1039, 0x1039}, {0x1058, 0x1059},
+ {0x1160, 0x11FF}, {0x135F, 0x135F}, {0x1712, 0x1714}, {0x1732, 0x1734},
+ {0x1752, 0x1753}, {0x1772, 0x1773}, {0x17B4, 0x17B5}, {0x17B7, 0x17BD},
+ {0x17C6, 0x17C6}, {0x17C9, 0x17D3}, {0x17DD, 0x17DD}, {0x180B, 0x180D},
+ {0x18A9, 0x18A9}, {0x1920, 0x1922}, {0x1927, 0x1928}, {0x1932, 0x1932},
+ {0x1939, 0x193B}, {0x1A17, 0x1A18}, {0x1B00, 0x1B03}, {0x1B34, 0x1B34},
+ {0x1B36, 0x1B3A}, {0x1B3C, 0x1B3C}, {0x1B42, 0x1B42}, {0x1B6B, 0x1B73},
+ {0x1DC0, 0x1DCA}, {0x1DFE, 0x1DFF}, {0x200B, 0x200F}, {0x202A, 0x202E},
+ {0x2060, 0x2063}, {0x206A, 0x206F}, {0x20D0, 0x20EF}, {0x302A, 0x302F},
+ {0x3099, 0x309A}, {0xA806, 0xA806}, {0xA80B, 0xA80B}, {0xA825, 0xA826},
+ {0xFB1E, 0xFB1E}, {0xFE00, 0xFE0F}, {0xFE20, 0xFE23}, {0xFEFF, 0xFEFF},
+ {0xFFF9, 0xFFFB}, {0x10A01, 0x10A03}, {0x10A05, 0x10A06}, {0x10A0C, 0x10A0F},
+ {0x10A38, 0x10A3A}, {0x10A3F, 0x10A3F}, {0x1D167, 0x1D169}, {0x1D173, 0x1D182},
+ {0x1D185, 0x1D18B}, {0x1D1AA, 0x1D1AD}, {0x1D242, 0x1D244}, {0xE0001, 0xE0001},
+ {0xE0020, 0xE007F}, {0xE0100, 0xE01EF}};
/* test for 8-bit control characters */
if (ucs == 0)
@@ -319,162 +214,46 @@ int mk_wcswidth(const int* pwcs, size_t n) {
int mk_wcwidth_cjk(int ucs) {
/* sorted list of non-overlapping intervals of East Asian Ambiguous
* characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
- static const struct interval ambiguous[] = {{0x00A1, 0x00A1},
- {0x00A4, 0x00A4},
- {0x00A7, 0x00A8},
- {0x00AA, 0x00AA},
- {0x00AE, 0x00AE},
- {0x00B0, 0x00B4},
- {0x00B6, 0x00BA},
- {0x00BC, 0x00BF},
- {0x00C6, 0x00C6},
- {0x00D0, 0x00D0},
- {0x00D7, 0x00D8},
- {0x00DE, 0x00E1},
- {0x00E6, 0x00E6},
- {0x00E8, 0x00EA},
- {0x00EC, 0x00ED},
- {0x00F0, 0x00F0},
- {0x00F2, 0x00F3},
- {0x00F7, 0x00FA},
- {0x00FC, 0x00FC},
- {0x00FE, 0x00FE},
- {0x0101, 0x0101},
- {0x0111, 0x0111},
- {0x0113, 0x0113},
- {0x011B, 0x011B},
- {0x0126, 0x0127},
- {0x012B, 0x012B},
- {0x0131, 0x0133},
- {0x0138, 0x0138},
- {0x013F, 0x0142},
- {0x0144, 0x0144},
- {0x0148, 0x014B},
- {0x014D, 0x014D},
- {0x0152, 0x0153},
- {0x0166, 0x0167},
- {0x016B, 0x016B},
- {0x01CE, 0x01CE},
- {0x01D0, 0x01D0},
- {0x01D2, 0x01D2},
- {0x01D4, 0x01D4},
- {0x01D6, 0x01D6},
- {0x01D8, 0x01D8},
- {0x01DA, 0x01DA},
- {0x01DC, 0x01DC},
- {0x0251, 0x0251},
- {0x0261, 0x0261},
- {0x02C4, 0x02C4},
- {0x02C7, 0x02C7},
- {0x02C9, 0x02CB},
- {0x02CD, 0x02CD},
- {0x02D0, 0x02D0},
- {0x02D8, 0x02DB},
- {0x02DD, 0x02DD},
- {0x02DF, 0x02DF},
- {0x0391, 0x03A1},
- {0x03A3, 0x03A9},
- {0x03B1, 0x03C1},
- {0x03C3, 0x03C9},
- {0x0401, 0x0401},
- {0x0410, 0x044F},
- {0x0451, 0x0451},
- {0x2010, 0x2010},
- {0x2013, 0x2016},
- {0x2018, 0x2019},
- {0x201C, 0x201D},
- {0x2020, 0x2022},
- {0x2024, 0x2027},
- {0x2030, 0x2030},
- {0x2032, 0x2033},
- {0x2035, 0x2035},
- {0x203B, 0x203B},
- {0x203E, 0x203E},
- {0x2074, 0x2074},
- {0x207F, 0x207F},
- {0x2081, 0x2084},
- {0x20AC, 0x20AC},
- {0x2103, 0x2103},
- {0x2105, 0x2105},
- {0x2109, 0x2109},
- {0x2113, 0x2113},
- {0x2116, 0x2116},
- {0x2121, 0x2122},
- {0x2126, 0x2126},
- {0x212B, 0x212B},
- {0x2153, 0x2154},
- {0x215B, 0x215E},
- {0x2160, 0x216B},
- {0x2170, 0x2179},
- {0x2190, 0x2199},
- {0x21B8, 0x21B9},
- {0x21D2, 0x21D2},
- {0x21D4, 0x21D4},
- {0x21E7, 0x21E7},
- {0x2200, 0x2200},
- {0x2202, 0x2203},
- {0x2207, 0x2208},
- {0x220B, 0x220B},
- {0x220F, 0x220F},
- {0x2211, 0x2211},
- {0x2215, 0x2215},
- {0x221A, 0x221A},
- {0x221D, 0x2220},
- {0x2223, 0x2223},
- {0x2225, 0x2225},
- {0x2227, 0x222C},
- {0x222E, 0x222E},
- {0x2234, 0x2237},
- {0x223C, 0x223D},
- {0x2248, 0x2248},
- {0x224C, 0x224C},
- {0x2252, 0x2252},
- {0x2260, 0x2261},
- {0x2264, 0x2267},
- {0x226A, 0x226B},
- {0x226E, 0x226F},
- {0x2282, 0x2283},
- {0x2286, 0x2287},
- {0x2295, 0x2295},
- {0x2299, 0x2299},
- {0x22A5, 0x22A5},
- {0x22BF, 0x22BF},
- {0x2312, 0x2312},
- {0x2460, 0x24E9},
- {0x24EB, 0x254B},
- {0x2550, 0x2573},
- {0x2580, 0x258F},
- {0x2592, 0x2595},
- {0x25A0, 0x25A1},
- {0x25A3, 0x25A9},
- {0x25B2, 0x25B3},
- {0x25B6, 0x25B7},
- {0x25BC, 0x25BD},
- {0x25C0, 0x25C1},
- {0x25C6, 0x25C8},
- {0x25CB, 0x25CB},
- {0x25CE, 0x25D1},
- {0x25E2, 0x25E5},
- {0x25EF, 0x25EF},
- {0x2605, 0x2606},
- {0x2609, 0x2609},
- {0x260E, 0x260F},
- {0x2614, 0x2615},
- {0x261C, 0x261C},
- {0x261E, 0x261E},
- {0x2640, 0x2640},
- {0x2642, 0x2642},
- {0x2660, 0x2661},
- {0x2663, 0x2665},
- {0x2667, 0x266A},
- {0x266C, 0x266D},
- {0x266F, 0x266F},
- {0x273D, 0x273D},
- {0x2776, 0x277F},
- {0xE000, 0xF8FF},
- {0xFFFD, 0xFFFD},
- {0xF0000, 0xFFFFD},
- {0x100000, 0x10FFFD}};
+ static const struct interval ambiguous[] = {
+ {0x00A1, 0x00A1}, {0x00A4, 0x00A4}, {0x00A7, 0x00A8}, {0x00AA, 0x00AA},
+ {0x00AE, 0x00AE}, {0x00B0, 0x00B4}, {0x00B6, 0x00BA}, {0x00BC, 0x00BF},
+ {0x00C6, 0x00C6}, {0x00D0, 0x00D0}, {0x00D7, 0x00D8}, {0x00DE, 0x00E1},
+ {0x00E6, 0x00E6}, {0x00E8, 0x00EA}, {0x00EC, 0x00ED}, {0x00F0, 0x00F0},
+ {0x00F2, 0x00F3}, {0x00F7, 0x00FA}, {0x00FC, 0x00FC}, {0x00FE, 0x00FE},
+ {0x0101, 0x0101}, {0x0111, 0x0111}, {0x0113, 0x0113}, {0x011B, 0x011B},
+ {0x0126, 0x0127}, {0x012B, 0x012B}, {0x0131, 0x0133}, {0x0138, 0x0138},
+ {0x013F, 0x0142}, {0x0144, 0x0144}, {0x0148, 0x014B}, {0x014D, 0x014D},
+ {0x0152, 0x0153}, {0x0166, 0x0167}, {0x016B, 0x016B}, {0x01CE, 0x01CE},
+ {0x01D0, 0x01D0}, {0x01D2, 0x01D2}, {0x01D4, 0x01D4}, {0x01D6, 0x01D6},
+ {0x01D8, 0x01D8}, {0x01DA, 0x01DA}, {0x01DC, 0x01DC}, {0x0251, 0x0251},
+ {0x0261, 0x0261}, {0x02C4, 0x02C4}, {0x02C7, 0x02C7}, {0x02C9, 0x02CB},
+ {0x02CD, 0x02CD}, {0x02D0, 0x02D0}, {0x02D8, 0x02DB}, {0x02DD, 0x02DD},
+ {0x02DF, 0x02DF}, {0x0391, 0x03A1}, {0x03A3, 0x03A9}, {0x03B1, 0x03C1},
+ {0x03C3, 0x03C9}, {0x0401, 0x0401}, {0x0410, 0x044F}, {0x0451, 0x0451},
+ {0x2010, 0x2010}, {0x2013, 0x2016}, {0x2018, 0x2019}, {0x201C, 0x201D},
+ {0x2020, 0x2022}, {0x2024, 0x2027}, {0x2030, 0x2030}, {0x2032, 0x2033},
+ {0x2035, 0x2035}, {0x203B, 0x203B}, {0x203E, 0x203E}, {0x2074, 0x2074},
+ {0x207F, 0x207F}, {0x2081, 0x2084}, {0x20AC, 0x20AC}, {0x2103, 0x2103},
+ {0x2105, 0x2105}, {0x2109, 0x2109}, {0x2113, 0x2113}, {0x2116, 0x2116},
+ {0x2121, 0x2122}, {0x2126, 0x2126}, {0x212B, 0x212B}, {0x2153, 0x2154},
+ {0x215B, 0x215E}, {0x2160, 0x216B}, {0x2170, 0x2179}, {0x2190, 0x2199},
+ {0x21B8, 0x21B9}, {0x21D2, 0x21D2}, {0x21D4, 0x21D4}, {0x21E7, 0x21E7},
+ {0x2200, 0x2200}, {0x2202, 0x2203}, {0x2207, 0x2208}, {0x220B, 0x220B},
+ {0x220F, 0x220F}, {0x2211, 0x2211}, {0x2215, 0x2215}, {0x221A, 0x221A},
+ {0x221D, 0x2220}, {0x2223, 0x2223}, {0x2225, 0x2225}, {0x2227, 0x222C},
+ {0x222E, 0x222E}, {0x2234, 0x2237}, {0x223C, 0x223D}, {0x2248, 0x2248},
+ {0x224C, 0x224C}, {0x2252, 0x2252}, {0x2260, 0x2261}, {0x2264, 0x2267},
+ {0x226A, 0x226B}, {0x226E, 0x226F}, {0x2282, 0x2283}, {0x2286, 0x2287},
+ {0x2295, 0x2295}, {0x2299, 0x2299}, {0x22A5, 0x22A5}, {0x22BF, 0x22BF},
+ {0x2312, 0x2312}, {0x2460, 0x24E9}, {0x24EB, 0x254B}, {0x2550, 0x2573},
+ {0x2580, 0x258F}, {0x2592, 0x2595}, {0x25A0, 0x25A1}, {0x25A3, 0x25A9},
+ {0x25B2, 0x25B3}, {0x25B6, 0x25B7}, {0x25BC, 0x25BD}, {0x25C0, 0x25C1},
+ {0x25C6, 0x25C8}, {0x25CB, 0x25CB}, {0x25CE, 0x25D1}, {0x25E2, 0x25E5},
+ {0x25EF, 0x25EF}, {0x2605, 0x2606}, {0x2609, 0x2609}, {0x260E, 0x260F},
+ {0x2614, 0x2615}, {0x261C, 0x261C}, {0x261E, 0x261E}, {0x2640, 0x2640},
+ {0x2642, 0x2642}, {0x2660, 0x2661}, {0x2663, 0x2665}, {0x2667, 0x266A},
+ {0x266C, 0x266D}, {0x266F, 0x266F}, {0x273D, 0x273D}, {0x2776, 0x277F},
+ {0xE000, 0xF8FF}, {0xFFFD, 0xFFFD}, {0xF0000, 0xFFFFD}, {0x100000, 0x10FFFD}};
/* binary search in table of non-spacing characters */
if (bisearch(ucs, ambiguous, sizeof(ambiguous) / sizeof(struct interval) - 1))
diff --git a/src/mongo/shell/mongo.js b/src/mongo/shell/mongo.js
index fbdff5d61bd..7fb711d8a91 100644
--- a/src/mongo/shell/mongo.js
+++ b/src/mongo/shell/mongo.js
@@ -88,9 +88,7 @@ Mongo.prototype.setLogLevel = function(logLevel, component) {
} else if (component !== undefined) {
throw Error("setLogLevel component must be a string:" + tojson(component));
}
- var vDoc = {
- verbosity: logLevel
- };
+ var vDoc = {verbosity: logLevel};
// nest vDoc
for (var key, obj; componentNames.length > 0;) {
diff --git a/src/mongo/shell/mr.js b/src/mongo/shell/mr.js
index a810a7f0d79..e501a5c71fb 100644
--- a/src/mongo/shell/mr.js
+++ b/src/mongo/shell/mr.js
@@ -22,11 +22,7 @@ MR.emit = function(k, v) {
var num = nativeHelper.apply(get_num_, [k]);
var data = $arr[num];
if (!data) {
- data = {
- key: k,
- values: new Array(1000),
- count: 0
- };
+ data = {key: k, values: new Array(1000), count: 0};
$arr[num] = data;
}
data.values[data.count++] = v;
diff --git a/src/mongo/shell/query.js b/src/mongo/shell/query.js
index 813d9be9e59..3a32b7a951a 100644
--- a/src/mongo/shell/query.js
+++ b/src/mongo/shell/query.js
@@ -85,9 +85,7 @@ DBQuery.prototype._ensureSpecial = function() {
if (this._special)
return;
- var n = {
- query: this._query
- };
+ var n = {query: this._query};
this._query = n;
this._special = true;
};
@@ -343,9 +341,7 @@ DBQuery.prototype.toArray = function() {
};
DBQuery.prototype._convertToCountCmd = function(applySkipLimit) {
- var cmd = {
- count: this._collection.getName()
- };
+ var cmd = {count: this._collection.getName()};
if (this._query) {
if (this._special) {
@@ -472,9 +468,7 @@ DBQuery.prototype.maxTimeMS = function(maxTimeMS) {
};
DBQuery.prototype.readConcern = function(level) {
- var readConcernObj = {
- level: level
- };
+ var readConcernObj = {level: level};
return this._addSpecial("readConcern", readConcernObj);
};
@@ -493,9 +487,7 @@ DBQuery.prototype.collation = function(collationSpec) {
* @return this cursor
*/
DBQuery.prototype.readPref = function(mode, tagSet) {
- var readPrefObj = {
- mode: mode
- };
+ var readPrefObj = {mode: mode};
if (tagSet) {
readPrefObj.tags = tagSet;
@@ -759,10 +751,7 @@ DBCommandCursor.prototype.close = function() {
*/
DBCommandCursor.prototype._runGetMoreCommand = function() {
// Construct the getMore command.
- var getMoreCmd = {
- getMore: this._cursorid,
- collection: this._collName
- };
+ var getMoreCmd = {getMore: this._cursorid, collection: this._collName};
if (this._batchSize) {
getMoreCmd["batchSize"] = this._batchSize;
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index 662397267c1..394af60484d 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -74,10 +74,7 @@ var ReplSetTest = function(opts) {
var self = this;
// Replica set health states
- var Health = {
- UP: 1,
- DOWN: 0
- };
+ var Health = {UP: 1, DOWN: 0};
var _alldbpaths;
var _configSettings;
@@ -94,10 +91,7 @@ var ReplSetTest = function(opts) {
* Populates a reference to all reachable nodes.
*/
function _clearLiveNodes() {
- self.liveNodes = {
- master: null,
- slaves: []
- };
+ self.liveNodes = {master: null, slaves: []};
}
/**
@@ -310,10 +304,8 @@ var ReplSetTest = function(opts) {
function _getLastCommittedOpTime(conn) {
var replSetStatus =
assert.commandWorked(conn.getDB("admin").runCommand({replSetGetStatus: 1}));
- return (replSetStatus.OpTimes || replSetStatus.optimes).lastCommittedOpTime || {
- ts: Timestamp(0, 0),
- t: NumberLong(0)
- };
+ return (replSetStatus.OpTimes || replSetStatus.optimes).lastCommittedOpTime ||
+ {ts: Timestamp(0, 0), t: NumberLong(0)};
}
/**
@@ -325,22 +317,14 @@ var ReplSetTest = function(opts) {
function _getReadConcernMajorityOpTime(conn) {
var replSetStatus =
assert.commandWorked(conn.getDB("admin").runCommand({replSetGetStatus: 1}));
- return (replSetStatus.OpTimes || replSetStatus.optimes).readConcernMajorityOpTime || {
- ts: Timestamp(0, 0),
- t: NumberLong(0)
- };
+ return (replSetStatus.OpTimes || replSetStatus.optimes).readConcernMajorityOpTime ||
+ {ts: Timestamp(0, 0), t: NumberLong(0)};
}
function _isEarlierOpTime(ot1, ot2) {
// Make sure both optimes have a timestamp and a term.
- ot1 = ot1.t ? ot1 : {
- ts: ot1,
- t: NumberLong(-1)
- };
- ot2 = ot2.t ? ot2 : {
- ts: ot2,
- t: NumberLong(-1)
- };
+ ot1 = ot1.t ? ot1 : {ts: ot1, t: NumberLong(-1)};
+ ot2 = ot2.t ? ot2 : {ts: ot2, t: NumberLong(-1)};
// If both optimes have a term that's not -1 and one has a lower term, return that optime.
if (!friendlyEqual(ot1.t, NumberLong(-1)) && !friendlyEqual(ot2.t, NumberLong(-1))) {
@@ -916,10 +900,7 @@ var ReplSetTest = function(opts) {
options.restart = options.restart || restart;
- var pathOpts = {
- node: n,
- set: this.name
- };
+ var pathOpts = {node: n, set: this.name};
options.pathOpts = Object.merge(options.pathOpts || {}, pathOpts);
if (tojson(options) != tojson({}))
@@ -929,15 +910,13 @@ var ReplSetTest = function(opts) {
if (_useBridge) {
var bridgeOptions = Object.merge(_bridgeOptions, options.bridgeOptions || {});
- bridgeOptions = Object.merge(
- bridgeOptions,
- {
- hostName: this.host,
- port: this.ports[n],
- // The mongod processes identify themselves to mongobridge as host:port, where the
- // host is the actual hostname of the machine and not localhost.
- dest: getHostName() + ":" + _unbridgedPorts[n],
- });
+ bridgeOptions = Object.merge(bridgeOptions, {
+ hostName: this.host,
+ port: this.ports[n],
+ // The mongod processes identify themselves to mongobridge as host:port, where the
+ // host is the actual hostname of the machine and not localhost.
+ dest: getHostName() + ":" + _unbridgedPorts[n],
+ });
this.nodes[n] = new MongoBridge(bridgeOptions);
}
@@ -1117,9 +1096,7 @@ var ReplSetTest = function(opts) {
this.query = function(ts) {
var coll = this.getOplogColl();
- var query = {
- "ts": {"$gte": ts ? ts : new Timestamp()}
- };
+ var query = {"ts": {"$gte": ts ? ts : new Timestamp()}};
this.cursor = coll.find(query).sort({$natural: 1});
this.cursor.addOption(DBQuery.Option.oplogReplay);
};
@@ -1309,9 +1286,7 @@ ReplSetTest.awaitRSClientHosts = function(conn, host, hostOk, rs, timeout) {
timeout = timeout || 60000;
if (hostOk == undefined)
- hostOk = {
- ok: true
- };
+ hostOk = {ok: true};
if (host.host)
host = host.host;
if (rs)
diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js
index 2496b70fb91..6bfc15d945d 100644
--- a/src/mongo/shell/servers.js
+++ b/src/mongo/shell/servers.js
@@ -382,9 +382,7 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
// If we're a mongo object
if (opts.getDB) {
- opts = {
- restart: opts.runId
- };
+ opts = {restart: opts.runId};
}
// Initialize and create a copy of the opts
@@ -794,11 +792,10 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
if (!Array.contains(allowedExitCodes, returnCode)) {
throw new MongoRunner.StopError(
- // clang-format off
+ // clang-format off
`MongoDB process on port ${port} exited with error code ${returnCode}`,
- // clang-format on
- returnCode
- );
+ // clang-format on
+ returnCode);
}
return returnCode;
@@ -884,10 +881,9 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
}
}
if (!hasAuthMechs) {
- argArray.push(...[
- '--setParameter',
- "authenticationMechanisms=" + jsTest.options().authMechanism
- ]);
+ argArray.push(
+ ...['--setParameter',
+ "authenticationMechanisms=" + jsTest.options().authMechanism]);
}
}
if (jsTest.options().auth) {
@@ -916,22 +912,16 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
}
}
if (jsTest.options().wiredTigerEngineConfigString) {
- argArray.push(...[
- '--wiredTigerEngineConfigString',
- jsTest.options().wiredTigerEngineConfigString
- ]);
+ argArray.push(...['--wiredTigerEngineConfigString',
+ jsTest.options().wiredTigerEngineConfigString]);
}
if (jsTest.options().wiredTigerCollectionConfigString) {
- argArray.push(...[
- '--wiredTigerCollectionConfigString',
- jsTest.options().wiredTigerCollectionConfigString
- ]);
+ argArray.push(...['--wiredTigerCollectionConfigString',
+ jsTest.options().wiredTigerCollectionConfigString]);
}
if (jsTest.options().wiredTigerIndexConfigString) {
- argArray.push(...[
- '--wiredTigerIndexConfigString',
- jsTest.options().wiredTigerIndexConfigString
- ]);
+ argArray.push(...['--wiredTigerIndexConfigString',
+ jsTest.options().wiredTigerIndexConfigString]);
}
// apply setParameters for mongod
if (jsTest.options().setParameters) {
diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js
index d1fd416d568..be105364261 100644
--- a/src/mongo/shell/shardingtest.js
+++ b/src/mongo/shell/shardingtest.js
@@ -410,12 +410,10 @@ var ShardingTest = function(params) {
}
var s = "";
- this.config.chunks.find(q)
- .sort({ns: 1, min: 1})
- .forEach(function(z) {
- s += " " + z._id + "\t" + z.lastmod.t + "|" + z.lastmod.i + "\t" + tojson(z.min) +
- " -> " + tojson(z.max) + " " + z.shard + " " + z.ns + "\n";
- });
+ this.config.chunks.find(q).sort({ns: 1, min: 1}).forEach(function(z) {
+ s += " " + z._id + "\t" + z.lastmod.t + "|" + z.lastmod.i + "\t" + tojson(z.min) +
+ " -> " + tojson(z.max) + " " + z.shard + " " + z.ns + "\n";
+ });
return s;
};
@@ -494,13 +492,12 @@ var ShardingTest = function(params) {
x[z._id] = 0;
});
- this.config.chunks.find({ns: dbName + "." + collName})
- .forEach(function(z) {
- if (x[z.shard])
- x[z.shard]++;
- else
- x[z.shard] = 1;
- });
+ this.config.chunks.find({ns: dbName + "." + collName}).forEach(function(z) {
+ if (x[z.shard])
+ x[z.shard]++;
+ else
+ x[z.shard] = 1;
+ });
return x;
};
@@ -538,11 +535,9 @@ var ShardingTest = function(params) {
this.getShardNames = function() {
var shards = [];
- this.s.getCollection("config.shards")
- .find()
- .forEach(function(shardDoc) {
- shards.push(shardDoc._id);
- });
+ this.s.getCollection("config.shards").find().forEach(function(shardDoc) {
+ shards.push(shardDoc._id);
+ });
return shards;
};
@@ -788,15 +783,13 @@ var ShardingTest = function(params) {
var bridgeOptions =
(opts !== mongos) ? opts.bridgeOptions : mongos.fullOptions.bridgeOptions;
bridgeOptions = Object.merge(otherParams.bridgeOptions, bridgeOptions || {});
- bridgeOptions = Object.merge(
- bridgeOptions,
- {
- hostName: otherParams.useHostname ? hostName : "localhost",
- port: this._mongos[n].port,
- // The mongos processes identify themselves to mongobridge as host:port, where the
- // host is the actual hostname of the machine and not localhost.
- dest: hostName + ":" + opts.port,
- });
+ bridgeOptions = Object.merge(bridgeOptions, {
+ hostName: otherParams.useHostname ? hostName : "localhost",
+ port: this._mongos[n].port,
+ // The mongos processes identify themselves to mongobridge as host:port, where the
+ // host is the actual hostname of the machine and not localhost.
+ dest: hostName + ":" + opts.port,
+ });
this._mongos[n] = new MongoBridge(bridgeOptions);
}
@@ -850,15 +843,13 @@ var ShardingTest = function(params) {
var bridgeOptions =
(opts !== mongod) ? opts.bridgeOptions : mongod.fullOptions.bridgeOptions;
bridgeOptions = Object.merge(otherParams.bridgeOptions, bridgeOptions || {});
- bridgeOptions = Object.merge(
- bridgeOptions,
- {
- hostName: otherParams.useHostname ? hostName : "localhost",
- port: this._connections[n].port,
- // The mongod processes identify themselves to mongobridge as host:port, where the
- // host is the actual hostname of the machine and not localhost.
- dest: hostName + ":" + opts.port,
- });
+ bridgeOptions = Object.merge(bridgeOptions, {
+ hostName: otherParams.useHostname ? hostName : "localhost",
+ port: this._connections[n].port,
+ // The mongod processes identify themselves to mongobridge as host:port, where the
+ // host is the actual hostname of the machine and not localhost.
+ dest: hostName + ":" + opts.port,
+ });
this._connections[n] = new MongoBridge(bridgeOptions);
}
@@ -911,15 +902,13 @@ var ShardingTest = function(params) {
if (otherParams.useBridge) {
var bridgeOptions =
Object.merge(otherParams.bridgeOptions, mongod.fullOptions.bridgeOptions || {});
- bridgeOptions = Object.merge(
- bridgeOptions,
- {
- hostName: otherParams.useHostname ? hostName : "localhost",
- port: this._configServers[n].port,
- // The mongod processes identify themselves to mongobridge as host:port, where the
- // host is the actual hostname of the machine and not localhost.
- dest: hostName + ":" + mongod.port,
- });
+ bridgeOptions = Object.merge(bridgeOptions, {
+ hostName: otherParams.useHostname ? hostName : "localhost",
+ port: this._configServers[n].port,
+ // The mongod processes identify themselves to mongobridge as host:port, where the
+ // host is the actual hostname of the machine and not localhost.
+ dest: hostName + ":" + mongod.port,
+ });
this._configServers[n] = new MongoBridge(bridgeOptions);
}
@@ -1033,9 +1022,7 @@ var ShardingTest = function(params) {
this._testName = testName;
this._otherParams = otherParams;
- var pathOpts = {
- testName: testName
- };
+ var pathOpts = {testName: testName};
for (var k in otherParams) {
if (k.startsWith("rs") && otherParams[k] != undefined) {
@@ -1092,12 +1079,8 @@ var ShardingTest = function(params) {
settings: rsSettings
});
- this._rs[i] = {
- setName: setName,
- test: rs,
- nodes: rs.startSet(rsDefaults),
- url: rs.getURL()
- };
+ this._rs[i] =
+ {setName: setName, test: rs, nodes: rs.startSet(rsDefaults), url: rs.getURL()};
rs.initiate(null, null, initiateTimeout);
@@ -1133,14 +1116,12 @@ var ShardingTest = function(params) {
if (otherParams.useBridge) {
var bridgeOptions =
Object.merge(otherParams.bridgeOptions, options.bridgeOptions || {});
- bridgeOptions = Object.merge(
- bridgeOptions,
- {
- hostName: otherParams.useHostname ? hostName : "localhost",
- // The mongod processes identify themselves to mongobridge as host:port, where
- // the host is the actual hostname of the machine and not localhost.
- dest: hostName + ":" + options.port,
- });
+ bridgeOptions = Object.merge(bridgeOptions, {
+ hostName: otherParams.useHostname ? hostName : "localhost",
+ // The mongod processes identify themselves to mongobridge as host:port, where
+ // the host is the actual hostname of the machine and not localhost.
+ dest: hostName + ":" + options.port,
+ });
var bridge = new MongoBridge(bridgeOptions);
}
@@ -1177,11 +1158,9 @@ var ShardingTest = function(params) {
rs.getPrimary().getDB("admin").foo.save({x: 1});
if (keyFile) {
- authutil.asCluster(rs.nodes,
- keyFile,
- function() {
- rs.awaitReplication();
- });
+ authutil.asCluster(rs.nodes, keyFile, function() {
+ rs.awaitReplication();
+ });
}
rs.awaitSecondaryNodes();
@@ -1288,14 +1267,12 @@ var ShardingTest = function(params) {
if (otherParams.useBridge) {
var bridgeOptions =
Object.merge(otherParams.bridgeOptions, options.bridgeOptions || {});
- bridgeOptions = Object.merge(
- bridgeOptions,
- {
- hostName: otherParams.useHostname ? hostName : "localhost",
- // The mongos processes identify themselves to mongobridge as host:port, where the
- // host is the actual hostname of the machine and not localhost.
- dest: hostName + ":" + options.port,
- });
+ bridgeOptions = Object.merge(bridgeOptions, {
+ hostName: otherParams.useHostname ? hostName : "localhost",
+ // The mongos processes identify themselves to mongobridge as host:port, where the
+ // host is the actual hostname of the machine and not localhost.
+ dest: hostName + ":" + options.port,
+ });
var bridge = new MongoBridge(bridgeOptions);
}
@@ -1325,13 +1302,11 @@ var ShardingTest = function(params) {
// If auth is enabled for the test, login the mongos connections as system in order to
// configure the instances and then log them out again.
if (keyFile) {
- authutil.assertAuthenticate(this._mongos,
- 'admin',
- {
- user: '__system',
- mechanism: 'MONGODB-CR',
- pwd: cat(keyFile).replace(/[\011-\015\040]/g, '')
- });
+ authutil.assertAuthenticate(this._mongos, 'admin', {
+ user: '__system',
+ mechanism: 'MONGODB-CR',
+ pwd: cat(keyFile).replace(/[\011-\015\040]/g, '')
+ });
}
try {
diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp
index 63ab20931dc..7bafc00c54c 100644
--- a/src/mongo/shell/shell_options.cpp
+++ b/src/mongo/shell/shell_options.cpp
@@ -84,14 +84,15 @@ Status addMongoShellOptions(moe::OptionSection* options) {
authenticationOptions.addOptionChaining(
"username", "username,u", moe::String, "username for authentication");
- authenticationOptions.addOptionChaining(
- "password", "password,p", moe::String, "password for authentication")
+ authenticationOptions
+ .addOptionChaining("password", "password,p", moe::String, "password for authentication")
.setImplicit(moe::Value(std::string("")));
- authenticationOptions.addOptionChaining("authenticationDatabase",
- "authenticationDatabase",
- moe::String,
- "user source (defaults to dbname)")
+ authenticationOptions
+ .addOptionChaining("authenticationDatabase",
+ "authenticationDatabase",
+ moe::String,
+ "user source (defaults to dbname)")
.setDefault(moe::Value(std::string("")));
authenticationOptions.addOptionChaining("authenticationMechanism",
@@ -99,11 +100,11 @@ Status addMongoShellOptions(moe::OptionSection* options) {
moe::String,
"authentication mechanism");
- authenticationOptions.addOptionChaining(
- "gssapiServiceName",
- "gssapiServiceName",
- moe::String,
- "Service name to use when authenticating using GSSAPI/Kerberos")
+ authenticationOptions
+ .addOptionChaining("gssapiServiceName",
+ "gssapiServiceName",
+ moe::String,
+ "Service name to use when authenticating using GSSAPI/Kerberos")
.setDefault(moe::Value(std::string(saslDefaultServiceName)));
authenticationOptions.addOptionChaining(
@@ -128,10 +129,11 @@ Status addMongoShellOptions(moe::OptionSection* options) {
moe::Switch,
"disable the Javascript Just In Time compiler");
- options->addOptionChaining("disableJavaScriptProtection",
- "disableJavaScriptProtection",
- moe::Switch,
- "allow automatic JavaScript function marshalling")
+ options
+ ->addOptionChaining("disableJavaScriptProtection",
+ "disableJavaScriptProtection",
+ moe::Switch,
+ "allow automatic JavaScript function marshalling")
.incompatibleWith("enableJavaScriptProtection");
Status ret = Status::OK();
@@ -142,11 +144,11 @@ Status addMongoShellOptions(moe::OptionSection* options) {
}
#endif
- options->addOptionChaining(
- "enableJavaScriptProtection",
- "enableJavaScriptProtection",
- moe::Switch,
- "disable automatic JavaScript function marshalling (defaults to true)")
+ options
+ ->addOptionChaining("enableJavaScriptProtection",
+ "enableJavaScriptProtection",
+ moe::Switch,
+ "disable automatic JavaScript function marshalling (defaults to true)")
.hidden()
.incompatibleWith("disableJavaScriptProtection");
@@ -165,27 +167,33 @@ Status addMongoShellOptions(moe::OptionSection* options) {
// for testing, will kill op without prompting
options->addOptionChaining("autokillop", "autokillop", moe::Switch, "autokillop").hidden();
- options->addOptionChaining("useLegacyWriteOps",
- "useLegacyWriteOps",
- moe::Switch,
- "use legacy write ops instead of write commands").hidden();
-
- options->addOptionChaining("writeMode",
- "writeMode",
- moe::String,
- "mode to determine how writes are done:"
- " commands, compatibility, legacy").hidden();
-
- options->addOptionChaining("readMode",
- "readMode",
- moe::String,
- "mode to determine how .find() queries are done:"
- " commands, compatibility, legacy").hidden();
-
- options->addOptionChaining("rpcProtocols",
- "rpcProtocols",
- moe::String,
- " none, opQueryOnly, opCommandOnly, all").hidden();
+ options
+ ->addOptionChaining("useLegacyWriteOps",
+ "useLegacyWriteOps",
+ moe::Switch,
+ "use legacy write ops instead of write commands")
+ .hidden();
+
+ options
+ ->addOptionChaining("writeMode",
+ "writeMode",
+ moe::String,
+ "mode to determine how writes are done:"
+ " commands, compatibility, legacy")
+ .hidden();
+
+ options
+ ->addOptionChaining("readMode",
+ "readMode",
+ moe::String,
+ "mode to determine how .find() queries are done:"
+ " commands, compatibility, legacy")
+ .hidden();
+
+ options
+ ->addOptionChaining(
+ "rpcProtocols", "rpcProtocols", moe::String, " none, opQueryOnly, opCommandOnly, all")
+ .hidden();
return Status::OK();
}
@@ -313,7 +321,8 @@ Status storeMongoShellOptions(const moe::Environment& params,
throw MsgAssertionException(
17397,
mongoutils::str::stream()
- << "Unknown readMode option: '" << mode
+ << "Unknown readMode option: '"
+ << mode
<< "'. Valid modes are: {commands, compatibility, legacy}");
}
shellGlobalParams.readMode = mode;
diff --git a/src/mongo/shell/shell_utils.cpp b/src/mongo/shell/shell_utils.cpp
index bae9cce9081..1d723a4c54c 100644
--- a/src/mongo/shell/shell_utils.cpp
+++ b/src/mongo/shell/shell_utils.cpp
@@ -31,13 +31,13 @@
#include "mongo/shell/shell_utils.h"
-#include "mongo/client/replica_set_monitor.h"
#include "mongo/client/dbclientinterface.h"
+#include "mongo/client/replica_set_monitor.h"
#include "mongo/db/catalog/index_key_validate.h"
#include "mongo/db/index/external_key_generator.h"
#include "mongo/platform/random.h"
-#include "mongo/shell/bench.h"
#include "mongo/scripting/engine.h"
+#include "mongo/shell/bench.h"
#include "mongo/shell/shell_options.h"
#include "mongo/shell/shell_utils_extended.h"
#include "mongo/shell/shell_utils_launcher.h"
diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp
index b71f7a8ebc6..cd2f4f24336 100644
--- a/src/mongo/shell/shell_utils_launcher.cpp
+++ b/src/mongo/shell/shell_utils_launcher.cpp
@@ -43,9 +43,9 @@
#include <io.h>
#define SIGKILL 9
#else
-#include <sys/socket.h>
#include <netinet/in.h>
#include <signal.h>
+#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/wait.h>
#endif
@@ -297,10 +297,12 @@ ProgramRunner::ProgramRunner(const BSONObj& args, const BSONObj& env) {
// we explicitly override them.
#ifdef _WIN32
wchar_t* processEnv = GetEnvironmentStringsW();
- ON_BLOCK_EXIT([](wchar_t* toFree) {
- if (toFree)
- FreeEnvironmentStringsW(toFree);
- }, processEnv);
+ ON_BLOCK_EXIT(
+ [](wchar_t* toFree) {
+ if (toFree)
+ FreeEnvironmentStringsW(toFree);
+ },
+ processEnv);
// Windows' GetEnvironmentStringsW returns a NULL terminated array of NULL separated
// <key>=<value> pairs.
@@ -397,7 +399,7 @@ void ProgramRunner::operator()() {
programOutputLogger.appendLine(
_port, _pid, "WARNING: mongod wrote null bytes to output");
char* last = buf;
- for (char* i = strchr(buf, '\n'); i; last = i + 1, i = strchr(last, '\n')) {
+ for (char *i = strchr(buf, '\n'); i; last = i + 1, i = strchr(last, '\n')) {
*i = '\0';
programOutputLogger.appendLine(_port, _pid, last);
}
@@ -589,10 +591,9 @@ void ProgramRunner::launchProcess(int child_stdout) {
std::string execErrMsg = str::stream() << "Unable to start program " << _argv[0];
auto constCharStorageMaker = [](const std::vector<std::string>& in) {
std::vector<const char*> out;
- std::transform(in.begin(),
- in.end(),
- std::back_inserter(out),
- [](const std::string& x) { return x.c_str(); });
+ std::transform(in.begin(), in.end(), std::back_inserter(out), [](const std::string& x) {
+ return x.c_str();
+ });
out.push_back(nullptr);
return out;
};
diff --git a/src/mongo/shell/shell_utils_launcher.h b/src/mongo/shell/shell_utils_launcher.h
index 7ecb8e95384..94ec8b3fec5 100644
--- a/src/mongo/shell/shell_utils_launcher.h
+++ b/src/mongo/shell/shell_utils_launcher.h
@@ -33,8 +33,8 @@
#include <map>
#include <sstream>
#include <string>
-#include <vector>
#include <utility>
+#include <vector>
#include "mongo/bson/bsonobj.h"
#include "mongo/platform/process_id.h"
diff --git a/src/mongo/shell/types.js b/src/mongo/shell/types.js
index d932b212cf9..0179dd0a43b 100644
--- a/src/mongo/shell/types.js
+++ b/src/mongo/shell/types.js
@@ -565,10 +565,7 @@ Map.prototype._get = function(key) {
return a[i];
}
}
- var o = {
- key: key,
- value: null
- };
+ var o = {key: key, value: null};
a.push(o);
return o;
};
diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js
index 26bfd1b7cc8..c99d50a97e7 100644
--- a/src/mongo/shell/utils.js
+++ b/src/mongo/shell/utils.js
@@ -162,42 +162,38 @@ jsTestName = function() {
return "__unknown_name__";
};
-var _jsTestOptions = {
- enableTestCommands: true
-}; // Test commands should be enabled by default
+var _jsTestOptions = {enableTestCommands: true}; // Test commands should be enabled by default
jsTestOptions = function() {
if (TestData) {
- return Object.merge(
- _jsTestOptions,
- {
- setParameters: TestData.setParameters,
- setParametersMongos: TestData.setParametersMongos,
- storageEngine: TestData.storageEngine,
- wiredTigerEngineConfigString: TestData.wiredTigerEngineConfigString,
- wiredTigerCollectionConfigString: TestData.wiredTigerCollectionConfigString,
- wiredTigerIndexConfigString: TestData.wiredTigerIndexConfigString,
- noJournal: TestData.noJournal,
- noJournalPrealloc: TestData.noJournalPrealloc,
- auth: TestData.auth,
- keyFile: TestData.keyFile,
- authUser: "__system",
- authPassword: TestData.keyFileData,
- authMechanism: TestData.authMechanism,
- adminUser: TestData.adminUser || "admin",
- adminPassword: TestData.adminPassword || "password",
- useLegacyConfigServers: TestData.useLegacyConfigServers || false,
- useLegacyReplicationProtocol: TestData.useLegacyReplicationProtocol || false,
- enableMajorityReadConcern: TestData.enableMajorityReadConcern,
- writeConcernMajorityShouldJournal: TestData.writeConcernMajorityShouldJournal,
- enableEncryption: TestData.enableEncryption,
- encryptionKeyFile: TestData.encryptionKeyFile,
- auditDestination: TestData.auditDestination,
- minPort: TestData.minPort,
- maxPort: TestData.maxPort,
- // Note: does not support the array version
- mongosBinVersion: TestData.mongosBinVersion || "",
- });
+ return Object.merge(_jsTestOptions, {
+ setParameters: TestData.setParameters,
+ setParametersMongos: TestData.setParametersMongos,
+ storageEngine: TestData.storageEngine,
+ wiredTigerEngineConfigString: TestData.wiredTigerEngineConfigString,
+ wiredTigerCollectionConfigString: TestData.wiredTigerCollectionConfigString,
+ wiredTigerIndexConfigString: TestData.wiredTigerIndexConfigString,
+ noJournal: TestData.noJournal,
+ noJournalPrealloc: TestData.noJournalPrealloc,
+ auth: TestData.auth,
+ keyFile: TestData.keyFile,
+ authUser: "__system",
+ authPassword: TestData.keyFileData,
+ authMechanism: TestData.authMechanism,
+ adminUser: TestData.adminUser || "admin",
+ adminPassword: TestData.adminPassword || "password",
+ useLegacyConfigServers: TestData.useLegacyConfigServers || false,
+ useLegacyReplicationProtocol: TestData.useLegacyReplicationProtocol || false,
+ enableMajorityReadConcern: TestData.enableMajorityReadConcern,
+ writeConcernMajorityShouldJournal: TestData.writeConcernMajorityShouldJournal,
+ enableEncryption: TestData.enableEncryption,
+ encryptionKeyFile: TestData.encryptionKeyFile,
+ auditDestination: TestData.auditDestination,
+ minPort: TestData.minPort,
+ maxPort: TestData.maxPort,
+ // Note: does not support the array version
+ mongosBinVersion: TestData.mongosBinVersion || "",
+ });
}
return _jsTestOptions;
};
@@ -290,19 +286,12 @@ defaultPrompt = function() {
try {
var prompt = replSetMemberStatePrompt();
// set our status that it was good
- db.getMongo().authStatus = {
- replSetGetStatus: true,
- isMaster: true
- };
+ db.getMongo().authStatus = {replSetGetStatus: true, isMaster: true};
return prefix + prompt;
} catch (e) {
// don't have permission to run that, or requires auth
// print(e);
- status = {
- authRequired: true,
- replSetGetStatus: false,
- isMaster: true
- };
+ status = {authRequired: true, replSetGetStatus: false, isMaster: true};
}
}
// auth detected
@@ -338,9 +327,7 @@ defaultPrompt = function() {
} catch (ex) {
printjson(ex);
// reset status and let it figure it out next time.
- status = {
- isMaster: true
- };
+ status = {isMaster: true};
}
db.getMongo().authStatus = status;
@@ -540,8 +527,8 @@ shellAutocomplete = function(
var worker = function(prefix) {
var global = (function() {
- return this;
- }).call(); // trick to get global object
+ return this;
+ }).call(); // trick to get global object
var curObj = global;
var parts = prefix.split('.');
@@ -999,9 +986,7 @@ _awaitRSHostViaRSMonitor = function(hostAddr, desiredState, rsName, timeout) {
timeout = timeout || 60 * 1000;
if (desiredState == undefined) {
- desiredState = {
- ok: true
- };
+ desiredState = {ok: true};
}
print("Awaiting " + hostAddr + " to be " + tojson(desiredState) + " in " + " rs " + rsName);
@@ -1123,9 +1108,7 @@ rs._runCmd = function(c) {
};
rs.reconfig = function(cfg, options) {
cfg.version = rs.conf().version + 1;
- cmd = {
- replSetReconfig: cfg
- };
+ cmd = {replSetReconfig: cfg};
for (var i in options) {
cmd[i] = options[i];
}
@@ -1147,10 +1130,7 @@ rs.add = function(hostport, arb) {
if (c.members[i]._id > max)
max = c.members[i]._id;
if (isString(hostport)) {
- cfg = {
- _id: max + 1,
- host: hostport
- };
+ cfg = {_id: max + 1, host: hostport};
if (arb)
cfg.arbiterOnly = true;
} else if (arb == true) {
@@ -1168,9 +1148,7 @@ rs.syncFrom = function(host) {
return db._adminCommand({replSetSyncFrom: host});
};
rs.stepDown = function(stepdownSecs, catchUpSecs) {
- var cmdObj = {
- replSetStepDown: stepdownSecs === undefined ? 60 : stepdownSecs
- };
+ var cmdObj = {replSetStepDown: stepdownSecs === undefined ? 60 : stepdownSecs};
if (catchUpSecs !== undefined) {
cmdObj['secondaryCatchUpPeriodSecs'] = catchUpSecs;
}
@@ -1229,9 +1207,7 @@ rs.debug.nullLastOpWritten = function(primary, secondary) {
if (!last.value.o || !last.value.o._id) {
print("couldn't find an _id?");
} else {
- last.value.o = {
- _id: last.value.o._id
- };
+ last.value.o = {_id: last.value.o._id};
}
print("nulling out this op:");
diff --git a/src/mongo/shell/utils_auth.js b/src/mongo/shell/utils_auth.js
index e096e2c8c67..6fd913c963a 100644
--- a/src/mongo/shell/utils_auth.js
+++ b/src/mongo/shell/utils_auth.js
@@ -67,13 +67,11 @@ var authutil;
*/
authutil.asCluster = function(conn, keyfile, action) {
var ex;
- authutil.assertAuthenticate(conn,
- 'local',
- {
- user: '__system',
- mechanism: 'SCRAM-SHA-1',
- pwd: cat(keyfile).replace(/[\011-\015\040]/g, '')
- });
+ authutil.assertAuthenticate(conn, 'local', {
+ user: '__system',
+ mechanism: 'SCRAM-SHA-1',
+ pwd: cat(keyfile).replace(/[\011-\015\040]/g, '')
+ });
try {
return action();
diff --git a/src/mongo/shell/utils_sh.js b/src/mongo/shell/utils_sh.js
index 8aa5e5d19ec..99a2eff00c6 100644
--- a/src/mongo/shell/utils_sh.js
+++ b/src/mongo/shell/utils_sh.js
@@ -92,10 +92,7 @@ sh.shardCollection = function(fullName, key, unique) {
assert(key, "need a key");
assert(typeof(key) == "object", "key needs to be an object");
- var cmd = {
- shardCollection: fullName,
- key: key
- };
+ var cmd = {shardCollection: fullName, key: key};
if (unique)
cmd.unique = true;
@@ -356,9 +353,7 @@ sh._lastMigration = function(ns) {
}
}
- var searchDoc = {
- what: /^moveChunk/
- };
+ var searchDoc = {what: /^moveChunk/};
if (coll)
searchDoc.ns = coll + "";
if (dbase)
@@ -466,11 +461,7 @@ sh.getRecentFailedRounds = function(configDB) {
if (configDB === undefined)
configDB = db.getSiblingDB('config');
var balErrs = configDB.actionlog.find({what: "balancer.round"}).sort({time: -1}).limit(5);
- var result = {
- count: 0,
- lastErr: "",
- lastTime: " "
- };
+ var result = {count: 0, lastErr: "", lastTime: " "};
if (balErrs != null) {
balErrs.forEach(function(r) {
if (r.details.errorOccured) {
@@ -494,41 +485,51 @@ sh.getRecentMigrations = function(configDB) {
var yesterday = new Date(new Date() - 24 * 60 * 60 * 1000);
// Successful migrations.
- var result = configDB.changelog.aggregate([
- {
- $match: {
- time: {$gt: yesterday},
- what: "moveChunk.from", 'details.errmsg': {$exists: false}, 'details.note': 'success'
- }
- },
- {$group: {_id: {msg: "$details.errmsg"}, count: {$sum: 1}}},
- {$project: {_id: {$ifNull: ["$_id.msg", "Success"]}, count: "$count"}}
- ]).toArray();
+ var result = configDB.changelog
+ .aggregate([
+ {
+ $match: {
+ time: {$gt: yesterday},
+ what: "moveChunk.from",
+ 'details.errmsg': {$exists: false},
+ 'details.note': 'success'
+ }
+ },
+ {$group: {_id: {msg: "$details.errmsg"}, count: {$sum: 1}}},
+ {$project: {_id: {$ifNull: ["$_id.msg", "Success"]}, count: "$count"}}
+ ])
+ .toArray();
// Failed migrations.
- result = result.concat(configDB.changelog.aggregate([
- {
- $match: {
- time: {$gt: yesterday},
- what: "moveChunk.from",
- $or: [{'details.errmsg': {$exists: true}}, {'details.note': {$ne: 'success'}}]
- }
- },
- {
- $group: {
- _id: {msg: "$details.errmsg", from: "$details.from", to: "$details.to"},
- count: {$sum: 1}
- }
- },
- {
- $project: {
- _id: {$ifNull: ['$_id.msg', 'aborted']},
- from: "$_id.from",
- to: "$_id.to",
- count: "$count"
- }
- }
- ]).toArray());
+ result = result.concat(
+ configDB.changelog
+ .aggregate([
+ {
+ $match: {
+ time: {$gt: yesterday},
+ what: "moveChunk.from",
+ $or: [
+ {'details.errmsg': {$exists: true}},
+ {'details.note': {$ne: 'success'}}
+ ]
+ }
+ },
+ {
+ $group: {
+ _id: {msg: "$details.errmsg", from: "$details.from", to: "$details.to"},
+ count: {$sum: 1}
+ }
+ },
+ {
+ $project: {
+ _id: {$ifNull: ['$_id.msg', 'aborted']},
+ from: "$_id.from",
+ to: "$_id.to",
+ count: "$count"
+ }
+ }
+ ])
+ .toArray());
return result;
};
@@ -588,17 +589,16 @@ function printShardingStatus(configDB, verbose) {
};
if (verbose) {
- configDB.mongos.find(recentMongosQuery)
- .sort({ping: -1})
- .forEach(function(z) {
- output("\t" + tojsononeline(z));
- });
+ configDB.mongos.find(recentMongosQuery).sort({ping: -1}).forEach(function(z) {
+ output("\t" + tojsononeline(z));
+ });
} else {
- configDB.mongos.aggregate([
- {$match: recentMongosQuery},
- {$group: {_id: "$mongoVersion", num: {$sum: 1}}},
- {$sort: {num: -1}}
- ])
+ configDB.mongos
+ .aggregate([
+ {$match: recentMongosQuery},
+ {$group: {_id: "$mongoVersion", num: {$sum: 1}}},
+ {$sort: {num: -1}}
+ ])
.forEach(function(z) {
output("\t" + tojson(z._id) + " : " + z.num);
});
@@ -733,12 +733,10 @@ function printShardingStatus(configDB, verbose) {
"\t\t\ttoo many chunks to print, use verbose if you want to force print");
}
- configDB.tags.find({ns: coll._id})
- .sort({min: 1})
- .forEach(function(tag) {
- output("\t\t\t tag: " + tag.tag + " " + tojson(tag.min) +
- " -->> " + tojson(tag.max));
- });
+ configDB.tags.find({ns: coll._id}).sort({min: 1}).forEach(function(tag) {
+ output("\t\t\t tag: " + tag.tag + " " + tojson(tag.min) + " -->> " +
+ tojson(tag.max));
+ });
}
});
}
@@ -783,23 +781,21 @@ function printShardingSizes(configDB) {
.sort({_id: 1})
.forEach(function(coll) {
output("\t\t" + coll._id + " chunks:");
- configDB.chunks.find({"ns": coll._id})
- .sort({min: 1})
- .forEach(function(chunk) {
- var mydb = shards[chunk.shard].getDB(db._id);
- var out = mydb.runCommand({
- dataSize: coll._id,
- keyPattern: coll.key,
- min: chunk.min,
- max: chunk.max
- });
- delete out.millis;
- delete out.ok;
-
- output("\t\t\t" + tojson(chunk.min) + " -->> " + tojson(chunk.max) +
- " on : " + chunk.shard + " " + tojson(out));
-
+ configDB.chunks.find({"ns": coll._id}).sort({min: 1}).forEach(function(chunk) {
+ var mydb = shards[chunk.shard].getDB(db._id);
+ var out = mydb.runCommand({
+ dataSize: coll._id,
+ keyPattern: coll.key,
+ min: chunk.min,
+ max: chunk.max
});
+ delete out.millis;
+ delete out.ok;
+
+ output("\t\t\t" + tojson(chunk.min) + " -->> " + tojson(chunk.max) +
+ " on : " + chunk.shard + " " + tojson(out));
+
+ });
});
}
});