blob: 3a5a6930bcecf66ff2a73e53458f8069cc2e2a22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
'use strict';
/**
* Returns true if the process is a mongos, and false otherwise.
*
*/
function isMongos(db) {
var res = db.runCommand('ismaster');
assert.commandWorked(res);
return 'isdbgrid' === res.msg;
}
/**
* Returns true if the process is a mongod, and false otherwise.
*
*/
function isMongod(db) {
return !isMongos(db);
}
/**
* Returns the name of the current storage engine.
*
* Throws an error if db is connected to a mongos, or if there is no reported storage engine.
*/
function getStorageEngineName(db) {
var status = db.serverStatus();
assert.commandWorked(status);
assert(isMongod(db), 'no storage engine is reported when connected to mongos');
assert.neq(
'undefined', typeof status.storageEngine, 'missing storage engine info in server status');
return status.storageEngine.name;
}
/**
* Returns true if the current storage engine is mmapv1, and false otherwise.
*/
function isMMAPv1(db) {
return getStorageEngineName(db) === 'mmapv1';
}
/**
* Returns true if the current storage engine is wiredTiger, and false otherwise.
*/
function isWiredTiger(db) {
return getStorageEngineName(db) === 'wiredTiger';
}
/**
* Returns true if the current storage engine is ephemeral, and false otherwise.
*/
function isEphemeral(db) {
var engine = getStorageEngineName(db);
return (engine === 'inMemory') || (engine === 'ephemeralForTest');
}
|