in lib/internal/Router.js [323:347]
async _chooseConnection(affinityHint) {
const cacheId = affinityHint.cacheId;
if (!this._distributionMap.has(cacheId)) {
Logger.logDebug('Distribution map does not have info for the cache ' + cacheId);
Logger.logDebug('Node has been chosen randomly');
// We are not awaiting here in order to not increase latency of requests
this._getCachePartitions(cacheId);
return this._getRandomConnection();
}
const cacheAffinityMap = this._distributionMap.get(cacheId);
const nodeId = await this._determineNodeId(cacheAffinityMap,
affinityHint.key,
affinityHint.keyType);
if (nodeId in this._connections) {
Logger.logDebug('Node has been chosen by affinity');
return this._connections[nodeId];
}
Logger.logDebug('Node has been chosen randomly');
return this._getRandomConnection();
}