oracledb 5.1.0 → 5.4.0

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +164 -2
  2. package/LICENSE.txt +443 -0
  3. package/NOTICE.txt +1 -0
  4. package/README.md +15 -13
  5. package/THIRD_PARTY_LICENSES.txt +52 -0
  6. package/build/Release/oracledb-5.4.0-darwin-x64.node +0 -0
  7. package/build/Release/oracledb-5.4.0-darwin-x64.node-buildinfo.txt +1 -0
  8. package/build/Release/oracledb-5.4.0-linux-x64.node +0 -0
  9. package/build/Release/oracledb-5.4.0-linux-x64.node-buildinfo.txt +1 -0
  10. package/build/Release/oracledb-5.4.0-win32-x64.node +0 -0
  11. package/build/Release/oracledb-5.4.0-win32-x64.node-buildinfo.txt +1 -0
  12. package/lib/aqDeqOptions.js +1 -1
  13. package/lib/aqEnqOptions.js +1 -1
  14. package/lib/aqMessage.js +1 -1
  15. package/lib/aqQueue.js +9 -5
  16. package/lib/connection.js +233 -33
  17. package/lib/dbObject.js +17 -17
  18. package/lib/lob.js +17 -5
  19. package/lib/oracledb.js +74 -11
  20. package/lib/pool.js +271 -163
  21. package/lib/poolStatistics.js +124 -0
  22. package/lib/queryStream.js +8 -6
  23. package/lib/resultset.js +37 -9
  24. package/lib/sodaCollection.js +46 -21
  25. package/lib/sodaDatabase.js +8 -4
  26. package/lib/sodaDocCursor.js +7 -3
  27. package/lib/sodaDocument.js +1 -1
  28. package/lib/sodaOperation.js +21 -9
  29. package/lib/util.js +80 -20
  30. package/package/README.md +8 -8
  31. package/package/install.js +8 -7
  32. package/package/prunebinaries.js +4 -5
  33. package/package.json +2 -2
  34. package/LICENSE.md +0 -2685
  35. package/build/Release/oracledb-5.1.0-darwin-x64.node +0 -0
  36. package/build/Release/oracledb-5.1.0-darwin-x64.node-buildinfo.txt +0 -1
  37. package/build/Release/oracledb-5.1.0-linux-x64.node +0 -0
  38. package/build/Release/oracledb-5.1.0-linux-x64.node-buildinfo.txt +0 -1
  39. package/build/Release/oracledb-5.1.0-win32-x64.node +0 -0
  40. package/build/Release/oracledb-5.1.0-win32-x64.node-buildinfo.txt +0 -1
package/lib/pool.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2016, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -22,38 +22,35 @@
22
22
  const EventEmitter = require('events');
23
23
  const nodbUtil = require('./util.js');
24
24
  const util = require('util');
25
+ const PoolStatistics = require('./poolStatistics.js');
26
+
25
27
 
26
28
  //-----------------------------------------------------------------------------
27
29
  // _checkRequestQueue()
28
30
  // When a connection is returned to the pool, this method is called (via an
29
31
  // event handler) to determine when requests for connections should be
30
- // completed and cancels any timeout that may have been associated with the
31
- // request.
32
+ // resumed and cancels any timeout that may have been associated with the
33
+ // request. This method is also called from reconfigure() so that waiting
34
+ // connection requests can be processed. Note the use of a local variable for
35
+ // the number of connections out. This is because the connection requests will
36
+ // not resume until after the loop is finished, and therefore the number of
37
+ // connections the pool thinks is out will not be incremented.
32
38
  //-----------------------------------------------------------------------------
33
39
  function _checkRequestQueue() {
34
-
35
- // nothing to do if no requests are in the queue or the pool is still full
36
- if (this._connRequestQueue.length === 0 ||
37
- this._connectionsOut >= this.poolMax) {
38
- return;
39
- }
40
-
41
- // process the payload
42
- const payload = this._connRequestQueue.shift();
43
- if (this._enableStats) {
44
- this._totalRequestsDequeued += 1;
45
- const waitTime = Date.now() - payload.enqueuedTime;
46
- this._totalTimeInQueue += waitTime;
47
- this._minTimeInQueue = Math.min(this._minTimeInQueue, waitTime);
48
- this._maxTimeInQueue = Math.max(this._maxTimeInQueue, waitTime);
49
- }
50
- if (payload.timeoutHandle) {
51
- clearTimeout(payload.timeoutHandle);
40
+ let connectionsOut = this._connectionsOut;
41
+ while (this._connRequestQueue.length > 0 && connectionsOut < this.poolMax) {
42
+ connectionsOut += 1;
43
+ const payload = this._connRequestQueue.shift();
44
+ if (this._enableStatistics) {
45
+ this._totalRequestsDequeued += 1;
46
+ this._updateWaitStatistics(payload);
47
+ }
48
+ if (payload.timeoutHandle) {
49
+ clearTimeout(payload.timeoutHandle);
50
+ }
51
+ // inform the waiter that processing can continue
52
+ payload.resolve();
52
53
  }
53
-
54
- // inform the waiter that processing can continue
55
- payload.resolve();
56
-
57
54
  }
58
55
 
59
56
 
@@ -75,11 +72,11 @@ async function getConnection(a1) {
75
72
  options = a1;
76
73
  }
77
74
 
78
- // if pool is draining or closed, throw an appropriate error
79
- this._checkPoolOpen();
75
+ // if pool is draining/closed, throw an appropriate error
76
+ this._checkPoolOpen(true);
80
77
 
81
78
  // manage stats, if applicable
82
- if (this._enableStats) {
79
+ if (this._enableStatistics) {
83
80
  this._totalConnectionRequests += 1;
84
81
  }
85
82
 
@@ -88,20 +85,22 @@ async function getConnection(a1) {
88
85
  try {
89
86
  poolMax = this.poolMax;
90
87
  } catch (err) {
91
- if (this._enableStats) {
88
+ if (this._enableStatistics) {
92
89
  this._totalFailedRequests += 1;
93
90
  }
94
91
  throw err;
95
92
  }
96
93
 
97
- if (this._connectionsOut >= poolMax) {
94
+ if (this._connectionsOut >= poolMax ||
95
+ this.status === this._oracledb.POOL_STATUS_RECONFIGURING) {
98
96
 
99
97
  // when the queue is huge, throw error early without waiting for queue timeout
100
- if (this._connRequestQueue.length >= this.queueMax && this.queueMax >= 0) {
101
- if (this._enableStats) {
98
+ if (this._connRequestQueue.length >= this._queueMax &&
99
+ this._queueMax >= 0) {
100
+ if (this._enableStatistics) {
102
101
  this._totalRequestsRejected += 1;
103
102
  }
104
- throw new Error(nodbUtil.getErrorMessage('NJS-076', this.queueMax));
103
+ throw new Error(nodbUtil.getErrorMessage('NJS-076', this._queueMax));
105
104
  }
106
105
 
107
106
  // if too many connections are out, wait until room is made available or the
@@ -120,29 +119,29 @@ async function getConnection(a1) {
120
119
  if (ix >= 0) {
121
120
  this._connRequestQueue.splice(ix, 1);
122
121
  }
123
- if (this._enableStats) {
122
+ if (this._enableStatistics) {
124
123
  this._totalRequestTimeouts += 1;
125
- this._totalTimeInQueue += Date.now() - payload.enqueuedTime;
124
+ this._updateWaitStatistics(payload);
126
125
  }
127
126
  reject(new Error(nodbUtil.getErrorMessage('NJS-040',
128
- this.queueTimeout)));
129
- }, this.queueTimeout);
127
+ this._queueTimeout)));
128
+ }, this._queueTimeout);
130
129
  }
131
130
 
132
131
  // add payload to the queue
133
132
  this._connRequestQueue.push(payload);
134
- if (this._enableStats) {
133
+ if (this._enableStatistics) {
135
134
  payload.enqueuedTime = Date.now();
136
135
  this._totalRequestsEnqueued += 1;
137
- this._maxQueueLength = Math.max(this._maxQueueLength,
136
+ this._maximumQueueLength = Math.max(this._maximumQueueLength,
138
137
  this._connRequestQueue.length);
139
138
  }
140
139
 
141
140
  });
142
141
 
143
- // check if pool is draining or closed after delay has completed and throw
144
- // an appropriate error if so
145
- this._checkPoolOpen();
142
+ // check if pool is draining/closed after delay has
143
+ // completed and throw an appropriate error
144
+ this._checkPoolOpen(true);
146
145
 
147
146
  }
148
147
 
@@ -180,7 +179,7 @@ async function getConnection(a1) {
180
179
 
181
180
  // when connection is closed, check to see if another request should be
182
181
  // processed and update any stats, as needed
183
- conn.on('_after_close', () => {
182
+ conn.on('_afterConnClose', () => {
184
183
  this._connectionsOut -= 1;
185
184
  this.emit('_checkRequestQueue');
186
185
  if (this._connectionsOut == 0) {
@@ -188,11 +187,11 @@ async function getConnection(a1) {
188
187
  }
189
188
  });
190
189
 
191
- return conn;
190
+ return (conn);
192
191
 
193
192
  } catch (err) {
194
193
  this._connectionsOut -= 1;
195
- if (this._enableStats) {
194
+ if (this._enableStatistics) {
196
195
  this._totalFailedRequests += 1;
197
196
  }
198
197
  this.emit('_checkRequestQueue');
@@ -202,6 +201,69 @@ async function getConnection(a1) {
202
201
  }
203
202
 
204
203
 
204
+ //-----------------------------------------------------------------------------
205
+ // reconfigure()
206
+ // Reconfigure the pool, change the value for given pool-properties.
207
+ //-----------------------------------------------------------------------------
208
+ async function reconfigure(options) {
209
+
210
+ // check arguments
211
+ nodbUtil.checkArgCount(arguments, 1, 1);
212
+ nodbUtil.assert(nodbUtil.isObject(options));
213
+
214
+ // reconfiguration can happen only when status is OPEN
215
+ this._checkPoolOpen(false);
216
+
217
+ if ((options.queueMax !== undefined) &&
218
+ (typeof options.queueMax !== "number"))
219
+ throw new Error(nodbUtil.getErrorMessage('NJS-004', "queueMax"));
220
+
221
+ if ((options.queueTimeout !== undefined) &&
222
+ (typeof options.queueTimeout !== "number"))
223
+ throw new Error(nodbUtil.getErrorMessage('NJS-004', "queueTimeout"));
224
+
225
+ if ((options.enableStatistics !== undefined) &&
226
+ (typeof options.enableStatistics !== "boolean"))
227
+ throw new Error(nodbUtil.getErrorMessage('NJS-004', "enableStatistics"));
228
+
229
+ if ((options.resetStatistics !== undefined) &&
230
+ (typeof options.resetStatistics != "boolean"))
231
+ throw new Error(nodbUtil.getErrorMessage('NJS-004', "resetStatistics"));
232
+
233
+ this._status = this._oracledb.POOL_STATUS_RECONFIGURING;
234
+ try {
235
+ // poolMin/poolMax/poolIncrement/poolPingInterval/poolTimeout/
236
+ // poolMaxPerShard/stmtCacheSize/sodaMetaDataCache parameters
237
+ await this._reconfigure(options);
238
+
239
+ // pool JS parameters: queueMax, queueTimeout, enableStatistics,
240
+ // resetStatistics
241
+
242
+ // reset the statistics-metrics only if 'resetStatistics' is true or
243
+ // 'enableStatistics' is being set to true
244
+ if (options.resetStatistics == true || (options.enableStatistics == true &&
245
+ this._enableStatistics == false)) {
246
+ this._resetStatistics();
247
+ }
248
+
249
+ if (options.queueMax !== undefined) {
250
+ this._queueMax = options.queueMax;
251
+ }
252
+
253
+ if (options.queueTimeout !== undefined) {
254
+ this._queueTimeout = options.queueTimeout;
255
+ }
256
+
257
+ if (options.enableStatistics !== undefined) {
258
+ this._enableStatistics = options.enableStatistics;
259
+ }
260
+ } finally {
261
+ this._status = this._oracledb.POOL_STATUS_OPEN;
262
+ }
263
+ this.emit('_checkRequestQueue');
264
+ }
265
+
266
+
205
267
  //-----------------------------------------------------------------------------
206
268
  // close()
207
269
  // Close the pool, optionally allowing for a period of time to pass for
@@ -230,9 +292,8 @@ async function close(a1) {
230
292
 
231
293
  }
232
294
 
233
- // check status of pool; if pool is already being drained or is already
234
- // closed, raise an appropriate error
235
- this._checkPoolOpen();
295
+ // if the pool is draining/reconfiguring/closed, throw an appropriate error
296
+ this._checkPoolOpen(false);
236
297
 
237
298
  // wait for the pool to become empty or for the drain timeout to expire
238
299
  // (whichever comes first)
@@ -253,67 +314,38 @@ async function close(a1) {
253
314
  // close the pool
254
315
  await this._close({forceClose: forceClose});
255
316
  this._status = this._oracledb.POOL_STATUS_CLOSED;
256
- this.emit('_after_close');
317
+ this.emit('_afterPoolClose');
257
318
 
258
319
  }
259
320
 
260
321
 
261
322
  //-----------------------------------------------------------------------------
262
- // _logStats()
263
- // Hidden method that provides an easy way to log out the statistics related
264
- // information that's collected when _enableStats is set to true when creating
265
- // a pool. This functionality may be altered or enhanced in the future.
323
+ // logStatistics()
324
+ // Method to print statistical related information and pool related
325
+ // information when enableStatistics is set to true.
326
+ // NOTE: This function replaces the DEPRECATED _logStats() function
266
327
  //-----------------------------------------------------------------------------
267
- function _logStats() {
268
- let averageTimeInQueue;
269
-
270
- if (this.status === this._oracledb.POOL_STATUS_CLOSED) {
271
- throw new Error(nodbUtil.getErrorMessage('NJS-065'));
328
+ function logStatistics() {
329
+ const stats = this.getStatistics();
330
+ if (stats === null) {
331
+ throw new Error(nodbUtil.getErrorMessage('NJS-083'));
272
332
  }
333
+ stats.logStatistics();
334
+ }
273
335
 
274
- if (this._enableStats !== true) {
275
- console.log('Pool statistics not enabled');
276
- return;
277
- }
278
336
 
279
- averageTimeInQueue = 0;
337
+ //-----------------------------------------------------------------------------
338
+ // getStatistics()
339
+ // Method to obtain a JSON object with all statistical metrics and pool
340
+ // properties
341
+ //-----------------------------------------------------------------------------
342
+ function getStatistics() {
343
+ this._checkPoolOpen(false);
280
344
 
281
- if (this._totalRequestsEnqueued !== 0) {
282
- averageTimeInQueue = Math.round(this._totalTimeInQueue/this._totalRequestsEnqueued);
345
+ if (this._enableStatistics !== true) {
346
+ return null;
283
347
  }
284
-
285
- console.log('\nPool statistics:');
286
- console.log('...total up time (milliseconds):', Date.now() - this._createdDate);
287
- console.log('...total connection requests:', this._totalConnectionRequests);
288
- console.log('...total requests enqueued:', this._totalRequestsEnqueued);
289
- console.log('...total requests dequeued:', this._totalRequestsDequeued);
290
- console.log('...total requests failed:', this._totalFailedRequests);
291
- console.log('...total requests exceeding queueMax:', this._totalRequestsRejected);
292
- console.log('...total request timeouts:', this._totalRequestTimeouts);
293
- console.log('...max queue length:', this._maxQueueLength);
294
- console.log('...sum of time in queue (milliseconds):', this._totalTimeInQueue);
295
- console.log('...min time in queue (milliseconds):', this._minTimeInQueue);
296
- console.log('...max time in queue (milliseconds):', this._maxTimeInQueue);
297
- console.log('...avg time in queue (milliseconds):', averageTimeInQueue);
298
- console.log('...pool connections in use:', this.connectionsInUse);
299
- console.log('...pool connections open:', this.connectionsOpen);
300
- console.log('Pool attributes:');
301
- console.log('...poolAlias:', this.poolAlias);
302
- console.log('...queueMax:', this.queueMax);
303
- console.log('...queueTimeout (milliseconds):', this.queueTimeout);
304
- console.log('...poolMin:', this.poolMin);
305
- console.log('...poolMax:', this.poolMax);
306
- console.log('...poolIncrement:', this.poolIncrement);
307
- console.log('...poolTimeout (seconds):', this.poolTimeout);
308
- console.log('...poolPingInterval:', this.poolPingInterval);
309
- console.log('...sessionCallback:',
310
- typeof this.sessionCallback === 'function' ? this.sessionCallback.name :
311
- (typeof this.sessionCallback === 'string' ? '"' + this.sessionCallback + '"' : this.sessionCallback));
312
- console.log('...stmtCacheSize:', this.stmtCacheSize);
313
- console.log('Pool status:');
314
- console.log('...status:', this.status);
315
- console.log('Related environment variables:');
316
- console.log('...process.env.UV_THREADPOOL_SIZE:', process.env.UV_THREADPOOL_SIZE);
348
+ return new PoolStatistics(this);
317
349
  }
318
350
 
319
351
 
@@ -323,21 +355,70 @@ function _logStats() {
323
355
  // statistics and managing the connection queue.
324
356
  //-----------------------------------------------------------------------------
325
357
  function _setup(poolAttrs, poolAlias, oracledb) {
326
- let queueMax;
327
- let queueTimeout;
328
-
329
358
  if (typeof poolAttrs.queueTimeout !== 'undefined') {
330
- queueTimeout = poolAttrs.queueTimeout;
359
+ this._queueTimeout = poolAttrs.queueTimeout;
331
360
  } else {
332
- queueTimeout = oracledb.queueTimeout;
361
+ this._queueTimeout = oracledb.queueTimeout;
333
362
  }
334
363
 
335
364
  if (typeof poolAttrs.queueMax !== 'undefined') {
336
- queueMax = poolAttrs.queueMax;
365
+ this._queueMax = poolAttrs.queueMax;
366
+ } else {
367
+ this._queueMax = oracledb.queueMax;
368
+ }
369
+
370
+ if (typeof poolAttrs.poolMaxPerShard !== 'undefined') {
371
+ this.poolMaxPerShard = poolAttrs.poolMaxPerShard;
372
+ }
373
+
374
+ if (typeof poolAttrs.enableStatistics !== 'undefined') {
375
+ this._enableStatistics = poolAttrs.enableStatistics;
376
+ } else {
377
+ this._enableStatistics = false; // default statistics is disabled.
378
+ }
379
+
380
+ if (!this._enableStatistics) {
381
+ // DEPRECATED property _enableStats.
382
+ if (typeof poolAttrs._enableStats !== 'undefined') {
383
+ this._enableStatistics = poolAttrs._enableStats;
384
+ }
385
+ }
386
+
387
+ if (typeof poolAttrs.sessionCallback !== 'undefined') {
388
+ if (typeof poolAttrs.sessionCallback === 'function' ||
389
+ typeof poolAttrs.sessionCallback === 'string')
390
+ this._sessionCallback = poolAttrs.sessionCallback;
391
+ }
392
+
393
+ // Properties - edition, events, externalAuth - values can be set globally
394
+ // on oracledb and can be overridden at pool creation time.
395
+ if (typeof poolAttrs.edition !== 'undefined') {
396
+ this.edition = poolAttrs.edition;
397
+ } else {
398
+ this.edition = oracledb.edition;
399
+ }
400
+
401
+ if (typeof poolAttrs.events !== 'undefined') {
402
+ this.events = poolAttrs.events;
403
+ } else {
404
+ this.events = oracledb.events;
405
+ }
406
+
407
+ if (typeof poolAttrs.externalAuth !== 'undefined') {
408
+ this.externalAuth = poolAttrs.externalAuth;
337
409
  } else {
338
- queueMax = oracledb.queueMax;
410
+ this.externalAuth = oracledb.externalAuth;
339
411
  }
340
412
 
413
+ // Properties - homogeneous, user, connectString - are NOT global properties
414
+ if (typeof poolAttrs.homogeneous !== 'undefined') {
415
+ this.homogeneous = poolAttrs.homogeneous;
416
+ } else {
417
+ this.homogeneous = true;
418
+ }
419
+ this.user = poolAttrs.user || poolAttrs.userName;
420
+ this.connectString = poolAttrs.connectString || poolAttrs.connectionString;
421
+
341
422
  // register event handler for when request queue should be checked
342
423
  this.on('_checkRequestQueue', this._checkRequestQueue);
343
424
 
@@ -349,63 +430,25 @@ function _setup(poolAttrs, poolAlias, oracledb) {
349
430
  queueMax: { // maximum number of pending pool connections that can be queued
350
431
  enumerable: true,
351
432
  get: function() {
352
- return queueMax;
353
- }
433
+ return (this._queueMax);
434
+ },
354
435
  },
355
436
  queueTimeout: { // milliseconds a connection request can spend in queue before being failed
356
437
  enumerable: true,
357
438
  get: function() {
358
- return queueTimeout;
359
- }
360
- },
361
- _enableStats: { // true means pool stats will be recorded
362
- value: poolAttrs._enableStats === true
363
- },
364
- _logStats: { // output pool stats
365
- value: _logStats
366
- },
367
- _createdDate: {
368
- value: Date.now()
369
- },
370
- _totalConnectionRequests: { // total number of pool.getConnection requests
371
- value: 0,
372
- writable: true
373
- },
374
- _totalRequestsRejected: { // number of pool.getConnection requests rejected because the queue length exceeded queueMax
375
- value: 0,
376
- writable: true
377
- },
378
- _totalRequestsEnqueued: { // number of pool.getConnection requests added to queue
379
- value: 0,
380
- writable: true
381
- },
382
- _totalRequestsDequeued: { // number of pool.getConnection requests removed from queue because a pool connection became available
383
- value: 0,
384
- writable: true
385
- },
386
- _totalFailedRequests: { // number of pool.getConnection requests that failed at the C layer
387
- value: 0,
388
- writable: true
439
+ return (this._queueTimeout);
440
+ },
389
441
  },
390
- _totalRequestTimeouts: { // number of queued pool.getConnection requests that timed out without being satisfied
391
- value: 0,
392
- writable: true
393
- },
394
- _totalTimeInQueue: { // sum of time in milliseconds that all pool.getConnection requests spent in the queue
395
- value: 0,
396
- writable: true
397
- },
398
- _maxQueueLength: { // maximum length of pool queue
399
- value: 0,
400
- writable: true
401
- },
402
- _minTimeInQueue: { // shortest amount of time (milliseconds) that any pool.getConnection request spent in queue
403
- value: 0,
404
- writable: true
442
+ _enableStats: { // DEPRECATED. true means pool stats will be recorded
443
+ get: function() {
444
+ return (this._enableStatistics);
445
+ }
405
446
  },
406
- _maxTimeInQueue: { // longest amount of time (milliseconds) that any pool.getConnection request spent in queue
407
- value: 0,
408
- writable: true
447
+ enableStatistics: { // true means pool stats will be recorded
448
+ enumerable: true,
449
+ get: function() {
450
+ return (this._enableStatistics);
451
+ }
409
452
  },
410
453
  _connectionsOut: { // number of connections checked out from the pool. Must be inc/dec in the main thread in JS
411
454
  value: 0,
@@ -422,23 +465,38 @@ function _setup(poolAttrs, poolAlias, oracledb) {
422
465
  poolAlias: {
423
466
  enumerable: true,
424
467
  get: function() {
425
- return poolAlias;
468
+ return (poolAlias);
426
469
  }
427
470
  },
428
471
  status: { // open/closing/closed
429
472
  enumerable: true,
430
473
  get: function() {
431
- return this._status;
474
+ return (this._status);
432
475
  }
433
476
  },
434
477
  sessionCallback: { // session callback
435
478
  enumerable: true,
436
479
  get: function() {
437
- return poolAttrs.sessionCallback;
480
+ return this._sessionCallback;
438
481
  }
439
482
  }
440
483
  }
441
484
  );
485
+
486
+ this._resetStatistics();
487
+
488
+ }
489
+
490
+
491
+ //-----------------------------------------------------------------------------
492
+ // setAccessToken()
493
+ // set parameters for token based authentication
494
+ //-----------------------------------------------------------------------------
495
+ async function setAccessToken(options) {
496
+ // check arguments
497
+ nodbUtil.checkArgCount(arguments, 1, 1);
498
+ nodbUtil.assert(nodbUtil.isObject(options), 'NJS-005', 1);
499
+ await this._setAccessToken(options);
442
500
  }
443
501
 
444
502
 
@@ -450,22 +508,72 @@ class Pool extends EventEmitter {
450
508
  this._checkRequestQueue = _checkRequestQueue;
451
509
  this.close = nodbUtil.callbackify(close);
452
510
  this.getConnection = nodbUtil.callbackify(getConnection);
511
+ this.reconfigure = nodbUtil.callbackify(reconfigure);
512
+ this.setAccessToken = nodbUtil.callbackify(setAccessToken);
513
+ this.logStatistics = logStatistics;
514
+ this.getStatistics = getStatistics;
453
515
  this.terminate = this.close;
516
+ this._queueMax = 0;
517
+ this._queueTimeout = 0;
518
+ this._enableStatistics = false;
519
+ this._timeOfReset = this._createdDate = Date.now();
520
+ this._sessionCallback = undefined;
521
+
522
+ // DEPRECATED alias
523
+ this._logStats = this.logStatistics;
454
524
  }
455
525
 
456
- // check if pool is draining or closed and throw an appropriate error if so
457
- _checkPoolOpen() {
526
+ // check if pool is draining/reconfiguring/closed and throw an
527
+ // appropriate error
528
+ _checkPoolOpen(ignoreReconfiguring) {
529
+ // if already in reconfiguring status, nothing to do.
458
530
  if (this.status === this._oracledb.POOL_STATUS_DRAINING) {
459
531
  throw new Error(nodbUtil.getErrorMessage('NJS-064'));
460
532
  } else if (this.status === this._oracledb.POOL_STATUS_CLOSED) {
461
533
  throw new Error(nodbUtil.getErrorMessage('NJS-065'));
534
+ } else if (!ignoreReconfiguring) {
535
+ if (this.status === this._oracledb.POOL_STATUS_RECONFIGURING) {
536
+ throw new Error(nodbUtil.getErrorMessage('NJS-082'));
537
+ }
462
538
  }
463
539
  }
464
540
 
465
541
  // temporary method for determining if an object is a date until
466
- // napi_is_date() can be used (when N-API v5 can be used)
542
+ // napi_is_date() can be used (when Node-API v5 can be used)
467
543
  _isDate(val) {
468
- return util.isDate(val);
544
+ return (util.isDate(val));
545
+ }
546
+
547
+ //---------------------------------------------------------------------------
548
+ // _resetStatistics()
549
+ // To initialize the counters/timers
550
+ //---------------------------------------------------------------------------
551
+ _resetStatistics() {
552
+ this._timeOfReset = Date.now();
553
+ this._totalConnectionRequests = 0;
554
+ this._totalRequestsEnqueued = 0;
555
+ this._totalRequestsDequeued = 0;
556
+ this._totalFailedRequests = 0;
557
+ this._totalRequestsRejected = 0;
558
+ this._totalRequestTimeouts = 0;
559
+ this._maximumQueueLength = this._connRequestQueue.length;
560
+ this._totalTimeInQueue = 0;
561
+ this._minTimeInQueue = 0;
562
+ this._maxTimeInQueue = 0;
563
+ }
564
+
565
+
566
+ // update pool wait statistics after a connect request has spent some time in
567
+ // the queue
568
+ _updateWaitStatistics(payload) {
569
+ const waitTime = Date.now() - payload.enqueuedTime;
570
+ this._totalTimeInQueue += waitTime;
571
+ if (this._minTimeInQueue === 0) {
572
+ this._minTimeInQueue = waitTime;
573
+ } else {
574
+ this._minTimeInQueue = Math.min(this._minTimeInQueue, waitTime);
575
+ }
576
+ this._maxTimeInQueue = Math.max(this._maxTimeInQueue, waitTime);
469
577
  }
470
578
 
471
579
  }