@Override public Set subregions(boolean recursive) { return this.realRegion.subregions(recursive); }
public String[] listSubRegionPaths(boolean recursive) { SortedSet<String> subregionPaths = new TreeSet<String>(); Set<Region<?, ?>> subregions = region.subregions(recursive); for (Region<?, ?> region : subregions) { subregionPaths.add(region.getFullPath()); } return subregionPaths.toArray(new String[subregionPaths.size()]); }
public void calcSize(Region r) { if (cancelled) { return; } Set nameSet = r.keySet(); if (cancelled) { return; } this.entryCount = nameSet.size(); Set subRegions = r.subregions(false); if (cancelled) { return; } this.subregionCount = subRegions.size(); }
@Override public Collection<String> getRegionNames() { security.authorize(DATA, READ, ALL, ALL); Set<String> regionNames = new HashSet<>(); cache.rootRegions().forEach(region -> { regionNames.add(region.getFullPath()); region.subregions(true).stream().map(Region::getFullPath).forEach(regionNames::add); }); return regionNames; }
@Override public Collection getIndexes() { ArrayList allIndexes = new ArrayList(); Iterator rootRegions = cache.rootRegions().iterator(); while (rootRegions.hasNext()) { Region region = (Region) rootRegions.next(); allIndexes.addAll(getIndexes(region)); Iterator subRegions = region.subregions(true).iterator(); while (subRegions.hasNext()) { allIndexes.addAll(getIndexes((Region) subRegions.next())); } } return allIndexes; }
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; }
@Override public void removeIndexes() { if (pool != null) { throw new UnsupportedOperationException( "Index Operation is not supported on the Server Region."); } Iterator rootRegions = cache.rootRegions().iterator(); while (rootRegions.hasNext()) { Region region = (Region) rootRegions.next(); Iterator subRegions = region.subregions(true).iterator(); while (subRegions.hasNext()) { removeIndexes((Region) subRegions.next()); } removeIndexes(region); } }
/** * Returns a possibly empty list that contains all the Chunks used by regions. */ private List<OffHeapStoredObject> getRegionLiveChunks(InternalCache cache) { ArrayList<OffHeapStoredObject> result = new ArrayList<OffHeapStoredObject>(); if (cache != null) { Iterator<Region<?, ?>> rootIt = cache.rootRegions().iterator(); while (rootIt.hasNext()) { Region<?, ?> rr = rootIt.next(); getRegionLiveChunks(rr, result); Iterator<Region<?, ?>> srIt = rr.subregions(true).iterator(); while (srIt.hasNext()) { getRegionLiveChunks(srIt.next(), result); } } } return result; }
/** * Returns a <code>SubRegionResponse</code> that will be returned to the specified recipient. The * message will contains a copy of the local manager's system config. */ public static SubRegionResponse create(DistributionManager dm, InternalDistributedMember recipient, Region r) { SubRegionResponse m = new SubRegionResponse(); m.setRecipient(recipient); Set subregions = r.subregions(false); List subNames = new ArrayList(); List userAttrs = new ArrayList(); Iterator it = subregions.iterator(); while (it.hasNext()) { Region reg = (Region) it.next(); subNames.add(reg.getName()); userAttrs.add(CacheDisplay.getCachedObjectDisplay(reg.getUserAttribute(), GemFireVM.LIGHTWEIGHT_CACHE_VALUE)); } String[] temp = new String[0]; m.subRegionNames = (String[]) subNames.toArray(temp); m.userAttributes = (String[]) userAttrs.toArray(temp); return m; }
/** * Returns a sorted list of all region full paths found in the specified cache. * * @param cache The cache to search. * @param recursive recursive search for sub-regions * @return Returns a sorted list of all region paths defined in the distributed system. */ @SuppressWarnings({"rawtypes", "unchecked"}) public static List getAllRegionPaths(InternalCache cache, boolean recursive) { ArrayList list = new ArrayList(); if (cache == null) { return list; } // get a list of all root regions Set<Region<?, ?>> regions = cache.rootRegions(); for (Region rootRegion : regions) { String regionPath = rootRegion.getFullPath(); Region region = cache.getRegion(regionPath); list.add(regionPath); Set<Region> subregionSet = region.subregions(true); if (recursive) { for (Region aSubregionSet : subregionSet) { list.add(aSubregionSet.getFullPath()); } } } Collections.sort(list); return list; }
regions.add(rootRegion); try { Set subRegions = rootRegion.subregions(true); // throws RDE for (Iterator iter2 = subRegions.iterator(); iter2.hasNext();) { regions.add(iter2.next());
@Override public void save(File dir, SnapshotFormat format, SnapshotOptions<Object, Object> options) throws IOException { createDirectoryIfNeeded(dir); for (Region<?, ?> region : cache.rootRegions()) { for (Region<?, ?> subRegion : region.subregions(true)) { saveRegion(subRegion, dir, format, options); } saveRegion(region, dir, format, options); } }
/** * Populates the collection of sub-region snapshots for the parentSnapShot with snapshots for the * regions given. * * @param parentSnapShot RegionSubRegionSnapshot of a parent region * @param regions collection of sub-regions of the region represented by parentSnapShot * @param cache cache instance is used for to get the LogWriter instance to log exceptions if any */ private void populateRegionSubRegions(RegionSubRegionSnapshot parentSnapShot, Set regions, InternalCache cache) { if (this.cancelled) { return; } for (Object region : regions) { Region subRegion = (Region) region; try { RegionSubRegionSnapshot subRegionSnapShot = new RegionSubRegionSnapshot(subRegion); parentSnapShot.addSubRegion(subRegionSnapShot); Set subRegions = subRegion.subregions(false); populateRegionSubRegions(subRegionSnapShot, subRegions, cache); } catch (Exception e) { logger.debug("Failed to create snapshot for region: {}. Continuing with next region.", subRegion.getFullPath(), e); } } }
public RemoteRegionSnapshot(Region r) throws CacheException { this.name = r.getName(); RegionAttributes rAttr = r.getAttributes(); this.attributes = new RemoteRegionAttributes(rAttr); if (rAttr.getStatisticsEnabled()) { this.stats = new RemoteCacheStatistics(r.getStatistics()); } else { this.stats = new RemoteCacheStatistics(); } this.attributes = new RemoteRegionAttributes(r.getAttributes()); Set nameSet = r.keySet(); this.entryCount = nameSet.size(); Set subRegions = r.subregions(false); this.subregionCount = subRegions.size(); Object attr = r.getUserAttribute(); if (attr != null) { this.userAttribute = attr.getClass().getName() + "\"" + attr.toString() + "\""; } else { this.userAttribute = null; } }
Region region = createRegion(name); assertEquals(0, region.subregions(false).size()); Set subregions = region.subregions(false); assertEquals(3, subregions.size());
@Test public void getRegionNames() { authorize(DATA, READ, ALL, ALL); Set<Region<?, ?>> regions = new HashSet<>(); regions.add(region); when(cache.rootRegions()).thenReturn(regions); Set subregions = new HashSet<>(); Region region2 = mock(Region.class); subregions.add(region2); Region region3 = mock(Region.class); subregions.add(region3); when(region.getFullPath()).thenReturn("region1"); when(region2.getFullPath()).thenReturn("region2"); when(region3.getFullPath()).thenReturn("region3"); when(region.subregions(true)).thenReturn(subregions); Collection<String> regionNames = authorizingCache.getRegionNames(); assertThat(regionNames).containsExactly("region1", "region2", "region3"); verify(cache).rootRegions(); }
public RegionInformation(Region<?, ?> region, boolean recursive) { this.name = region.getFullPath().substring(1); this.path = region.getFullPath().substring(1); this.scope = region.getAttributes().getScope(); this.dataPolicy = region.getAttributes().getDataPolicy(); if (region.getParentRegion() == null) { this.isRoot = true; if (recursive) { Set<Region<?, ?>> subRegions = region.subregions(recursive); subRegionInformationSet = getSubRegions(subRegions); } } else { this.isRoot = false; this.parentRegion = region.getParentRegion().getFullPath(); } }
private void setRegionDetails(final Region<?, ?> region, final DiskStore diskStore, final DiskStoreDetails diskStoreDetails) { if (isUsingDiskStore(region, diskStore)) { String regionFullPath = region.getFullPath(); DiskStoreDetails.RegionDetails regionDetails = new DiskStoreDetails.RegionDetails( regionFullPath, StringUtils.defaultIfBlank(region.getName(), regionFullPath)); regionDetails.setOverflowToDisk(isOverflowToDisk(region)); regionDetails.setPersistent(isPersistent(region)); diskStoreDetails.add(regionDetails); } for (Region<?, ?> subregion : region.subregions(false)) { setRegionDetails(subregion, diskStore, diskStoreDetails); // depth-first, recursive strategy } }
when(mockUserRegion.getFullPath()).thenReturn("/UserRegion"); when(mockUserRegion.getName()).thenReturn("UserRegion"); when(mockUserRegion.subregions(false)).thenReturn(CollectionUtils.asSet(mockSessionRegion)); when(mockUserRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_PARTITION); when(mockUserRegionAttributes.getDiskStoreName()).thenReturn(diskStoreName); when(mockSessionRegion.getFullPath()).thenReturn("/UserRegion/SessionRegion"); when(mockSessionRegion.getName()).thenReturn("SessionRegion"); when(mockSessionRegion.subregions(false)).thenReturn(Collections.emptySet()); when(mockSessionRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); when(mockSessionRegionAttributes.getDiskStoreName()).thenReturn(diskStoreName); when(mockSessionEvictionAttributes.getAction()).thenReturn(EvictionAction.OVERFLOW_TO_DISK); when(mockGuestRegion.getAttributes()).thenReturn(mockGuestRegionAttributes); when(mockGuestRegion.subregions(false)).thenReturn(Collections.emptySet()); when(mockGuestRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); when(mockGuestRegionAttributes.getDiskStoreName())
assertTrue(attrs != subregion.getAttributes()); Set subregions = region.subregions(false); assertEquals(1, subregions.size()); assertEquals(subregion, subregions.iterator().next());