public static Set<String> getAllRegionNames(Cache cache) { Set<String> regionNames = new HashSet<>(); Set<Region<?, ?>> rootRegions = cache.rootRegions(); for (Region<?, ?> rootRegion : rootRegions) { regionNames.add(rootRegion.getFullPath().substring(1)); Set<Region<?, ?>> subRegions = rootRegion.subregions(true); for (Region<?, ?> subRegion : subRegions) { regionNames.add(subRegion.getFullPath().substring(1)); } } return regionNames; }
protected static final void destroyRegions(final Cache cache) { if (cache != null && !cache.isClosed()) { // try to destroy the root regions first so that we clean up any persistent files. for (Region<?, ?> root : cache.rootRegions()) { String regionFullPath = root == null ? null : root.getFullPath(); // for colocated regions you can't locally destroy a partitioned region. if (root.isDestroyed() || root instanceof HARegion || root instanceof PartitionedRegion) { continue; } try { root.localDestroyRegion("teardown"); } catch (Throwable t) { logger.error("Failure during tearDown destroyRegions for " + regionFullPath, t); } } } }
Set rootRegions = cache.rootRegions();
@Override public void execute(FunctionContext context) { ArrayList<String> vals = new ArrayList<String>(); Cache c = null; try { c = CacheFactory.getAnyInstance(); } catch (CacheClosedException ex) { vals.add("NoCacheResult"); context.getResultSender().lastResult(vals); } final Set<Region<?, ?>> regionSet = c.rootRegions(); for (Region<?, ?> r : regionSet) { vals.add(r.getName()); } context.getResultSender().lastResult(vals); }
protected void initializeRegionSizes() { Iterator rootRegions = cache.rootRegions().iterator(); while (rootRegions.hasNext()) { LocalRegion rootRegion = (LocalRegion) rootRegions.next(); if (!(rootRegion instanceof HARegion)) { RegionStatus rootRegionStatus = rootRegion instanceof PartitionedRegion ? new PartitionedRegionStatus((PartitionedRegion) rootRegion) : new RegionStatus(rootRegion); putRegionStatus(rootRegion.getFullPath(), rootRegionStatus); Iterator subRegions = rootRegion.subregions(true).iterator(); while (subRegions.hasNext()) { LocalRegion subRegion = (LocalRegion) subRegions.next(); RegionStatus subRegionStatus = subRegion instanceof PartitionedRegion ? new PartitionedRegionStatus((PartitionedRegion) subRegion) : new RegionStatus(subRegion); putRegionStatus(subRegion.getFullPath(), subRegionStatus); } } } } }
@Override public void execute(FunctionContext functionContext) { try { Cache cache = functionContext.getCache(); Set<Region<?, ?>> regions = cache.rootRegions(); // should never return a null if (regions == null || regions.isEmpty()) { functionContext.getResultSender().lastResult(null); } else { Set<RegionInformation> regionInformationSet = new HashSet<>(); for (Region<?, ?> region : regions) { RegionInformation regInfo = new RegionInformation(region, true); regionInformationSet.add(regInfo); } functionContext.getResultSender().lastResult(regionInformationSet.toArray()); } } catch (Exception e) { functionContext.getResultSender().sendException(e); } } }
private static void destroyRegions(final Cache cache) { if (cache != null && !cache.isClosed()) { // try to destroy the root regions first so that we clean up any persistent files. for (Region<?, ?> root : cache.rootRegions()) { String regionFullPath = root == null ? null : root.getFullPath(); // for colocated regions you can't locally destroy a partitioned region. if (root.isDestroyed() || root instanceof HARegion || root instanceof PartitionedRegion) { continue; } try { root.localDestroyRegion("CacheRule_tearDown"); } catch (Exception ignore) { } } } }
rSet.addAll(this.cache.rootRegions()); Iterator it = rSet.iterator(); while (it.hasNext()) {
Collection<Region<?, ?>> otherRoots = other.rootRegions(); if (myRoots.size() != otherRoots.size()) { throw new RuntimeException("roots size");
} else { TreeSet rSet = new TreeSet(new RegionComparator()); rSet.addAll(this.cache.rootRegions()); Iterator it = rSet.iterator(); while (it.hasNext()) {
for (Region root : cache.rootRegions()) { if (root.isDestroyed() || root instanceof HARegion) { continue;
@Override public void execute(FunctionContext functionContext) { List<String> regionNames = new ArrayList<String>(); for (Region<?, ?> region : getCache().rootRegions()) { regionNames.add(region.getName()); } functionContext.getResultSender().lastResult(regionNames); }
@Override public void execute(FunctionContext functionContext) { List<String> regionNames = new ArrayList<String>(); for (Region<?, ?> region : getCache().rootRegions()) { regionNames.add(region.getName()); } functionContext.getResultSender().lastResult(regionNames); }