Search in sources :

Example 1 with IntHashMap

use of org.apache.ignite.internal.util.collection.IntHashMap in project ignite by apache.

the class DataRegionMetricsImpl method removeCacheGrpPageMetrics.

/**
 * Removes all memory page metrics associated with the given cache group.
 */
public void removeCacheGrpPageMetrics(Integer grpId) {
    PageMetrics rmvMetrics;
    synchronized (cacheGrpMetricsLock) {
        IntMap<PageMetrics> copy = new IntHashMap<>(cacheGrpMetrics);
        rmvMetrics = copy.remove(grpId);
        cacheGrpMetrics = copy;
    }
    // (it hasn't been done in previous implementations)
    if (rmvMetrics != null)
        dataRegionPageMetrics.indexPages().add(-rmvMetrics.indexPages().value());
}
Also used : IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) PageMetrics(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics)

Example 2 with IntHashMap

use of org.apache.ignite.internal.util.collection.IntHashMap in project ignite by apache.

the class DataRegionMetricsImpl method cacheGrpPageMetrics.

/**
 * Returns memory page metrics associated with the given cache group.
 */
public PageMetrics cacheGrpPageMetrics(int cacheGrpId) {
    PageMetrics pageMetrics = cacheGrpMetrics.get(cacheGrpId);
    if (pageMetrics != null)
        return pageMetrics;
    synchronized (cacheGrpMetricsLock) {
        IntMap<PageMetrics> localCacheGrpMetrics = cacheGrpMetrics;
        // double check
        PageMetrics doubleCheckPageMetrics = localCacheGrpMetrics.get(cacheGrpId);
        if (doubleCheckPageMetrics != null)
            return doubleCheckPageMetrics;
        IntMap<PageMetrics> copy = new IntHashMap<>(localCacheGrpMetrics);
        PageMetrics newMetrics = Optional.of(kernalCtx).map(GridKernalContext::cache).map(cache -> cache.cacheGroupDescriptors().get(cacheGrpId)).map(decs -> createCacheGrpPageMetrics(decs.cacheOrGroupName())).orElse(dataRegionPageMetrics);
        copy.put(cacheGrpId, newMetrics);
        cacheGrpMetrics = copy;
        return newMetrics;
    }
}
Also used : PageMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetricsImpl) IntMap(org.apache.ignite.internal.util.collection.IntMap) U(org.apache.ignite.internal.util.typedef.internal.U) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) PageMetrics(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) GridKernalContext(org.apache.ignite.internal.GridKernalContext) TestOnly(org.jetbrains.annotations.TestOnly) DataRegionMetrics(org.apache.ignite.DataRegionMetrics) Nullable(org.jetbrains.annotations.Nullable) DataRegionMetricsProvider(org.apache.ignite.DataRegionMetricsProvider) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) LongAdderWithDelegateMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderWithDelegateMetric) MetricUtils(org.apache.ignite.internal.processors.metric.impl.MetricUtils) MetricsMxBean(org.apache.ignite.mxbean.MetricsMxBean) Optional(java.util.Optional) HitRateMetric(org.apache.ignite.internal.processors.metric.impl.HitRateMetric) IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) PageMetrics(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics)

Example 3 with IntHashMap

use of org.apache.ignite.internal.util.collection.IntHashMap in project ignite by apache.

the class IgniteStatisticsInMemoryStoreImpl method loadAllObsolescence.

/**
 * {@inheritDoc}
 */
@Override
public Map<StatisticsKey, IntMap<ObjectPartitionStatisticsObsolescence>> loadAllObsolescence() {
    Map<StatisticsKey, IntMap<ObjectPartitionStatisticsObsolescence>> res = new HashMap<>();
    obsStats.forEach((k, v) -> {
        IntHashMap newV = new IntHashMap(v.size());
        v.forEach((k1, v1) -> newV.put(k1, v1));
        res.put(k, newV);
    });
    return res;
}
Also used : IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) IntMap(org.apache.ignite.internal.util.collection.IntMap)

Example 4 with IntHashMap

use of org.apache.ignite.internal.util.collection.IntHashMap in project ignite by apache.

the class GridDhtPartitionDemander method preloadEntries.

/**
 * Adds entries to partition p.
 *
 * @param topVer Topology version.
 * @param part Local partition.
 * @param infos Entries info for preload.
 * @throws IgniteCheckedException If failed.
 */
private void preloadEntries(AffinityTopologyVersion topVer, GridDhtLocalPartition part, Iterator<GridCacheEntryInfo> infos) throws IgniteCheckedException {
    // Received keys by caches, for statistics.
    IntHashMap<GridMutableLong> receivedKeys = new IntHashMap<>();
    grp.offheap().storeEntries(part, infos, new IgnitePredicateX<CacheDataRow>() {

        /**
         * {@inheritDoc}
         */
        @Override
        public boolean applyx(CacheDataRow row) throws IgniteCheckedException {
            receivedKeys.computeIfAbsent(row.cacheId(), cid -> new GridMutableLong()).incrementAndGet();
            return preloadEntry(row, topVer);
        }
    });
    updateKeyReceivedMetrics(grp, receivedKeys);
}
Also used : CacheDataRow(org.apache.ignite.internal.processors.cache.persistence.CacheDataRow) IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridMutableLong(org.apache.ignite.internal.util.GridMutableLong)

Example 5 with IntHashMap

use of org.apache.ignite.internal.util.collection.IntHashMap in project ignite by apache.

the class GridDhtPartitionDemander method mvccPreloadEntries.

/**
 * Adds mvcc entries with theirs history to partition p.
 *
 * @param topVer Topology version.
 * @param node Node which sent entry.
 * @param p Partition id.
 * @param infos Entries info for preload.
 * @throws IgniteCheckedException If failed.
 */
private void mvccPreloadEntries(AffinityTopologyVersion topVer, ClusterNode node, int p, Iterator<GridCacheEntryInfo> infos) throws IgniteCheckedException {
    if (!infos.hasNext())
        return;
    // Received keys by caches, for statistics.
    IntHashMap<GridMutableLong> receivedKeys = new IntHashMap<>();
    List<GridCacheMvccEntryInfo> entryHist = new ArrayList<>();
    GridCacheContext<?, ?> cctx = grp.sharedGroup() ? null : grp.singleCacheContext();
    // Loop through all received entries and try to preload them.
    while (infos.hasNext() || !entryHist.isEmpty()) {
        ctx.database().checkpointReadLock();
        try {
            for (int i = 0; i < PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK; i++) {
                boolean hasMore = infos.hasNext();
                assert hasMore || !entryHist.isEmpty();
                GridCacheMvccEntryInfo entry = null;
                boolean flushHistory;
                if (hasMore) {
                    entry = (GridCacheMvccEntryInfo) infos.next();
                    GridCacheMvccEntryInfo prev = entryHist.isEmpty() ? null : entryHist.get(0);
                    flushHistory = prev != null && ((grp.sharedGroup() && prev.cacheId() != entry.cacheId()) || !prev.key().equals(entry.key()));
                } else
                    flushHistory = true;
                if (flushHistory) {
                    assert !entryHist.isEmpty();
                    int cacheId = entryHist.get(0).cacheId();
                    if (grp.sharedGroup() && (cctx == null || cacheId != cctx.cacheId())) {
                        assert cacheId != CU.UNDEFINED_CACHE_ID;
                        cctx = grp.shared().cacheContext(cacheId);
                    }
                    if (cctx != null) {
                        mvccPreloadEntry(cctx, node, entryHist, topVer, p);
                        rebalanceFut.onReceivedKeys(p, 1, node);
                        receivedKeys.computeIfAbsent(cacheId, cid -> new GridMutableLong()).incrementAndGet();
                    }
                    entryHist.clear();
                    if (!hasMore)
                        break;
                }
                entryHist.add(entry);
            }
        } finally {
            ctx.database().checkpointReadUnlock();
        }
    }
    updateKeyReceivedMetrics(grp, receivedKeys);
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) Collectors.counting(java.util.stream.Collectors.counting) IteratorWrapper(org.apache.ignite.internal.util.lang.GridIterableAdapter.IteratorWrapper) CacheRebalanceMode(org.apache.ignite.cache.CacheRebalanceMode) EVT_CACHE_REBALANCE_STARTED(org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STARTED) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) EVT_CACHE_REBALANCE_STOPPED(org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STOPPED) EVT_CACHE_REBALANCE_PART_LOADED(org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_LOADED) MetricUtils.metricName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName) Collectors.toSet(java.util.stream.Collectors.toSet) CACHE_GROUP_METRICS_PREFIX(org.apache.ignite.internal.processors.cache.CacheGroupMetricsImpl.CACHE_GROUP_METRICS_PREFIX) GridCacheEntryInfo(org.apache.ignite.internal.processors.cache.GridCacheEntryInfo) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) AtomicReferenceFieldUpdater(java.util.concurrent.atomic.AtomicReferenceFieldUpdater) GridToStringExclude(org.apache.ignite.internal.util.tostring.GridToStringExclude) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DR_PRELOAD(org.apache.ignite.internal.processors.dr.GridDrType.DR_PRELOAD) Set(java.util.Set) NavigableSet(java.util.NavigableSet) UUID(java.util.UUID) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) CacheDataRow(org.apache.ignite.internal.processors.cache.persistence.CacheDataRow) Collectors(java.util.stream.Collectors) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Stream(java.util.stream.Stream) GridDhtPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology) CU(org.apache.ignite.internal.util.typedef.internal.CU) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) Objects.nonNull(java.util.Objects.nonNull) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) EVT_CACHE_REBALANCE_OBJECT_LOADED(org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_OBJECT_LOADED) GridCachePartitionExchangeManager(org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager) LongAdder(java.util.concurrent.atomic.LongAdder) DR_NONE(org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) Collectors.partitioningBy(java.util.stream.Collectors.partitioningBy) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) CacheEntryInfoCollection(org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection) CheckpointProgress(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointProgress) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) IgnitePredicateX(org.apache.ignite.internal.util.lang.IgnitePredicateX) U(org.apache.ignite.internal.util.typedef.internal.U) HashMap(java.util.HashMap) IgniteLogger(org.apache.ignite.IgniteLogger) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) AtomicReference(java.util.concurrent.atomic.AtomicReference) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext) LT(org.apache.ignite.internal.util.typedef.internal.LT) ArrayList(java.util.ArrayList) AffinityAssignment(org.apache.ignite.internal.processors.affinity.AffinityAssignment) HashSet(java.util.HashSet) ClusterNode(org.apache.ignite.cluster.ClusterNode) CI1(org.apache.ignite.internal.util.typedef.CI1) GridTimeoutObjectAdapter(org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter) S(org.apache.ignite.internal.util.typedef.internal.S) MOVING(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.MOVING) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) PAGE_SNAPSHOT_TAKEN(org.apache.ignite.internal.processors.cache.persistence.CheckpointState.PAGE_SNAPSHOT_TAKEN) FINISHED(org.apache.ignite.internal.processors.cache.persistence.CheckpointState.FINISHED) F(org.apache.ignite.internal.util.typedef.F) GridIterableAdapter(org.apache.ignite.internal.util.lang.GridIterableAdapter) Iterator(java.util.Iterator) GridTimeoutObject(org.apache.ignite.internal.processors.timeout.GridTimeoutObject) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) TTL_ETERNAL(org.apache.ignite.internal.processors.cache.GridCacheUtils.TTL_ETERNAL) GridMutableLong(org.apache.ignite.internal.util.GridMutableLong) GridDhtInvalidPartitionException(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) WalStateManager(org.apache.ignite.internal.processors.cache.WalStateManager) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) CacheMetricsImpl(org.apache.ignite.internal.processors.cache.CacheMetricsImpl) GridCacheMvccEntryInfo(org.apache.ignite.internal.processors.cache.GridCacheMvccEntryInfo) Collections(java.util.Collections) TxState(org.apache.ignite.internal.processors.cache.mvcc.txlog.TxState) PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK(org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl.PRELOAD_SIZE_UNDER_CHECKPOINT_LOCK) IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) GridCacheMvccEntryInfo(org.apache.ignite.internal.processors.cache.GridCacheMvccEntryInfo) ArrayList(java.util.ArrayList) GridMutableLong(org.apache.ignite.internal.util.GridMutableLong)

Aggregations

IntHashMap (org.apache.ignite.internal.util.collection.IntHashMap)7 HashMap (java.util.HashMap)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 CacheDataRow (org.apache.ignite.internal.processors.cache.persistence.CacheDataRow)3 U (org.apache.ignite.internal.util.typedef.internal.U)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Collectors (java.util.stream.Collectors)2 IgniteLogger (org.apache.ignite.IgniteLogger)2 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)2 CacheGroupContext (org.apache.ignite.internal.processors.cache.CacheGroupContext)2 GridCacheSharedContext (org.apache.ignite.internal.processors.cache.GridCacheSharedContext)2 FINISHED (org.apache.ignite.internal.processors.cache.persistence.CheckpointState.FINISHED)2 PageMetrics (org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics)2 GridMutableLong (org.apache.ignite.internal.util.GridMutableLong)2