/** {@inheritDoc} */ @Override public long getRowCount() { return ctx.cache().cacheGroupDescriptors().size(); } }
/** * Validate propose message. * * @param msg Message. * @return Error message or {@code null} if everything is OK. */ @Nullable private String validate(WalStateProposeMessage msg) { // Is group still there? CacheGroupDescriptor grpDesc = cacheProcessor().cacheGroupDescriptors().get(msg.groupId()); if (grpDesc == null) return "Failed to change WAL mode because some caches no longer exist: " + msg.caches().keySet(); // Are specified caches still there? for (Map.Entry<String, IgniteUuid> cache : msg.caches().entrySet()) { String cacheName = cache.getKey(); DynamicCacheDescriptor cacheDesc = cacheProcessor().cacheDescriptor(cacheName); if (cacheDesc == null || !F.eq(cacheDesc.deploymentId(), cache.getValue())) return "Cache doesn't exist: " + cacheName; } // Are there any new caches in the group? HashSet<String> grpCacheNames = new HashSet<>(grpDesc.caches().keySet()); grpCacheNames.removeAll(msg.caches().keySet()); if (!grpCacheNames.isEmpty()) { return "Cannot change WAL mode because not all cache names belonging to the " + "group are provided [group=" + grpDesc.groupName() + ", missingCaches=" + grpCacheNames + ']'; } return null; }
/** * @param msg Message. * @return Cache or group descriptor. */ private Object descriptorForMessage(GridCacheMessage msg) { if (msg instanceof GridCacheIdMessage) return cctx.cache().cacheDescriptor(((GridCacheIdMessage)msg).cacheId()); else if (msg instanceof GridCacheGroupIdMessage) return cctx.cache().cacheGroupDescriptors().get(((GridCacheGroupIdMessage)msg).groupId()); return null; }
/** * @param knownKeys Saved keys set. * @return New keys for local cache groups. */ @Nullable private HashMap<Integer, byte[]> newEncryptionKeys(Set<Integer> knownKeys) { Map<Integer, CacheGroupDescriptor> grpDescs = ctx.cache().cacheGroupDescriptors(); HashMap<Integer, byte[]> newKeys = null; for (CacheGroupDescriptor grpDesc : grpDescs.values()) { if (knownKeys.contains(grpDesc.groupId()) || !grpDesc.config().isEncryptionEnabled()) continue; if (newKeys == null) newKeys = new HashMap<>(); newKeys.put(grpDesc.groupId(), getSpi().encryptKey(getSpi().create())); } return newKeys; }
/** * @param grpCnt Group count. */ private void validateDepIds(int grpCnt) { Map<Integer, IgniteUuid> depIds = new HashMap<>(); for (Ignite ignite : G.allGrids()) { final Map<Integer, CacheGroupDescriptor> descMap = ((IgniteEx) ignite).context().cache().cacheGroupDescriptors(); for (Map.Entry<Integer, CacheGroupDescriptor> entry : descMap.entrySet()) { final IgniteUuid u = entry.getValue().deploymentId(); final IgniteUuid u0 = depIds.get(entry.getKey()); if (u0 == null) depIds.put(entry.getKey(), u); else assertEquals("Descriptors do not match", u0, u); } } assertEquals(grpCnt + 1, depIds.size()); }
/** */ private void verifyCachesAndGroups(IgniteEx ignite) { Map<String, DynamicCacheDescriptor> caches = ignite.context().cache().cacheDescriptors(); assertEquals(2, caches.size()); caches.keySet().contains(GridCacheUtils.UTILITY_CACHE_NAME); caches.keySet().contains(STATIC_CACHE_NAME); Map<Integer, CacheGroupDescriptor> groups = ignite.context().cache().cacheGroupDescriptors(); assertEquals(2, groups.size()); boolean defaultGroupFound = false; boolean staticCachesGroupFound = false; for (CacheGroupDescriptor grpDesc : groups.values()) { if (grpDesc.cacheOrGroupName().equals(GridCacheUtils.UTILITY_CACHE_NAME)) defaultGroupFound = true; else if (grpDesc.cacheOrGroupName().equals(GROUP_WITH_STATIC_CACHES)) staticCachesGroupFound = true; } assertTrue(String.format("Default group found: %b, static group found: %b", defaultGroupFound, staticCachesGroupFound), defaultGroupFound && staticCachesGroupFound); }
/** * 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().cacheGroupDescriptors().get(grpId); CacheStoreHolder holder0 = null; if (gDesc != null) { if (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; } }
/** * Callback invoked when caches info is collected inside cache processor start routine. Discovery is not * active at this point. */ public void onCachesInfoCollected() { if (!srv) return; synchronized (mux) { // Process top pending requests. for (CacheGroupDescriptor grpDesc : cacheProcessor().cacheGroupDescriptors().values()) { WalStateProposeMessage msg = grpDesc.nextWalChangeRequest(); if (msg != null) { if (log.isDebugEnabled()) log.debug("Processing WAL state message on start: " + msg); boolean enabled = grpDesc.walEnabled(); WalStateResult res; if (F.eq(enabled, msg.enable())) res = new WalStateResult(msg, false); else { res = new WalStateResult(msg, true); grpDesc.walEnabled(!enabled); } initialRess.add(res); addResult(res); } } } }
CacheGroupDescriptor desc = ctx.cache().cacheGroupDescriptors().get(grpId);
/** * 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. */ 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(); }
/** {@inheritDoc} */ @Override public void cleanupRestoredCaches() { if (dataRegionMap.isEmpty()) return; for (CacheGroupDescriptor grpDesc : cctx.cache().cacheGroupDescriptors().values()) { String regionName = grpDesc.config().getDataRegionName(); DataRegion region = regionName != null ? dataRegionMap.get(regionName) : dfltDataRegion; if (region == null) continue; if (log.isInfoEnabled()) log.info("Page memory " + region.config().getName() + " for " + grpDesc + " has invalidated."); int partitions = grpDesc.config().getAffinity().partitions(); if (region.pageMemory() instanceof PageMemoryEx) { PageMemoryEx memEx = (PageMemoryEx)region.pageMemory(); for (int partId = 0; partId < partitions; partId++) memEx.invalidate(grpDesc.groupId(), partId); memEx.invalidate(grpDesc.groupId(), PageIdAllocator.INDEX_PARTITION); } } storeMgr.cleanupPageStoreIfMatch( new Predicate<Integer>() { @Override public boolean test(Integer grpId) { return MetaStorage.METASTORAGE_CACHE_ID != grpId; } }, true); }
CacheGroupDescriptor grpDesc = cacheProcessor().cacheGroupDescriptors().get(msg.groupId());
log.info("Starting binary memory restore for: " + cctx.cache().cacheGroupDescriptors().keySet());
CacheGroupDescriptor cacheGrp = ctx.cache().cacheGroupDescriptors().get(idCond.valueForEquality().getInt()); cacheGroups = ctx.cache().cacheGroupDescriptors().values();
CacheGroupDescriptor desc = cctx.cache().cacheGroupDescriptors().get(msg0.groupId());
log.debug("WAL state change message is valid (will continue processing): " + msg); CacheGroupDescriptor grpDesc = cacheProcessor().cacheGroupDescriptors().get(msg.groupId());
((IgniteKernal)node).context().cache().cacheGroupDescriptors(); Map<String, DynamicCacheDescriptor> caches0 = ((IgniteKernal)node).context().cache().cacheDescriptors();
/** * @param msg Message. * @return Cache or group descriptor. */ private Object descriptorForMessage(GridCacheMessage msg) { if (msg instanceof GridCacheIdMessage) return cctx.cache().cacheDescriptor(((GridCacheIdMessage)msg).cacheId()); else if (msg instanceof GridCacheGroupIdMessage) return cctx.cache().cacheGroupDescriptors().get(((GridCacheGroupIdMessage)msg).groupId()); return null; }
/** * @param knownKeys Saved keys set. * @return New keys for local cache groups. */ @Nullable private HashMap<Integer, byte[]> newEncryptionKeys(Set<Integer> knownKeys) { Map<Integer, CacheGroupDescriptor> grpDescs = ctx.cache().cacheGroupDescriptors(); HashMap<Integer, byte[]> newKeys = null; for (CacheGroupDescriptor grpDesc : grpDescs.values()) { if (knownKeys.contains(grpDesc.groupId()) || !grpDesc.config().isEncryptionEnabled()) continue; if (newKeys == null) newKeys = new HashMap<>(); newKeys.put(grpDesc.groupId(), getSpi().encryptKey(getSpi().create())); } return newKeys; }
/** * 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. */ private PageMemoryEx getPageMemoryForCacheGroup(int grpId) throws IgniteCheckedException { // 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) throw new IgniteCheckedException("Failed to find cache group descriptor [grpId=" + grpId + ']'); String memPlcName = desc.config().getDataRegionName(); return (PageMemoryEx)sharedCtx.database().dataRegion(memPlcName).pageMemory(); }