/** {@inheritDoc} */ @Override public long getRowCount() { return ctx.cache().cacheDescriptors().size(); } }
/** * Gets a collection of currently started caches. * * @return Collection of started cache names. */ public Collection<String> cacheNames() { return F.viewReadOnly(cacheDescriptors().values(), new IgniteClosure<DynamicCacheDescriptor, String>() { @Override public String apply(DynamicCacheDescriptor desc) { return desc.cacheConfiguration().getName(); } }); }
/** * Gets a collection of currently started public cache names. * * @return Collection of currently started public cache names */ public Collection<String> publicCacheNames() { return F.viewReadOnly(cacheDescriptors().values(), new IgniteClosure<DynamicCacheDescriptor, String>() { @Override public String apply(DynamicCacheDescriptor desc) { return desc.cacheConfiguration().getName(); } }, new IgnitePredicate<DynamicCacheDescriptor>() { @Override public boolean apply(DynamicCacheDescriptor desc) { return desc.cacheType().userCache(); } } ); }
/** * Gets a collection of currently started public cache names. * * @return Collection of currently started public cache names */ public Collection<String> publicAndDsCacheNames() { return F.viewReadOnly(cacheDescriptors().values(), new IgniteClosure<DynamicCacheDescriptor, String>() { @Override public String apply(DynamicCacheDescriptor desc) { return desc.cacheConfiguration().getName(); } }, new IgnitePredicate<DynamicCacheDescriptor>() { @Override public boolean apply(DynamicCacheDescriptor desc) { return desc.cacheType().userCache() || desc.cacheType() == CacheType.DATA_STRUCTURES; } } ); }
/** * @param cacheId Cache ID. * @return Cache descriptor. */ @Nullable public DynamicCacheDescriptor cacheDescriptor(int cacheId) { for (DynamicCacheDescriptor cacheDesc : cacheDescriptors().values()) { CacheConfiguration ccfg = cacheDesc.cacheConfiguration(); assert ccfg != null : cacheDesc; if (CU.cacheId(ccfg.getName()) == cacheId) return cacheDesc; } return null; }
/** {@inheritDoc} */ @Override protected VisorCacheNamesCollectorTaskResult run(Void arg) { GridCacheProcessor cacheProc = ignite.context().cache(); Map<String, IgniteUuid> caches = new HashMap<>(); Set<String> groups = new HashSet<>(); for (Map.Entry<String, DynamicCacheDescriptor> item : cacheProc.cacheDescriptors().entrySet()) { DynamicCacheDescriptor cd = item.getValue(); caches.put(item.getKey(), cd.deploymentId()); String grp = cd.groupDescriptor().groupName(); if (!F.isEmpty(grp)) groups.add(grp); } return new VisorCacheNamesCollectorTaskResult(caches, groups); }
/** * @param node Node to check. * @return Public cache names accessible on the given node. */ public Map<String, CacheConfiguration> nodePublicCaches(ClusterNode node) { Map<String, CacheConfiguration> caches = U.newHashMap(registeredCaches.size()); for (DynamicCacheDescriptor cacheDesc : ctx.cache().cacheDescriptors().values()) { if (!cacheDesc.cacheType().userCache()) continue; CachePredicate p = registeredCaches.get(cacheDesc.cacheName()); if (p != null && p.cacheNode(node)) caches.put(cacheDesc.cacheName(), cacheDesc.cacheConfiguration()); } return caches; }
List<String> cachesWithoutNodes = null; for (DynamicCacheDescriptor cacheDesc : cctx.cache().cacheDescriptors().values()) { if (discoCache.cacheGroupAffinityNodes(cacheDesc.groupId()).isEmpty()) { if (cachesWithoutNodes == null)
/** */ private Set<Integer> getGroupIds() { Set<Integer> grpIds = new HashSet<>(); if (arg.getCaches() != null && !arg.getCaches().isEmpty()) { Set<String> missingCaches = new HashSet<>(); for (String cacheName : arg.getCaches()) { DynamicCacheDescriptor desc = ignite.context().cache().cacheDescriptor(cacheName); if (desc == null || !isCacheMatchFilter(cacheName)) { missingCaches.add(cacheName); continue; } grpIds.add(desc.groupId()); } handlingMissedCaches(missingCaches); } else if (onlySpecificCaches()) { for (DynamicCacheDescriptor desc : ignite.context().cache().cacheDescriptors().values()) { if (desc.cacheConfiguration().getCacheMode() != LOCAL && isCacheMatchFilter(desc.cacheName())) grpIds.add(desc.groupId()); } } else grpIds = getCacheGroupIds(); return grpIds; }
/** * Remove all persistent files for all registered caches. */ public void cleanupCachesDirectories() throws IgniteCheckedException { if (sharedCtx.pageStore() == null || sharedCtx.kernalContext().clientNode()) return; for (DynamicCacheDescriptor desc : cacheDescriptors().values()) { if (isPersistentCache(desc.cacheConfiguration(), sharedCtx.gridConfig().getDataStorageConfiguration())) sharedCtx.pageStore().cleanupPersistentSpace(desc.cacheConfiguration()); } }
/** * @param node Joining node. * @return Validation result or {@code null} in case of success. */ @Nullable private IgniteNodeValidationResult validateHashIdResolvers(ClusterNode node) { if (!node.isClient()) { for (DynamicCacheDescriptor desc : cacheDescriptors().values()) { CacheConfiguration cfg = desc.cacheConfiguration(); if (cfg.getAffinity() instanceof RendezvousAffinityFunction) { RendezvousAffinityFunction aff = (RendezvousAffinityFunction)cfg.getAffinity(); Object nodeHashObj = aff.resolveNodeHash(node); for (ClusterNode topNode : ctx.discovery().aliveServerNodes()) { Object topNodeHashObj = aff.resolveNodeHash(topNode); if (nodeHashObj.hashCode() == topNodeHashObj.hashCode()) { String errMsg = "Failed to add node to topology because it has the same hash code for " + "partitioned affinity as one of existing nodes [cacheName=" + cfg.getName() + ", existingNodeId=" + topNode.id() + ']'; String sndMsg = "Failed to add node to topology because it has the same hash code for " + "partitioned affinity as one of existing nodes [cacheName=" + cfg.getName() + ", existingNodeId=" + topNode.id() + ']'; return new IgniteNodeValidationResult(topNode.id(), errMsg, sndMsg); } } } } } return null; }
/** */ 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); }
/** * @param ig Ignite. * @param cacheNames Cache names. */ protected void checkDescriptors(IgniteEx ig, Set<String> cacheNames) { Collection<DynamicCacheDescriptor> descs = ig.context().cache().cacheDescriptors().values(); assertEquals("Node name: " + ig.name(), cacheNames.size() + 1, descs.size()); int systemCnt = 0; for (DynamicCacheDescriptor desc : descs) if (!CU.isSystemCache(desc.cacheName())) assertTrue(desc.cacheName(), cacheNames.contains(desc.cacheName())); else systemCnt++; assertEquals(1, systemCnt); }
Set<String> names = new HashSet<>(); ctx.cache().cacheDescriptors().forEach((name, desc) -> { if (change.containsKey(desc.groupId())) names.add(name);
Map<String, DynamicCacheDescriptor> descMap = k.context().cache().cacheDescriptors();
((IgniteKernal)node).context().cache().cacheGroupDescriptors(); Map<String, DynamicCacheDescriptor> caches0 = ((IgniteKernal)node).context().cache().cacheDescriptors();
QueryUtils.checkQueryEntityConflicts(ccfg, ctx.cache().cacheDescriptors().values());
caches = ctx.cache().cacheDescriptors().values();
/** * @param cacheId Cache ID. * @return Cache descriptor. */ @Nullable public DynamicCacheDescriptor cacheDescriptor(int cacheId) { for (DynamicCacheDescriptor cacheDesc : cacheDescriptors().values()) { CacheConfiguration ccfg = cacheDesc.cacheConfiguration(); assert ccfg != null : cacheDesc; if (CU.cacheId(ccfg.getName()) == cacheId) return cacheDesc; } return null; }
/** * Remove all persistent files for all registered caches. */ public void cleanupCachesDirectories() throws IgniteCheckedException { if (sharedCtx.pageStore() == null || sharedCtx.kernalContext().clientNode()) return; for (DynamicCacheDescriptor desc : cacheDescriptors().values()) { if (isPersistentCache(desc.cacheConfiguration(), sharedCtx.gridConfig().getDataStorageConfiguration())) sharedCtx.pageStore().cleanupPersistentSpace(desc.cacheConfiguration()); } }