MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / _checkPoolState

Method _checkPoolState

lib/host.js:381–397  ·  view source on GitHub ↗

* Validates that the internal state of the connection pool. * If the pool size is smaller than expected, schedule a new connection attempt. * If the amount of connections is 0 for not ignored hosts, the host must be down. * @private

()

Source from the content-addressed store, hash-verified

379 * @private
380 */
381 _checkPoolState() {
382 if (this.pool.isClosing()) {
383 return;
384 }
385 if (this.pool.connections.length < this.pool.coreConnectionsLength) {
386 // the pool needs to grow / reconnect
387 if (!this.pool.hasScheduledNewConnection()) {
388 this.reconnectionDelay = this.reconnectionSchedule.next().value;
389 this.pool.scheduleNewConnectionAttempt(this.reconnectionDelay);
390 }
391 }
392 const shouldHaveConnections = this._distance !== types.distance.ignored && this.pool.coreConnectionsLength > 0;
393 if (shouldHaveConnections && this.pool.connections.length === 0) {
394 // Mark as DOWN, if its UP
395 this.setDown();
396 }
397 }
398
399 /**
400 * Executed after an scheduled new connection attempt finished

Callers 4

constructorMethod · 0.95
setDownMethod · 0.95
removeFromPoolMethod · 0.95
_onNewConnectionOpenMethod · 0.95

Calls 5

setDownMethod · 0.95
isClosingMethod · 0.80
nextMethod · 0.80

Tested by

no test coverage detected