private object ReadDistributionMapResponse(IBinaryStream s) { var affinityTopologyVersion = new AffinityTopologyVersion(s.ReadLong(), s.ReadInt()); var size = s.ReadInt(); var mapping = new Dictionary <int, ClientCachePartitionMap>(); for (int i = 0; i < size; i++) { var grp = new ClientCachePartitionAwarenessGroup(s); if (grp.PartitionMap == null) { // Partition awareness is not applicable for these caches. foreach (var cache in grp.Caches) { mapping[cache.Key] = null; } continue; } // Count partitions to avoid reallocating array. int maxPartNum = 0; if (grp.PartitionMap == null) { continue; } foreach (var partMap in grp.PartitionMap) { foreach (var part in partMap.Value) { if (part > maxPartNum) { maxPartNum = part; } } } // Populate partition array. var partNodeIds = new Guid[maxPartNum + 1]; foreach (var partMap in grp.PartitionMap) { foreach (var part in partMap.Value) { partNodeIds[part] = partMap.Key; } } foreach (var cache in grp.Caches) { mapping[cache.Key] = new ClientCachePartitionMap(partNodeIds, cache.Value); } } _distributionMap = new ClientCacheTopologyPartitionMap(mapping, affinityTopologyVersion); return(null); }
/// <summary> /// Returns a value indicating whether distribution map is up to date. /// </summary> /// <returns></returns> private bool IsDistributionMapUpToDate(ClientCacheTopologyPartitionMap map = null) { map = map ?? _distributionMap; if (map == null || _affinityTopologyVersion == null) { return(false); } return(map.AffinityTopologyVersion >= (AffinityTopologyVersion)_affinityTopologyVersion); }