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);
}
}
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();
}
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;
}
}
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;
}
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()));
}
Aggregations