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

Method getNextHost

lib/prepare-handler.js:173–201  ·  view source on GitHub ↗

* Gets the next host from the query plan. * @param {Iterator} iterator * @param {ProfileManager} profileManager * @param {Object} [triedHosts] * @return {Host|null}

(iterator, profileManager, triedHosts)

Source from the content-addressed store, hash-verified

171 * @return {Host|null}
172 */
173 static getNextHost(iterator, profileManager, triedHosts) {
174 let host;
175 // Get a host that is UP in a sync loop
176 while (true) {
177 const item = iterator.next();
178 if (item.done) {
179 return null;
180 }
181
182 host = item.value;
183
184 // set the distance relative to the client first
185 const distance = profileManager.getDistance(host);
186 if (distance === types.distance.ignored) {
187 //If its marked as ignore by the load balancing policy, move on.
188 continue;
189 }
190
191 if (host.isUp()) {
192 break;
193 }
194
195 if (triedHosts) {
196 triedHosts[host.address] = 'Host considered as DOWN';
197 }
198 }
199
200 return host;
201 }
202
203 /**
204 * Prepares all queries on a single host.

Callers 2

_prepareWithQueryPlanMethod · 0.80
_prepareOnAllHostsMethod · 0.80

Calls 3

nextMethod · 0.80
isUpMethod · 0.65
getDistanceMethod · 0.45

Tested by

no test coverage detected