org.apache.geode.cache.Region.subregions()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(70)

本文整理了Java中org.apache.geode.cache.Region.subregions方法的一些代码示例,展示了Region.subregions的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Region.subregions方法的具体详情如下:
包路径:org.apache.geode.cache.Region
类名称:Region
方法名:subregions

Region.subregions介绍

[英]Returns a Set of all subregions. If the recursive parameter is set to true, this call will recursively collect all subregions contained in this region. Otherwise, this call will only return the Set of direct subregions.

This Set is unmodifiable. It is backed by this region. Synchronization is not necessary to access or iterate over this set. No ConcurrentModificationExceptions will be thrown, but subregions may be added or removed while a thread is iterating. Iterators are intended to be used by one thread at a time. If a stable "snapshot" view of the set is required, then call one of the toArray methods on the set and iterate over the array.
[中]返回所有子区域的集合。如果recursive参数设置为true,则此调用将递归收集此区域中包含的所有子区域。否则,此调用将只返回直接子区域集。
这个Set是不可修改的。它得到了这个地区的支持。访问或迭代此集合不需要同步。不会抛出ConcurrentModificationExceptions,但可以在线程迭代时添加或删除子区域。迭代器一次只能由一个线程使用。如果需要一个稳定的集合“快照”视图,那么调用集合上的一个toArray方法并迭代数组。

代码示例

代码示例来源:origin: apache/geode

@Override
public Set subregions(boolean recursive) {
 return this.realRegion.subregions(recursive);
}

代码示例来源:origin: apache/geode

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

代码示例来源:origin: apache/geode

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

代码示例来源:origin: apache/geode

@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;
}

代码示例来源:origin: apache/geode

@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;
}

代码示例来源:origin: apache/geode

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;
}

代码示例来源:origin: apache/geode

@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);
 }
}

代码示例来源:origin: apache/geode

/**
 * 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;
}

代码示例来源:origin: apache/geode

/**
 * 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;
}

代码示例来源:origin: apache/geode

/**
 * 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;
}

代码示例来源:origin: apache/geode

regions.add(rootRegion);
try {
 Set subRegions = rootRegion.subregions(true); // throws RDE
 for (Iterator iter2 = subRegions.iterator(); iter2.hasNext();) {
  regions.add(iter2.next());

代码示例来源:origin: apache/geode

@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);
 }
}

代码示例来源:origin: apache/geode

/**
 * 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);
  }
 }
}

代码示例来源:origin: apache/geode

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;
 }
}

代码示例来源:origin: apache/geode

Region region = createRegion(name);
assertEquals(0, region.subregions(false).size());
 Set subregions = region.subregions(false);
 assertEquals(3, subregions.size());

代码示例来源:origin: apache/geode

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

代码示例来源:origin: apache/geode

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

代码示例来源:origin: apache/geode

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
 }
}

代码示例来源:origin: apache/geode

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())

代码示例来源:origin: apache/geode

assertTrue(attrs != subregion.getAttributes());
Set subregions = region.subregions(false);
assertEquals(1, subregions.size());
assertEquals(subregion, subregions.iterator().next());

相关文章

微信公众号

最新文章

更多