@mongosh/shell-api 2.1.0 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/abstract-cursor.js +176 -132
- package/lib/abstract-cursor.js.map +1 -1
- package/lib/aggregate-or-find-cursor.js +102 -51
- package/lib/aggregate-or-find-cursor.js.map +1 -1
- package/lib/aggregation-cursor.js +59 -13
- package/lib/aggregation-cursor.js.map +1 -1
- package/lib/bulk.js +248 -197
- package/lib/bulk.js.map +1 -1
- package/lib/change-stream-cursor.js +145 -101
- package/lib/change-stream-cursor.js.map +1 -1
- package/lib/collection.d.ts +2 -1
- package/lib/collection.js +1185 -1245
- package/lib/collection.js.map +1 -1
- package/lib/cursor.js +238 -203
- package/lib/cursor.js.map +1 -1
- package/lib/database.js +1180 -1206
- package/lib/database.js.map +1 -1
- package/lib/dbquery.js +68 -22
- package/lib/dbquery.js.map +1 -1
- package/lib/decorators.d.ts +39 -13
- package/lib/decorators.js +34 -34
- package/lib/decorators.js.map +1 -1
- package/lib/explainable-cursor.js +66 -20
- package/lib/explainable-cursor.js.map +1 -1
- package/lib/explainable.js +214 -179
- package/lib/explainable.js.map +1 -1
- package/lib/field-level-encryption.js +286 -235
- package/lib/field-level-encryption.js.map +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/interruptor.js.map +1 -1
- package/lib/log-entry.js.map +1 -1
- package/lib/mongo-errors.js.map +1 -1
- package/lib/mongo.d.ts +1 -1
- package/lib/mongo.js +582 -547
- package/lib/mongo.js.map +1 -1
- package/lib/plan-cache.js +108 -64
- package/lib/plan-cache.js.map +1 -1
- package/lib/replica-set.js +290 -277
- package/lib/replica-set.js.map +1 -1
- package/lib/result.js +228 -91
- package/lib/result.js.map +1 -1
- package/lib/run-command-cursor.js +59 -13
- package/lib/run-command-cursor.js.map +1 -1
- package/lib/session.js +123 -76
- package/lib/session.js.map +1 -1
- package/lib/shard.js +507 -514
- package/lib/shard.js.map +1 -1
- package/lib/shell-api.d.ts +1 -0
- package/lib/shell-api.js +313 -260
- package/lib/shell-api.js.map +1 -1
- package/lib/shell-bson.js.map +1 -1
- package/lib/shell-instance-state.js.map +1 -1
- package/lib/stream-processor.js +139 -92
- package/lib/stream-processor.js.map +1 -1
- package/lib/streams.js +158 -110
- package/lib/streams.js.map +1 -1
- package/package.json +8 -8
package/lib/shard.js
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
7
39
|
};
|
|
8
40
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -15,529 +47,490 @@ const enums_1 = require("./enums");
|
|
|
15
47
|
const result_1 = require("./result");
|
|
16
48
|
const history_1 = require("@mongosh/history");
|
|
17
49
|
const semver_1 = __importDefault(require("semver"));
|
|
18
|
-
let Shard =
|
|
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
|
-
|
|
50
|
+
let Shard = (() => {
|
|
51
|
+
let _classDecorators = [decorators_1.shellApiClassDefault];
|
|
52
|
+
let _classDescriptor;
|
|
53
|
+
let _classExtraInitializers = [];
|
|
54
|
+
let _classThis;
|
|
55
|
+
let _classSuper = decorators_1.ShellApiWithMongoClass;
|
|
56
|
+
let _instanceExtraInitializers = [];
|
|
57
|
+
let _enableSharding_decorators;
|
|
58
|
+
let _commitReshardCollection_decorators;
|
|
59
|
+
let _abortReshardCollection_decorators;
|
|
60
|
+
let _shardCollection_decorators;
|
|
61
|
+
let _reshardCollection_decorators;
|
|
62
|
+
let _status_decorators;
|
|
63
|
+
let _addShard_decorators;
|
|
64
|
+
let _addShardToZone_decorators;
|
|
65
|
+
let _addShardTag_decorators;
|
|
66
|
+
let _updateZoneKeyRange_decorators;
|
|
67
|
+
let _addTagRange_decorators;
|
|
68
|
+
let _removeRangeFromZone_decorators;
|
|
69
|
+
let _removeTagRange_decorators;
|
|
70
|
+
let _removeShardFromZone_decorators;
|
|
71
|
+
let _removeShardTag_decorators;
|
|
72
|
+
let _enableAutoSplit_decorators;
|
|
73
|
+
let _disableAutoSplit_decorators;
|
|
74
|
+
let _splitAt_decorators;
|
|
75
|
+
let _splitFind_decorators;
|
|
76
|
+
let _moveChunk_decorators;
|
|
77
|
+
let _balancerCollectionStatus_decorators;
|
|
78
|
+
let _enableBalancing_decorators;
|
|
79
|
+
let _disableBalancing_decorators;
|
|
80
|
+
let _getBalancerState_decorators;
|
|
81
|
+
let _isBalancerRunning_decorators;
|
|
82
|
+
let _startBalancer_decorators;
|
|
83
|
+
let _stopBalancer_decorators;
|
|
84
|
+
let _setBalancerState_decorators;
|
|
85
|
+
let _getShardedDataDistribution_decorators;
|
|
86
|
+
let _startAutoMerger_decorators;
|
|
87
|
+
let _stopAutoMerger_decorators;
|
|
88
|
+
let _isAutoMergerEnabled_decorators;
|
|
89
|
+
let _disableAutoMerger_decorators;
|
|
90
|
+
let _enableAutoMerger_decorators;
|
|
91
|
+
let _checkMetadataConsistency_decorators;
|
|
92
|
+
var Shard = _classThis = class extends _classSuper {
|
|
93
|
+
constructor(database) {
|
|
94
|
+
super();
|
|
95
|
+
this._database = (__runInitializers(this, _instanceExtraInitializers), void 0);
|
|
96
|
+
this._database = database;
|
|
97
|
+
}
|
|
98
|
+
get _mongo() {
|
|
99
|
+
return this._database._mongo;
|
|
100
|
+
}
|
|
101
|
+
[enums_1.asPrintable]() {
|
|
102
|
+
return `Shard class connected to ${(0, history_1.redactURICredentials)(this._database._mongo._uri)} via db ${this._database._name}`;
|
|
103
|
+
}
|
|
104
|
+
_emitShardApiCall(methodName, methodArguments = {}) {
|
|
105
|
+
this._database._mongo._instanceState.emitApiCallWithArgs({
|
|
106
|
+
method: methodName,
|
|
107
|
+
class: 'Shard',
|
|
108
|
+
arguments: methodArguments,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
async enableSharding(database, primaryShard) {
|
|
112
|
+
(0, helpers_1.assertArgsDefinedType)([database, primaryShard], ['string', [undefined, 'string']], 'Shard.enableSharding');
|
|
113
|
+
this._emitShardApiCall('enableSharding', { database, primaryShard });
|
|
114
|
+
const cmd = {
|
|
115
|
+
enableSharding: database,
|
|
116
|
+
};
|
|
117
|
+
if (primaryShard !== undefined) {
|
|
118
|
+
cmd.primaryShard = primaryShard;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
return await this._database._runAdminCommand(cmd);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
if ((error === null || error === void 0 ? void 0 : error.codeName) === 'CommandNotFound') {
|
|
125
|
+
error.message = `${error.message}. Are you connected to mongos?`;
|
|
126
|
+
}
|
|
127
|
+
throw error;
|
|
51
128
|
}
|
|
52
|
-
throw error;
|
|
53
129
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
130
|
+
async commitReshardCollection(namespace) {
|
|
131
|
+
(0, helpers_1.assertArgsDefinedType)([namespace], ['string'], 'Shard.commitReshardCollection');
|
|
132
|
+
this._emitShardApiCall('commitReshardCollection', { namespace });
|
|
133
|
+
return await this._database._runAdminCommand({
|
|
134
|
+
commitReshardCollection: namespace,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
async abortReshardCollection(namespace) {
|
|
138
|
+
(0, helpers_1.assertArgsDefinedType)([namespace], ['string'], 'Shard.abortReshardCollection');
|
|
139
|
+
this._emitShardApiCall('abortReshardCollection', { namespace });
|
|
140
|
+
return await this._database._runAdminCommand({
|
|
141
|
+
abortReshardCollection: namespace,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
async shardCollection(namespace, key, unique, options) {
|
|
145
|
+
return await this._runShardCollection('shardCollection', namespace, key, unique, options);
|
|
146
|
+
}
|
|
147
|
+
async reshardCollection(namespace, key, unique, options) {
|
|
148
|
+
return await this._runShardCollection('reshardCollection', namespace, key, unique, options);
|
|
149
|
+
}
|
|
150
|
+
async _runShardCollection(command, namespace, key, unique, options) {
|
|
151
|
+
(0, helpers_1.assertArgsDefinedType)([namespace, key, unique, options], [
|
|
152
|
+
'string',
|
|
153
|
+
'object',
|
|
154
|
+
[undefined, 'boolean', 'object'],
|
|
155
|
+
[undefined, 'object'],
|
|
156
|
+
], `Shard.${command}`);
|
|
157
|
+
this._emitShardApiCall(command, { namespace, key, unique, options });
|
|
158
|
+
if (typeof unique === 'object' && unique !== null) {
|
|
159
|
+
options = unique;
|
|
160
|
+
unique = undefined;
|
|
161
|
+
}
|
|
162
|
+
const cmd = {
|
|
163
|
+
[command]: namespace,
|
|
164
|
+
key: key,
|
|
165
|
+
};
|
|
166
|
+
if (unique !== undefined) {
|
|
167
|
+
cmd.unique = unique;
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
return await this._database._runAdminCommand({ ...cmd, ...options });
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
if ((error === null || error === void 0 ? void 0 : error.codeName) === 'CommandNotFound') {
|
|
174
|
+
error.message = `${error.message}. Are you connected to mongos?`;
|
|
175
|
+
}
|
|
176
|
+
throw error;
|
|
100
177
|
}
|
|
101
|
-
throw error;
|
|
102
178
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
179
|
+
async status(verbose = false, configDB) {
|
|
180
|
+
const result = await (0, helpers_1.getPrintableShardStatus)(configDB !== null && configDB !== void 0 ? configDB : (await (0, helpers_1.getConfigDB)(this._database)), verbose);
|
|
181
|
+
return new result_1.CommandResult('StatsResult', result);
|
|
182
|
+
}
|
|
183
|
+
async addShard(url) {
|
|
184
|
+
(0, helpers_1.assertArgsDefinedType)([url], ['string'], 'Shard.addShard');
|
|
185
|
+
await (0, helpers_1.getConfigDB)(this._database);
|
|
186
|
+
this._emitShardApiCall('addShard', { url });
|
|
187
|
+
return this._database._runAdminCommand({
|
|
188
|
+
addShard: url,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
async addShardToZone(shard, zone) {
|
|
192
|
+
(0, helpers_1.assertArgsDefinedType)([shard, zone], ['string', 'string'], 'Shard.addShardToZone');
|
|
193
|
+
this._emitShardApiCall('addShardToZone', { shard, zone });
|
|
194
|
+
await (0, helpers_1.getConfigDB)(this._database);
|
|
195
|
+
return this._database._runAdminCommand({
|
|
196
|
+
addShardToZone: shard,
|
|
197
|
+
zone: zone,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
async addShardTag(shard, tag) {
|
|
201
|
+
(0, helpers_1.assertArgsDefinedType)([shard, tag], ['string', 'string'], 'Shard.addShardTag');
|
|
202
|
+
this._emitShardApiCall('addShardTag', { shard, tag });
|
|
203
|
+
try {
|
|
204
|
+
return await this.addShardToZone(shard, tag);
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
if ((error === null || error === void 0 ? void 0 : error.codeName) === 'CommandNotFound') {
|
|
208
|
+
error.message = `${error.message}. This method aliases to addShardToZone which exists only for server versions > 3.4.`;
|
|
209
|
+
}
|
|
210
|
+
throw error;
|
|
134
211
|
}
|
|
135
|
-
throw error;
|
|
136
212
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
213
|
+
async updateZoneKeyRange(namespace, min, max, zone) {
|
|
214
|
+
(0, helpers_1.assertArgsDefinedType)([namespace, min, max, zone], ['string', 'object', 'object', true], 'Shard.updateZoneKeyRange');
|
|
215
|
+
this._emitShardApiCall('updateZoneKeyRange', { namespace, min, max, zone });
|
|
216
|
+
await (0, helpers_1.getConfigDB)(this._database);
|
|
217
|
+
return await this._database._runAdminCommand({
|
|
218
|
+
updateZoneKeyRange: namespace,
|
|
219
|
+
min,
|
|
220
|
+
max,
|
|
221
|
+
zone,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
async addTagRange(namespace, min, max, zone) {
|
|
225
|
+
(0, helpers_1.assertArgsDefinedType)([namespace, min, max, zone], ['string', 'object', 'object', true], 'Shard.addTagRange');
|
|
226
|
+
this._emitShardApiCall('addTagRange', { namespace, min, max, zone });
|
|
227
|
+
try {
|
|
228
|
+
return await this.updateZoneKeyRange(namespace, min, max, zone);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
if ((error === null || error === void 0 ? void 0 : error.codeName) === 'CommandNotFound') {
|
|
232
|
+
error.message = `${error.message}. This method aliases to updateZoneKeyRange which exists only for server versions > 3.4.`;
|
|
233
|
+
}
|
|
234
|
+
throw error;
|
|
158
235
|
}
|
|
159
|
-
throw error;
|
|
160
236
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
237
|
+
async removeRangeFromZone(ns, min, max) {
|
|
238
|
+
(0, helpers_1.assertArgsDefinedType)([ns, min, max], ['string', 'object', 'object'], 'Shard.removeRangeFromZone');
|
|
239
|
+
this._emitShardApiCall('removeRangeFromZone', { ns, min, max });
|
|
240
|
+
return this.updateZoneKeyRange(ns, min, max, null);
|
|
241
|
+
}
|
|
242
|
+
async removeTagRange(ns, min, max) {
|
|
243
|
+
(0, helpers_1.assertArgsDefinedType)([ns, min, max], ['string', 'object', 'object'], 'Shard.removeTagRange');
|
|
244
|
+
this._emitShardApiCall('removeTagRange', { ns, min, max });
|
|
245
|
+
try {
|
|
246
|
+
return await this.updateZoneKeyRange(ns, min, max, null);
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
if ((error === null || error === void 0 ? void 0 : error.codeName) === 'CommandNotFound') {
|
|
250
|
+
error.message = `${error.message}. This method aliases to updateZoneKeyRange which exists only for server versions > 3.4.`;
|
|
251
|
+
}
|
|
252
|
+
throw error;
|
|
176
253
|
}
|
|
177
|
-
throw error;
|
|
178
254
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
255
|
+
async removeShardFromZone(shard, zone) {
|
|
256
|
+
(0, helpers_1.assertArgsDefinedType)([shard, zone], ['string', 'string'], 'Shard.removeShardFromZone');
|
|
257
|
+
this._emitShardApiCall('removeShardFromZone', { shard, zone });
|
|
258
|
+
await (0, helpers_1.getConfigDB)(this._database);
|
|
259
|
+
return await this._database._runAdminCommand({
|
|
260
|
+
removeShardFromZone: shard,
|
|
261
|
+
zone: zone,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
async removeShardTag(shard, tag) {
|
|
265
|
+
(0, helpers_1.assertArgsDefinedType)([shard, tag], ['string', 'string'], 'Shard.removeShardTag');
|
|
266
|
+
this._emitShardApiCall('removeTagRange', { shard, tag });
|
|
267
|
+
try {
|
|
268
|
+
return await this.removeShardFromZone(shard, tag);
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
if ((error === null || error === void 0 ? void 0 : error.codeName) === 'CommandNotFound') {
|
|
272
|
+
error.message = `${error.message}. This method aliases to removeShardFromZone which exists only for server versions > 3.4.`;
|
|
273
|
+
}
|
|
274
|
+
throw error;
|
|
198
275
|
}
|
|
199
|
-
throw error;
|
|
200
276
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
.updateOne({ _id: 'autosplit' }, { $set: { enabled: true } }, { upsert: true, writeConcern: { w: 'majority', wtimeout: 30000 } }));
|
|
212
|
-
}
|
|
213
|
-
async disableAutoSplit() {
|
|
214
|
-
if (this._instanceState.connectionInfo.buildInfo.version &&
|
|
215
|
-
semver_1.default.gte(this._instanceState.connectionInfo.buildInfo.version, '6.0.3')) {
|
|
216
|
-
await this._instanceState.printDeprecationWarning('Starting in MongoDB 6.0.3, automatic chunk splitting is not performed. This is because of balancing policy improvements. Auto-splitting commands still exist, but do not perform an operation. For details, see Balancing Policy Changes: https://www.mongodb.com/docs/manual/release-notes/6.0/#balancing-policy-changes\n');
|
|
217
|
-
}
|
|
218
|
-
this._emitShardApiCall('disableAutoSplit', {});
|
|
219
|
-
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
220
|
-
return (await config
|
|
221
|
-
.getCollection('settings')
|
|
222
|
-
.updateOne({ _id: 'autosplit' }, { $set: { enabled: false } }, { upsert: true, writeConcern: { w: 'majority', wtimeout: 30000 } }));
|
|
223
|
-
}
|
|
224
|
-
async splitAt(ns, query) {
|
|
225
|
-
(0, helpers_1.assertArgsDefinedType)([ns, query], ['string', 'object'], 'Shard.splitAt');
|
|
226
|
-
this._emitShardApiCall('splitAt', { ns, query });
|
|
227
|
-
return this._database._runAdminCommand({
|
|
228
|
-
split: ns,
|
|
229
|
-
middle: query,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
async splitFind(ns, query) {
|
|
233
|
-
(0, helpers_1.assertArgsDefinedType)([ns, query], ['string', 'object'], 'Shard.splitFind');
|
|
234
|
-
this._emitShardApiCall('splitFind', { ns, query });
|
|
235
|
-
return this._database._runAdminCommand({
|
|
236
|
-
split: ns,
|
|
237
|
-
find: query,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
async moveChunk(ns, query, destination) {
|
|
241
|
-
(0, helpers_1.assertArgsDefinedType)([ns, query, destination], ['string', 'object', 'string'], 'Shard.moveChunk');
|
|
242
|
-
this._emitShardApiCall('moveChunk', { ns, query, destination });
|
|
243
|
-
return this._database._runAdminCommand({
|
|
244
|
-
moveChunk: ns,
|
|
245
|
-
find: query,
|
|
246
|
-
to: destination,
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
async balancerCollectionStatus(ns) {
|
|
250
|
-
(0, helpers_1.assertArgsDefinedType)([ns], ['string'], 'Shard.balancerCollectionStatus');
|
|
251
|
-
this._emitShardApiCall('balancerCollectionStatus', { ns });
|
|
252
|
-
return this._database._runAdminCommand({
|
|
253
|
-
balancerCollectionStatus: ns,
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
async enableBalancing(ns) {
|
|
257
|
-
(0, helpers_1.assertArgsDefinedType)([ns], ['string'], 'Shard.enableBalancing');
|
|
258
|
-
this._emitShardApiCall('enableBalancing', { ns });
|
|
259
|
-
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
260
|
-
return (await config
|
|
261
|
-
.getCollection('collections')
|
|
262
|
-
.updateOne({ _id: ns }, { $set: { noBalance: false } }, { writeConcern: { w: 'majority', wtimeout: 60000 } }));
|
|
263
|
-
}
|
|
264
|
-
async disableBalancing(ns) {
|
|
265
|
-
(0, helpers_1.assertArgsDefinedType)([ns], ['string'], 'Shard.disableBalancing');
|
|
266
|
-
this._emitShardApiCall('disableBalancing', { ns });
|
|
267
|
-
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
268
|
-
return (await config
|
|
269
|
-
.getCollection('collections')
|
|
270
|
-
.updateOne({ _id: ns }, { $set: { noBalance: true } }, { writeConcern: { w: 'majority', wtimeout: 60000 } }));
|
|
271
|
-
}
|
|
272
|
-
async getBalancerState() {
|
|
273
|
-
this._emitShardApiCall('getBalancerState', {});
|
|
274
|
-
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
275
|
-
const doc = await config
|
|
276
|
-
.getCollection('settings')
|
|
277
|
-
.findOne({ _id: 'balancer' });
|
|
278
|
-
if (doc === null || doc === undefined) {
|
|
279
|
-
return true;
|
|
280
|
-
}
|
|
281
|
-
return !doc.stopped;
|
|
282
|
-
}
|
|
283
|
-
async isBalancerRunning() {
|
|
284
|
-
this._emitShardApiCall('isBalancerRunning', {});
|
|
285
|
-
await (0, helpers_1.getConfigDB)(this._database);
|
|
286
|
-
return this._database._runAdminCommand({
|
|
287
|
-
balancerStatus: 1,
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
async startBalancer(timeout = 60000) {
|
|
291
|
-
(0, helpers_1.assertArgsDefinedType)([timeout], ['number'], 'Shard.startBalancer');
|
|
292
|
-
this._emitShardApiCall('startBalancer', { timeout });
|
|
293
|
-
return this._database._runAdminCommand({
|
|
294
|
-
balancerStart: 1,
|
|
295
|
-
maxTimeMS: timeout,
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
async stopBalancer(timeout = 60000) {
|
|
299
|
-
(0, helpers_1.assertArgsDefinedType)([timeout], ['number'], 'Shard.stopBalancer');
|
|
300
|
-
this._emitShardApiCall('stopBalancer', { timeout });
|
|
301
|
-
return this._database._runAdminCommand({
|
|
302
|
-
balancerStop: 1,
|
|
303
|
-
maxTimeMS: timeout,
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
async setBalancerState(state) {
|
|
307
|
-
(0, helpers_1.assertArgsDefinedType)([state], ['boolean'], 'Shard.setBalancerState');
|
|
308
|
-
this._emitShardApiCall('setBalancerState', { state });
|
|
309
|
-
if (state) {
|
|
310
|
-
return this.startBalancer();
|
|
277
|
+
async enableAutoSplit() {
|
|
278
|
+
if (this._instanceState.connectionInfo.buildInfo.version &&
|
|
279
|
+
semver_1.default.gte(this._instanceState.connectionInfo.buildInfo.version, '6.0.3')) {
|
|
280
|
+
await this._instanceState.printDeprecationWarning('Starting in MongoDB 6.0.3, automatic chunk splitting is not performed. This is because of balancing policy improvements. Auto-splitting commands still exist, but do not perform an operation. For details, see Balancing Policy Changes: https://www.mongodb.com/docs/manual/release-notes/6.0/#balancing-policy-changes\n');
|
|
281
|
+
}
|
|
282
|
+
this._emitShardApiCall('enableAutoSplit', {});
|
|
283
|
+
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
284
|
+
return (await config
|
|
285
|
+
.getCollection('settings')
|
|
286
|
+
.updateOne({ _id: 'autosplit' }, { $set: { enabled: true } }, { upsert: true, writeConcern: { w: 'majority', wtimeout: 30000 } }));
|
|
311
287
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
this._emitShardApiCall('getShardedDataDistribution', {});
|
|
317
|
-
const cursor = await this._database
|
|
318
|
-
.getSiblingDB('admin')
|
|
319
|
-
.aggregate([{ $shardedDataDistribution: options }]);
|
|
320
|
-
try {
|
|
321
|
-
await cursor.hasNext();
|
|
322
|
-
}
|
|
323
|
-
catch (err) {
|
|
324
|
-
if (((_a = err.code) === null || _a === void 0 ? void 0 : _a.valueOf()) === 40324) {
|
|
325
|
-
err.message = `sh.getShardedDataDistribution only works on mongos and MongoDB server versions greater than 6.0.3 [Original Error: ${err.message}]`;
|
|
288
|
+
async disableAutoSplit() {
|
|
289
|
+
if (this._instanceState.connectionInfo.buildInfo.version &&
|
|
290
|
+
semver_1.default.gte(this._instanceState.connectionInfo.buildInfo.version, '6.0.3')) {
|
|
291
|
+
await this._instanceState.printDeprecationWarning('Starting in MongoDB 6.0.3, automatic chunk splitting is not performed. This is because of balancing policy improvements. Auto-splitting commands still exist, but do not perform an operation. For details, see Balancing Policy Changes: https://www.mongodb.com/docs/manual/release-notes/6.0/#balancing-policy-changes\n');
|
|
326
292
|
}
|
|
327
|
-
|
|
293
|
+
this._emitShardApiCall('disableAutoSplit', {});
|
|
294
|
+
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
295
|
+
return (await config
|
|
296
|
+
.getCollection('settings')
|
|
297
|
+
.updateOne({ _id: 'autosplit' }, { $set: { enabled: false } }, { upsert: true, writeConcern: { w: 'majority', wtimeout: 30000 } }));
|
|
328
298
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
.
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
299
|
+
async splitAt(ns, query) {
|
|
300
|
+
(0, helpers_1.assertArgsDefinedType)([ns, query], ['string', 'object'], 'Shard.splitAt');
|
|
301
|
+
this._emitShardApiCall('splitAt', { ns, query });
|
|
302
|
+
return this._database._runAdminCommand({
|
|
303
|
+
split: ns,
|
|
304
|
+
middle: query,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
async splitFind(ns, query) {
|
|
308
|
+
(0, helpers_1.assertArgsDefinedType)([ns, query], ['string', 'object'], 'Shard.splitFind');
|
|
309
|
+
this._emitShardApiCall('splitFind', { ns, query });
|
|
310
|
+
return this._database._runAdminCommand({
|
|
311
|
+
split: ns,
|
|
312
|
+
find: query,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
async moveChunk(ns, query, destination) {
|
|
316
|
+
(0, helpers_1.assertArgsDefinedType)([ns, query, destination], ['string', 'object', 'string'], 'Shard.moveChunk');
|
|
317
|
+
this._emitShardApiCall('moveChunk', { ns, query, destination });
|
|
318
|
+
return this._database._runAdminCommand({
|
|
319
|
+
moveChunk: ns,
|
|
320
|
+
find: query,
|
|
321
|
+
to: destination,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
async balancerCollectionStatus(ns) {
|
|
325
|
+
(0, helpers_1.assertArgsDefinedType)([ns], ['string'], 'Shard.balancerCollectionStatus');
|
|
326
|
+
this._emitShardApiCall('balancerCollectionStatus', { ns });
|
|
327
|
+
return this._database._runAdminCommand({
|
|
328
|
+
balancerCollectionStatus: ns,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
async enableBalancing(ns) {
|
|
332
|
+
(0, helpers_1.assertArgsDefinedType)([ns], ['string'], 'Shard.enableBalancing');
|
|
333
|
+
this._emitShardApiCall('enableBalancing', { ns });
|
|
334
|
+
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
335
|
+
return (await config
|
|
336
|
+
.getCollection('collections')
|
|
337
|
+
.updateOne({ _id: ns }, { $set: { noBalance: false } }, { writeConcern: { w: 'majority', wtimeout: 60000 } }));
|
|
338
|
+
}
|
|
339
|
+
async disableBalancing(ns) {
|
|
340
|
+
(0, helpers_1.assertArgsDefinedType)([ns], ['string'], 'Shard.disableBalancing');
|
|
341
|
+
this._emitShardApiCall('disableBalancing', { ns });
|
|
342
|
+
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
343
|
+
return (await config
|
|
344
|
+
.getCollection('collections')
|
|
345
|
+
.updateOne({ _id: ns }, { $set: { noBalance: true } }, { writeConcern: { w: 'majority', wtimeout: 60000 } }));
|
|
346
|
+
}
|
|
347
|
+
async getBalancerState() {
|
|
348
|
+
this._emitShardApiCall('getBalancerState', {});
|
|
349
|
+
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
350
|
+
const doc = await config
|
|
351
|
+
.getCollection('settings')
|
|
352
|
+
.findOne({ _id: 'balancer' });
|
|
353
|
+
if (doc === null || doc === undefined) {
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
return !doc.stopped;
|
|
357
|
+
}
|
|
358
|
+
async isBalancerRunning() {
|
|
359
|
+
this._emitShardApiCall('isBalancerRunning', {});
|
|
360
|
+
await (0, helpers_1.getConfigDB)(this._database);
|
|
361
|
+
return this._database._runAdminCommand({
|
|
362
|
+
balancerStatus: 1,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
async startBalancer(timeout = 60000) {
|
|
366
|
+
(0, helpers_1.assertArgsDefinedType)([timeout], ['number'], 'Shard.startBalancer');
|
|
367
|
+
this._emitShardApiCall('startBalancer', { timeout });
|
|
368
|
+
return this._database._runAdminCommand({
|
|
369
|
+
balancerStart: 1,
|
|
370
|
+
maxTimeMS: timeout,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
async stopBalancer(timeout = 60000) {
|
|
374
|
+
(0, helpers_1.assertArgsDefinedType)([timeout], ['number'], 'Shard.stopBalancer');
|
|
375
|
+
this._emitShardApiCall('stopBalancer', { timeout });
|
|
376
|
+
return this._database._runAdminCommand({
|
|
377
|
+
balancerStop: 1,
|
|
378
|
+
maxTimeMS: timeout,
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
async setBalancerState(state) {
|
|
382
|
+
(0, helpers_1.assertArgsDefinedType)([state], ['boolean'], 'Shard.setBalancerState');
|
|
383
|
+
this._emitShardApiCall('setBalancerState', { state });
|
|
384
|
+
if (state) {
|
|
385
|
+
return this.startBalancer();
|
|
386
|
+
}
|
|
387
|
+
return this.stopBalancer();
|
|
388
|
+
}
|
|
389
|
+
async getShardedDataDistribution(options = {}) {
|
|
390
|
+
var _a;
|
|
391
|
+
this._emitShardApiCall('getShardedDataDistribution', {});
|
|
392
|
+
const cursor = await this._database
|
|
393
|
+
.getSiblingDB('admin')
|
|
394
|
+
.aggregate([{ $shardedDataDistribution: options }]);
|
|
395
|
+
try {
|
|
396
|
+
await cursor.hasNext();
|
|
397
|
+
}
|
|
398
|
+
catch (err) {
|
|
399
|
+
if (((_a = err.code) === null || _a === void 0 ? void 0 : _a.valueOf()) === 40324) {
|
|
400
|
+
err.message = `sh.getShardedDataDistribution only works on mongos and MongoDB server versions greater than 6.0.3 [Original Error: ${err.message}]`;
|
|
401
|
+
}
|
|
402
|
+
throw err;
|
|
403
|
+
}
|
|
404
|
+
return cursor;
|
|
405
|
+
}
|
|
406
|
+
async startAutoMerger() {
|
|
407
|
+
this._emitShardApiCall('startAutoMerger', {});
|
|
408
|
+
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
409
|
+
return (await config
|
|
410
|
+
.getCollection('settings')
|
|
411
|
+
.updateOne({ _id: 'automerge' }, { $set: { enabled: true } }, { upsert: true, writeConcern: { w: 'majority', wtimeout: 30000 } }));
|
|
412
|
+
}
|
|
413
|
+
async stopAutoMerger() {
|
|
414
|
+
this._emitShardApiCall('stopAutoMerger', {});
|
|
415
|
+
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
416
|
+
return (await config
|
|
417
|
+
.getCollection('settings')
|
|
418
|
+
.updateOne({ _id: 'automerge' }, { $set: { enabled: false } }, { upsert: true, writeConcern: { w: 'majority', wtimeout: 30000 } }));
|
|
419
|
+
}
|
|
420
|
+
async isAutoMergerEnabled() {
|
|
421
|
+
this._emitShardApiCall('isAutoMergerEnabled', {});
|
|
422
|
+
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
423
|
+
const doc = await config
|
|
424
|
+
.getCollection('settings')
|
|
425
|
+
.findOne({ _id: 'automerge' });
|
|
426
|
+
if (doc === null || doc === undefined) {
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
return doc.enabled;
|
|
430
|
+
}
|
|
431
|
+
async disableAutoMerger(ns) {
|
|
432
|
+
(0, helpers_1.assertArgsDefinedType)([ns], ['string'], 'Shard.disableAutoMerger');
|
|
433
|
+
this._emitShardApiCall('disableAutoMerger', { ns });
|
|
434
|
+
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
435
|
+
return (await config
|
|
436
|
+
.getCollection('collections')
|
|
437
|
+
.updateOne({ _id: ns }, { $set: { enableAutoMerge: false } }, { writeConcern: { w: 'majority', wtimeout: 60000 } }));
|
|
438
|
+
}
|
|
439
|
+
async enableAutoMerger(ns) {
|
|
440
|
+
(0, helpers_1.assertArgsDefinedType)([ns], ['string'], 'Shard.enableAutoMerger');
|
|
441
|
+
this._emitShardApiCall('enableAutoMerger', { ns });
|
|
442
|
+
const config = await (0, helpers_1.getConfigDB)(this._database);
|
|
443
|
+
return (await config
|
|
444
|
+
.getCollection('collections')
|
|
445
|
+
.updateOne({ _id: ns }, { $unset: { enableAutoMerge: 1 } }, { writeConcern: { w: 'majority', wtimeout: 60000 } }));
|
|
446
|
+
}
|
|
447
|
+
async checkMetadataConsistency(options = {}) {
|
|
448
|
+
this._emitShardApiCall('checkMetadataConsistency', { options });
|
|
449
|
+
return this._database._runAdminCursorCommand({
|
|
450
|
+
checkMetadataConsistency: 1,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
__setFunctionName(_classThis, "Shard");
|
|
455
|
+
(() => {
|
|
456
|
+
var _a;
|
|
457
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
458
|
+
_enableSharding_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
459
|
+
_commitReshardCollection_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest])];
|
|
460
|
+
_abortReshardCollection_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest])];
|
|
461
|
+
_shardCollection_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
462
|
+
_reshardCollection_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest])];
|
|
463
|
+
_status_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
464
|
+
_addShard_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
465
|
+
_addShardToZone_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['3.4.0', enums_1.ServerVersions.latest])];
|
|
466
|
+
_addShardTag_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['3.4.0', enums_1.ServerVersions.latest])];
|
|
467
|
+
_updateZoneKeyRange_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
468
|
+
_addTagRange_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['3.4.0', enums_1.ServerVersions.latest])];
|
|
469
|
+
_removeRangeFromZone_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['3.4.0', enums_1.ServerVersions.latest])];
|
|
470
|
+
_removeTagRange_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['3.4.0', enums_1.ServerVersions.latest])];
|
|
471
|
+
_removeShardFromZone_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['3.4.0', enums_1.ServerVersions.latest])];
|
|
472
|
+
_removeShardTag_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['3.4.0', enums_1.ServerVersions.latest])];
|
|
473
|
+
_enableAutoSplit_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1]), (0, decorators_1.serverVersions)(['3.4.0', '6.0.2'])];
|
|
474
|
+
_disableAutoSplit_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1]), (0, decorators_1.serverVersions)(['3.4.0', '6.0.2'])];
|
|
475
|
+
_splitAt_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
476
|
+
_splitFind_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
477
|
+
_moveChunk_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
478
|
+
_balancerCollectionStatus_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest])];
|
|
479
|
+
_enableBalancing_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
480
|
+
_disableBalancing_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
481
|
+
_getBalancerState_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
482
|
+
_isBalancerRunning_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
483
|
+
_startBalancer_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
484
|
+
_stopBalancer_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
485
|
+
_setBalancerState_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
486
|
+
_getShardedDataDistribution_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['6.0.3', enums_1.ServerVersions.latest]), (0, decorators_1.returnType)('AggregationCursor')];
|
|
487
|
+
_startAutoMerger_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest])];
|
|
488
|
+
_stopAutoMerger_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest])];
|
|
489
|
+
_isAutoMergerEnabled_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest])];
|
|
490
|
+
_disableAutoMerger_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest])];
|
|
491
|
+
_enableAutoMerger_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest])];
|
|
492
|
+
_checkMetadataConsistency_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest])];
|
|
493
|
+
__esDecorate(_classThis, null, _enableSharding_decorators, { kind: "method", name: "enableSharding", static: false, private: false, access: { has: obj => "enableSharding" in obj, get: obj => obj.enableSharding }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
494
|
+
__esDecorate(_classThis, null, _commitReshardCollection_decorators, { kind: "method", name: "commitReshardCollection", static: false, private: false, access: { has: obj => "commitReshardCollection" in obj, get: obj => obj.commitReshardCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
495
|
+
__esDecorate(_classThis, null, _abortReshardCollection_decorators, { kind: "method", name: "abortReshardCollection", static: false, private: false, access: { has: obj => "abortReshardCollection" in obj, get: obj => obj.abortReshardCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
496
|
+
__esDecorate(_classThis, null, _shardCollection_decorators, { kind: "method", name: "shardCollection", static: false, private: false, access: { has: obj => "shardCollection" in obj, get: obj => obj.shardCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
497
|
+
__esDecorate(_classThis, null, _reshardCollection_decorators, { kind: "method", name: "reshardCollection", static: false, private: false, access: { has: obj => "reshardCollection" in obj, get: obj => obj.reshardCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
498
|
+
__esDecorate(_classThis, null, _status_decorators, { kind: "method", name: "status", static: false, private: false, access: { has: obj => "status" in obj, get: obj => obj.status }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
499
|
+
__esDecorate(_classThis, null, _addShard_decorators, { kind: "method", name: "addShard", static: false, private: false, access: { has: obj => "addShard" in obj, get: obj => obj.addShard }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
500
|
+
__esDecorate(_classThis, null, _addShardToZone_decorators, { kind: "method", name: "addShardToZone", static: false, private: false, access: { has: obj => "addShardToZone" in obj, get: obj => obj.addShardToZone }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
501
|
+
__esDecorate(_classThis, null, _addShardTag_decorators, { kind: "method", name: "addShardTag", static: false, private: false, access: { has: obj => "addShardTag" in obj, get: obj => obj.addShardTag }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
502
|
+
__esDecorate(_classThis, null, _updateZoneKeyRange_decorators, { kind: "method", name: "updateZoneKeyRange", static: false, private: false, access: { has: obj => "updateZoneKeyRange" in obj, get: obj => obj.updateZoneKeyRange }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
503
|
+
__esDecorate(_classThis, null, _addTagRange_decorators, { kind: "method", name: "addTagRange", static: false, private: false, access: { has: obj => "addTagRange" in obj, get: obj => obj.addTagRange }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
504
|
+
__esDecorate(_classThis, null, _removeRangeFromZone_decorators, { kind: "method", name: "removeRangeFromZone", static: false, private: false, access: { has: obj => "removeRangeFromZone" in obj, get: obj => obj.removeRangeFromZone }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
505
|
+
__esDecorate(_classThis, null, _removeTagRange_decorators, { kind: "method", name: "removeTagRange", static: false, private: false, access: { has: obj => "removeTagRange" in obj, get: obj => obj.removeTagRange }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
506
|
+
__esDecorate(_classThis, null, _removeShardFromZone_decorators, { kind: "method", name: "removeShardFromZone", static: false, private: false, access: { has: obj => "removeShardFromZone" in obj, get: obj => obj.removeShardFromZone }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
507
|
+
__esDecorate(_classThis, null, _removeShardTag_decorators, { kind: "method", name: "removeShardTag", static: false, private: false, access: { has: obj => "removeShardTag" in obj, get: obj => obj.removeShardTag }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
508
|
+
__esDecorate(_classThis, null, _enableAutoSplit_decorators, { kind: "method", name: "enableAutoSplit", static: false, private: false, access: { has: obj => "enableAutoSplit" in obj, get: obj => obj.enableAutoSplit }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
509
|
+
__esDecorate(_classThis, null, _disableAutoSplit_decorators, { kind: "method", name: "disableAutoSplit", static: false, private: false, access: { has: obj => "disableAutoSplit" in obj, get: obj => obj.disableAutoSplit }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
510
|
+
__esDecorate(_classThis, null, _splitAt_decorators, { kind: "method", name: "splitAt", static: false, private: false, access: { has: obj => "splitAt" in obj, get: obj => obj.splitAt }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
511
|
+
__esDecorate(_classThis, null, _splitFind_decorators, { kind: "method", name: "splitFind", static: false, private: false, access: { has: obj => "splitFind" in obj, get: obj => obj.splitFind }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
512
|
+
__esDecorate(_classThis, null, _moveChunk_decorators, { kind: "method", name: "moveChunk", static: false, private: false, access: { has: obj => "moveChunk" in obj, get: obj => obj.moveChunk }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
513
|
+
__esDecorate(_classThis, null, _balancerCollectionStatus_decorators, { kind: "method", name: "balancerCollectionStatus", static: false, private: false, access: { has: obj => "balancerCollectionStatus" in obj, get: obj => obj.balancerCollectionStatus }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
514
|
+
__esDecorate(_classThis, null, _enableBalancing_decorators, { kind: "method", name: "enableBalancing", static: false, private: false, access: { has: obj => "enableBalancing" in obj, get: obj => obj.enableBalancing }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
515
|
+
__esDecorate(_classThis, null, _disableBalancing_decorators, { kind: "method", name: "disableBalancing", static: false, private: false, access: { has: obj => "disableBalancing" in obj, get: obj => obj.disableBalancing }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
516
|
+
__esDecorate(_classThis, null, _getBalancerState_decorators, { kind: "method", name: "getBalancerState", static: false, private: false, access: { has: obj => "getBalancerState" in obj, get: obj => obj.getBalancerState }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
517
|
+
__esDecorate(_classThis, null, _isBalancerRunning_decorators, { kind: "method", name: "isBalancerRunning", static: false, private: false, access: { has: obj => "isBalancerRunning" in obj, get: obj => obj.isBalancerRunning }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
518
|
+
__esDecorate(_classThis, null, _startBalancer_decorators, { kind: "method", name: "startBalancer", static: false, private: false, access: { has: obj => "startBalancer" in obj, get: obj => obj.startBalancer }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
519
|
+
__esDecorate(_classThis, null, _stopBalancer_decorators, { kind: "method", name: "stopBalancer", static: false, private: false, access: { has: obj => "stopBalancer" in obj, get: obj => obj.stopBalancer }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
520
|
+
__esDecorate(_classThis, null, _setBalancerState_decorators, { kind: "method", name: "setBalancerState", static: false, private: false, access: { has: obj => "setBalancerState" in obj, get: obj => obj.setBalancerState }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
521
|
+
__esDecorate(_classThis, null, _getShardedDataDistribution_decorators, { kind: "method", name: "getShardedDataDistribution", static: false, private: false, access: { has: obj => "getShardedDataDistribution" in obj, get: obj => obj.getShardedDataDistribution }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
522
|
+
__esDecorate(_classThis, null, _startAutoMerger_decorators, { kind: "method", name: "startAutoMerger", static: false, private: false, access: { has: obj => "startAutoMerger" in obj, get: obj => obj.startAutoMerger }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
523
|
+
__esDecorate(_classThis, null, _stopAutoMerger_decorators, { kind: "method", name: "stopAutoMerger", static: false, private: false, access: { has: obj => "stopAutoMerger" in obj, get: obj => obj.stopAutoMerger }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
524
|
+
__esDecorate(_classThis, null, _isAutoMergerEnabled_decorators, { kind: "method", name: "isAutoMergerEnabled", static: false, private: false, access: { has: obj => "isAutoMergerEnabled" in obj, get: obj => obj.isAutoMergerEnabled }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
525
|
+
__esDecorate(_classThis, null, _disableAutoMerger_decorators, { kind: "method", name: "disableAutoMerger", static: false, private: false, access: { has: obj => "disableAutoMerger" in obj, get: obj => obj.disableAutoMerger }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
526
|
+
__esDecorate(_classThis, null, _enableAutoMerger_decorators, { kind: "method", name: "enableAutoMerger", static: false, private: false, access: { has: obj => "enableAutoMerger" in obj, get: obj => obj.enableAutoMerger }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
527
|
+
__esDecorate(_classThis, null, _checkMetadataConsistency_decorators, { kind: "method", name: "checkMetadataConsistency", static: false, private: false, access: { has: obj => "checkMetadataConsistency" in obj, get: obj => obj.checkMetadataConsistency }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
528
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
529
|
+
Shard = _classThis = _classDescriptor.value;
|
|
530
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
531
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
532
|
+
})();
|
|
533
|
+
return Shard = _classThis;
|
|
534
|
+
})();
|
|
542
535
|
exports.default = Shard;
|
|
543
536
|
//# sourceMappingURL=shard.js.map
|