Search in sources :

Example 1 with IgniteDhtPartitionHistorySuppliersMap

use of org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionHistorySuppliersMap in project ignite by apache.

the class GridCachePartitionExchangeManager method createPartitionsFullMessage.

/**
 * Creates partitions full message for selected cache groups.
 *
 * @param compress {@code True} if possible to compress message (properly work only if prepareMarshall/
 *     finishUnmarshall methods are called).
 * @param newCntrMap {@code True} if possible to use {@link CachePartitionFullCountersMap}.
 * @param exchId Non-null exchange ID if message is created for exchange.
 * @param lastVer Last version.
 * @param partHistSuppliers Partition history suppliers map.
 * @param partsToReload Partitions to reload map.
 * @param grps Selected cache groups.
 * @return Message.
 */
public GridDhtPartitionsFullMessage createPartitionsFullMessage(boolean compress, boolean newCntrMap, @Nullable final GridDhtPartitionExchangeId exchId, @Nullable GridCacheVersion lastVer, @Nullable IgniteDhtPartitionHistorySuppliersMap partHistSuppliers, @Nullable IgniteDhtPartitionsToReloadMap partsToReload, Collection<CacheGroupContext> grps) {
    AffinityTopologyVersion ver = exchId != null ? exchId.topologyVersion() : AffinityTopologyVersion.NONE;
    final GridDhtPartitionsFullMessage m = new GridDhtPartitionsFullMessage(exchId, lastVer, ver, partHistSuppliers, partsToReload);
    m.compressed(compress);
    final Map<Object, T2<Integer, GridDhtPartitionFullMap>> dupData = new HashMap<>();
    Map<Integer, Map<Integer, Long>> partsSizes = new HashMap<>();
    for (CacheGroupContext grp : grps) {
        if (!grp.isLocal()) {
            if (exchId != null) {
                AffinityTopologyVersion startTopVer = grp.localStartVersion();
                if (startTopVer.compareTo(exchId.topologyVersion()) > 0)
                    continue;
            }
            GridAffinityAssignmentCache affCache = grp.affinity();
            GridDhtPartitionFullMap locMap = grp.topology().partitionMap(true);
            if (locMap != null)
                addFullPartitionsMap(m, dupData, compress, grp.groupId(), locMap, affCache.similarAffinityKey());
            Map<Integer, Long> partSizesMap = grp.topology().globalPartSizes();
            if (!partSizesMap.isEmpty())
                partsSizes.put(grp.groupId(), partSizesMap);
            if (exchId != null) {
                CachePartitionFullCountersMap cntrsMap = grp.topology().fullUpdateCounters();
                if (newCntrMap)
                    m.addPartitionUpdateCounters(grp.groupId(), cntrsMap);
                else {
                    m.addPartitionUpdateCounters(grp.groupId(), CachePartitionFullCountersMap.toCountersMap(cntrsMap));
                }
                // Lost partitions can be skipped on node left or activation.
                m.addLostPartitions(grp.groupId(), grp.topology().lostPartitions());
            }
        }
    }
    // It is important that client topologies be added after contexts.
    for (GridClientPartitionTopology top : cctx.exchange().clientTopologies()) {
        GridDhtPartitionFullMap map = top.partitionMap(true);
        if (map != null)
            addFullPartitionsMap(m, dupData, compress, top.groupId(), map, top.similarAffinityKey());
        if (exchId != null) {
            CachePartitionFullCountersMap cntrsMap = top.fullUpdateCounters();
            if (newCntrMap)
                m.addPartitionUpdateCounters(top.groupId(), cntrsMap);
            else
                m.addPartitionUpdateCounters(top.groupId(), CachePartitionFullCountersMap.toCountersMap(cntrsMap));
            Map<Integer, Long> partSizesMap = top.globalPartSizes();
            if (!partSizesMap.isEmpty())
                partsSizes.put(top.groupId(), partSizesMap);
            m.addLostPartitions(top.groupId(), top.lostPartitions());
        }
    }
    if (!partsSizes.isEmpty())
        m.partitionSizes(cctx, partsSizes);
    return m;
}
Also used : AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) CachePartitionFullCountersMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionFullCountersMap) GridDhtPartitionFullMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridDhtPartitionsFullMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage) GridAffinityAssignmentCache(org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache) AtomicLong(java.util.concurrent.atomic.AtomicLong) IgniteSystemProperties.getLong(org.apache.ignite.IgniteSystemProperties.getLong) GridTimeoutObject(org.apache.ignite.internal.processors.timeout.GridTimeoutObject) GridPartitionStateMap(org.apache.ignite.internal.util.GridPartitionStateMap) CachePartitionFullCountersMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionFullCountersMap) Map(java.util.Map) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) IgniteDhtPartitionsToReloadMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionsToReloadMap) GridDhtPartitionFullMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap) CachePartitionPartialCountersMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap) GridDhtPartitionMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap) IgniteDhtPartitionHistorySuppliersMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionHistorySuppliersMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) T2(org.apache.ignite.internal.util.typedef.T2) GridClientPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridClientPartitionTopology)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 ConcurrentNavigableMap (java.util.concurrent.ConcurrentNavigableMap)1 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IgniteSystemProperties.getLong (org.apache.ignite.IgniteSystemProperties.getLong)1 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)1 GridAffinityAssignmentCache (org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache)1 CachePartitionFullCountersMap (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionFullCountersMap)1 CachePartitionPartialCountersMap (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap)1 GridDhtPartitionFullMap (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap)1 GridDhtPartitionMap (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap)1 GridDhtPartitionsFullMessage (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage)1 IgniteDhtPartitionHistorySuppliersMap (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionHistorySuppliersMap)1 IgniteDhtPartitionsToReloadMap (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionsToReloadMap)1 GridClientPartitionTopology (org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridClientPartitionTopology)1 GridTimeoutObject (org.apache.ignite.internal.processors.timeout.GridTimeoutObject)1