in src/internal/Router.ts [446:481]
async _handleCachePartitions(payload) {
const affinityTopologyVer = new AffinityTopologyVersion(payload);
Logger.logDebug('Partitions info for topology version ' + affinityTopologyVer);
if (this._versionIsNewer(affinityTopologyVer)) {
this._distributionMap = new Map();
this._affinityTopologyVer = affinityTopologyVer;
Logger.logDebug('New affinity topology version: ' + affinityTopologyVer);
} else if (this._versionIsOlder(affinityTopologyVer)) {
Logger.logDebug('Topology version is outdated. Actual version: ' + this._affinityTopologyVer);
return;
}
const groupsNum = payload.readInteger();
Logger.logDebug('Partitions info for ' + groupsNum + ' cache groups received');
for (let i = 0; i < groupsNum; i++) {
const group = await PartitionAwarenessCacheGroup.build(this._communicator, payload);
// {partition -> nodeId}
const partitionMapping = new Map();
for (const [nodeId, partitions] of group.partitionMap) {
for (const partition of partitions) {
partitionMapping.set(partition, nodeId);
}
}
for (const [cacheId, config] of group.caches) {
const cacheAffinityMap = new CacheAffinityMap(cacheId, partitionMapping, config);
this._distributionMap.set(cacheId, cacheAffinityMap);
Logger.logDebug('Partitions info for cache: ' + cacheId);
}
}
Logger.logDebug('Got cache partitions info');
}