Search in sources :

Example 1 with CacheGroupDescriptor

use of org.apache.ignite.internal.processors.cache.CacheGroupDescriptor in project ignite by apache.

the class GridDhtPartitionsExchangeFuture method assignPartitionsStates.

/**
 */
private void assignPartitionsStates() {
    for (Map.Entry<Integer, CacheGroupDescriptor> e : cctx.affinity().cacheGroups().entrySet()) {
        CacheGroupDescriptor grpDesc = e.getValue();
        if (grpDesc.config().getCacheMode() == CacheMode.LOCAL)
            continue;
        if (!CU.isPersistentCache(grpDesc.config(), cctx.gridConfig().getDataStorageConfiguration()))
            continue;
        CacheGroupContext grpCtx = cctx.cache().cacheGroup(e.getKey());
        GridDhtPartitionTopology top = grpCtx != null ? grpCtx.topology() : cctx.exchange().clientTopology(e.getKey(), events().discoveryCache());
        assignPartitionStates(top);
    }
}
Also used : GridDhtPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 2 with CacheGroupDescriptor

use of org.apache.ignite.internal.processors.cache.CacheGroupDescriptor in project ignite by apache.

the class GridCacheDatabaseSharedManager method getPageMemoryForCacheGroup.

/**
 * Obtains PageMemory reference from cache descriptor instead of cache context.
 *
 * @param grpId Cache group id.
 * @return PageMemoryEx instance.
 * @throws IgniteCheckedException if no DataRegion is configured for a name obtained from cache descriptor.
 */
// TODO IGNITE-12722: Get rid of GridCacheDatabaseSharedManager#getPageMemoryForCacheGroup functionality.
private PageMemoryEx getPageMemoryForCacheGroup(int grpId) throws IgniteCheckedException {
    if (grpId == MetaStorage.METASTORAGE_CACHE_ID)
        return (PageMemoryEx) dataRegion(METASTORE_DATA_REGION_NAME).pageMemory();
    // TODO IGNITE-7792 add generic mapping.
    if (grpId == TxLog.TX_LOG_CACHE_ID)
        return (PageMemoryEx) dataRegion(TxLog.TX_LOG_CACHE_NAME).pageMemory();
    // TODO IGNITE-5075: cache descriptor can be removed.
    GridCacheSharedContext sharedCtx = context();
    CacheGroupDescriptor desc = sharedCtx.cache().cacheGroupDescriptors().get(grpId);
    if (desc == null)
        return null;
    String memPlcName = desc.config().getDataRegionName();
    return (PageMemoryEx) sharedCtx.database().dataRegion(memPlcName).pageMemory();
}
Also used : CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) PageMemoryEx(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext)

Example 3 with CacheGroupDescriptor

use of org.apache.ignite.internal.processors.cache.CacheGroupDescriptor in project ignite by apache.

the class FilePageStoreManager method getHolder.

/**
 * Return cache store holedr.
 *
 * @param grpId Cache group ID.
 * @return Cache store holder.
 */
private CacheStoreHolder getHolder(int grpId) throws IgniteCheckedException {
    try {
        return idxCacheStores.computeIfAbsent(grpId, (key) -> {
            CacheGroupDescriptor gDesc = cctx.cache().cacheGroupDescriptor(grpId);
            CacheStoreHolder holder0 = null;
            if (gDesc != null && CU.isPersistentCache(gDesc.config(), cctx.gridConfig().getDataStorageConfiguration())) {
                try {
                    holder0 = initForCache(gDesc, gDesc.config());
                } catch (IgniteCheckedException e) {
                    throw new IgniteException(e);
                }
            }
            return holder0;
        });
    } catch (IgniteException ex) {
        if (X.hasCause(ex, IgniteCheckedException.class))
            throw ex.getCause(IgniteCheckedException.class);
        else
            throw ex;
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor)

Example 4 with CacheGroupDescriptor

use of org.apache.ignite.internal.processors.cache.CacheGroupDescriptor in project ignite by apache.

the class GridDiscoveryManager method resolveDiscoCache.

/**
 * Gets discovery cache for given topology version.
 *
 * @param grpId Cache group ID (participates in exception message).
 * @param topVer Topology version.
 * @return Discovery cache.
 */
private DiscoCache resolveDiscoCache(int grpId, AffinityTopologyVersion topVer) {
    Snapshot snap = topSnap.get();
    DiscoCache cache = AffinityTopologyVersion.NONE.equals(topVer) || topVer.equals(snap.topVer) ? snap.discoCache : discoCacheHist.get(topVer);
    if (cache == null) {
        AffinityTopologyVersion lastAffChangedTopVer = ctx.cache().context().exchange().lastAffinityChangedTopologyVersion(topVer);
        if (!lastAffChangedTopVer.equals(topVer)) {
            assert lastAffChangedTopVer.compareTo(topVer) < 0;
            for (Map.Entry<AffinityTopologyVersion, DiscoCache> e : discoCacheHist.descendingEntrySet()) {
                if (e.getKey().isBetween(lastAffChangedTopVer, topVer))
                    return e.getValue();
                if (e.getKey().compareTo(lastAffChangedTopVer) < 0)
                    break;
            }
        }
        CacheGroupDescriptor desc = ctx.cache().cacheGroupDescriptors().get(grpId);
        throw new IgniteException("Failed to resolve nodes topology [" + "cacheGrp=" + (desc != null ? desc.cacheOrGroupName() : "N/A") + ", topVer=" + topVer + ", history=" + discoCacheHist.keySet() + ", snap=" + snap + ", locNode=" + ctx.discovery().localNode() + ']');
    }
    return cache;
}
Also used : AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteException(org.apache.ignite.IgniteException) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) GridBoundedConcurrentLinkedHashMap(org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap)

Example 5 with CacheGroupDescriptor

use of org.apache.ignite.internal.processors.cache.CacheGroupDescriptor in project ignite by apache.

the class IgniteClusterSnapshotSelfTest method testClusterSnapshotWithCacheNodeFilter.

/**
 * @throws Exception If fails.
 */
@Test
public void testClusterSnapshotWithCacheNodeFilter() throws Exception {
    int grids = 4;
    CacheConfiguration<Integer, Integer> ccfg = txCacheConfig(new CacheConfiguration<Integer, Integer>(DEFAULT_CACHE_NAME)).setNodeFilter(node -> node.consistentId().toString().endsWith("1"));
    IgniteEx ig0 = startGridsWithoutCache(grids);
    for (int i = 0; i < CACHE_KEYS_RANGE; i++) ig0.getOrCreateCache(ccfg).put(i, i);
    ig0.snapshot().createSnapshot(SNAPSHOT_NAME).get();
    stopAllGrids();
    IgniteEx snp = startGridsFromSnapshot(grids, cfg -> resolveSnapshotWorkDirectory(cfg.setCacheConfiguration()).getAbsolutePath(), SNAPSHOT_NAME, true);
    awaitPartitionMapExchange();
    checkCacheDiscoveryDataConsistent();
    CacheGroupDescriptor descr = snp.context().cache().cacheGroupDescriptors().get(CU.cacheId(ccfg.getName()));
    assertNotNull(descr);
    assertNotNull(descr.config().getNodeFilter());
    assertEquals(ccfg.getNodeFilter().apply(grid(1).localNode()), descr.config().getNodeFilter().apply(grid(1).localNode()));
    assertSnapshotCacheKeys(snp.cache(ccfg.getName()));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test)

Aggregations

CacheGroupDescriptor (org.apache.ignite.internal.processors.cache.CacheGroupDescriptor)17 HashMap (java.util.HashMap)6 Map (java.util.Map)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 IgniteException (org.apache.ignite.IgniteException)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 IgniteEx (org.apache.ignite.internal.IgniteEx)4 DynamicCacheDescriptor (org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 Ignite (org.apache.ignite.Ignite)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 GridKernalContext (org.apache.ignite.internal.GridKernalContext)3 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)3 Nullable (org.jetbrains.annotations.Nullable)3 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 List (java.util.List)2