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

Method warmup

lib/host-connection-pool.js:173–195  ·  view source on GitHub ↗

* Creates all the connections in the pool and switches the keyspace of each connection if needed. * @param {string} keyspace

(keyspace)

Source from the content-addressed store, hash-verified

171 * @param {string} keyspace
172 */
173 async warmup(keyspace) {
174 if (this.connections.length < this.coreConnectionsLength) {
175 while (this.connections.length < this.coreConnectionsLength) {
176 await this._attemptNewConnection();
177 }
178
179 this.log('info',
180 `Connection pool to host ${this._address} created with ${this.connections.length} connection(s)`);
181 } else {
182 this.log('info', `Connection pool to host ${this._address} contains ${this.connections.length} connection(s)`);
183 }
184
185 if (keyspace) {
186 try {
187 for (const connection of this.connections) {
188 await connection.changeKeyspace(keyspace);
189 }
190 } catch (err) {
191 // Log it and move on, it could be a momentary schema mismatch failure
192 this.log('warning', `Connection(s) to host ${this._address} could not be switched to keyspace ${keyspace}`);
193 }
194 }
195 }
196
197 /** @returns {Connection} */
198 _createConnection() {

Callers 1

warmupPoolMethod · 0.80

Calls 2

_attemptNewConnectionMethod · 0.95
changeKeyspaceMethod · 0.80

Tested by

no test coverage detected