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

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

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

Region.createSubregion介绍

[英]Creates a subregion with the specified name and RegionAttributes. The name must not contain a region name separator. If the subregion is a distributed DataPolicy#withReplication region, it will be initialized with data from all other caches in this distributed system that have the same region.

Updates the CacheStatistics#getLastAccessedTime and CacheStatistics#getLastModifiedTime for this region.
[中]创建具有指定名称和RegionAttributes的子区域。名称不能包含区域名称分隔符。如果子区域是分布式DataPolicy#with replication region,则将使用此分布式系统中具有相同区域的所有其他缓存中的数据对其进行初始化。
更新此区域的CacheStatistics#getLastAccessedTime和CacheStatistics#getLastModifiedTime。

代码示例

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

public Region createSubregion(String subregionName, RegionAttributes aRegionAttributes)
  throws RegionExistsException, TimeoutException {
 return this.region.createSubregion(subregionName, aRegionAttributes);
}

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

private static Region createSubregion(final Region region) {
 Region subregion = getSubregion();
 if (subregion == null) {
  subregion = region.createSubregion(SUBREGION_NAME, region.getAttributes());
 }
 return subregion;
}

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

public static Region createRegion(Region parentRegion, String regionName, Class valueConstraint) {
 try {
  AttributesFactory attributesFactory = new AttributesFactory();
  if (valueConstraint != null)
   attributesFactory.setValueConstraint(valueConstraint);
  RegionAttributes regionAttributes = attributesFactory.create();
  return parentRegion.createSubregion(regionName, regionAttributes);
 } catch (Exception e) {
  throw new AssertionError(e);
 }
}

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

/**
 * Calls the corresponding cache APIs to create a sub-region by name 'command' in the current
 * region.
 */
public void mkrgn(String command) throws Exception {
 try {
  String name = command;
  AttributesFactory fac = new AttributesFactory(this.currRegion.getAttributes());
  Region nr = this.currRegion.createSubregion(name, fac.create());
  regionDefaultAttrMap.put(nr.getFullPath(), fac.create());
 } catch (Exception e) {
  // fail (" unable to make region..." + e.getMessage ());
  throw new Exception(" failed in mkrgn " + command);
 }
}

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

Region region = createRegion(name);
Region A = region.createSubregion("A", region.getAttributes());
Region B = region.createSubregion("B", region.getAttributes());
Region C = region.createSubregion("C", region.getAttributes());
A.createSubregion("D", region.getAttributes());
B.createSubregion("E", region.getAttributes());
C.createSubregion("F", region.getAttributes());

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

region.createSubregion("A", region.getAttributes());
region.createSubregion("B", region.getAttributes());
region.createSubregion("C", region.getAttributes());

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

@Override
 public void run2() throws CacheException {
  getLogger().fine("### Create subregion. ###");
  Region root = cache.getRegion(rootName);
  if (root == null) {
   root = cache.createRegionFactory().create(rootName);
  }
  RegionAttributes ra = null;
  if (regionAttributes == null) {
   ra = new AttributesFactory().create();
  }
  root.createSubregion(name, ra);
 }
});

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

region.put("C", "c");
Region sub = region.createSubregion("SUB", region.getAttributes());
sub.put("D", "d");
sub.put("E", "e");

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

r = parent.createSubregion(request.newRegionName, request.newRegionAttributes);
break;

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

region.createSubregion(null, region.getAttributes());
 fail("Should have thrown an IllegalArgumentException");
 region.createSubregion("TEST", null);
 fail("Should have thrown an IllegalArgumentException");
assertEquals('/', Region.SEPARATOR_CHAR);
try {
 region.createSubregion("BAD/TEST", region.getAttributes());
 fail("Should have thrown an IllegalArgumentException");
 region.createSubregion("", region.getAttributes());
 fail("Should have thrown an IllegalArgumentException");

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

region.createSubregion(name + "/BAD", attrs);
 fail("Should have thrown an IllegalArgumentException");
Region subregion = region.createSubregion(name, attrs);
assertTrue(attrs != subregion.getAttributes());

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

if (region == null) {
 AttributesFactory factory = new AttributesFactory(parentRegion.getAttributes());
 region = parentRegion.createSubregion(regionName, factory.create());
 if (logger.isDebugEnabled()) {
  logger.debug("{}: Created region {}", serverConnection.getName(), region);

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

private static void setupRegions(String regionName, String parRegionName) {
 InternalCache cache = ClusterStartupRule.getCache();
 RegionFactory regionFactory =
   cache.createRegionFactory(RegionShortcut.REPLICATE);
 Region dataRegion = regionFactory.create(DATA_REGION_NAME);
 assertNotNull(dataRegion);
 dataRegion =
   dataRegion.createSubregion(DATA_REGION_NAME_CHILD_1, dataRegion.getAttributes());
 assertNotNull(dataRegion);
 dataRegion =
   dataRegion.createSubregion(DATA_REGION_NAME_CHILD_1_2, dataRegion.getAttributes());
 assertNotNull(dataRegion);
 dataRegion = regionFactory.create(regionName);
 assertNotNull(dataRegion);
 PartitionAttributes partitionAttrs =
   new PartitionAttributesFactory().setRedundantCopies(2).create();
 RegionFactory<Object, Object> partitionRegionFactory =
   cache.createRegionFactory(RegionShortcut.PARTITION);
 partitionRegionFactory.setPartitionAttributes(partitionAttrs);
 Region dataParRegion = partitionRegionFactory.create(DATA_PAR_REGION_NAME);
 assertNotNull(dataParRegion);
 dataParRegion = partitionRegionFactory.create(parRegionName);
 assertNotNull(dataParRegion);
}

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

/**
 * Tests the {@link Region#getFullPath} method
 */
@Test
public void testGetPathFromRoot() throws CacheException {
 if (!supportsSubregions()) {
  return;
 }
 String name = this.getUniqueName();
 Region region = createRegion(name);
 String fullPath = "/root/" + name;
 assertEquals(fullPath, region.getFullPath());
 assertEquals("/root", region.getParentRegion().getFullPath());
 Region sub = region.createSubregion("SUB", region.getAttributes());
 assertEquals(fullPath + "/SUB", sub.getFullPath());
}

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

public final <K, V> Region<K, V> createRegion(final String name, final String rootName,
  final RegionAttributes<K, V> attributes) throws CacheException {
 Region<K, V> root = getRootRegion(rootName);
 if (root == null) {
  // don't put listeners on root region
  AttributesFactory<K, V> attributesFactory = new AttributesFactory<>(attributes);
  ExpirationAttributes expiration = ExpirationAttributes.DEFAULT;
  attributesFactory.setCacheLoader(null);
  attributesFactory.setCacheWriter(null);
  attributesFactory.setPoolName(null);
  attributesFactory.setPartitionAttributes(null);
  attributesFactory.setRegionTimeToLive(expiration);
  attributesFactory.setEntryTimeToLive(expiration);
  attributesFactory.setRegionIdleTimeout(expiration);
  attributesFactory.setEntryIdleTimeout(expiration);
  RegionAttributes<K, V> rootAttrs = attributesFactory.create();
  root = createRootRegion(rootName, rootAttrs);
 }
 return root.createSubregion(name, attributes);
}

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

me = parent.createSubregion(this.name, new AttributesFactory(this.attrs).create());
} catch (RegionExistsException ex) {
 me = ex.getRegion();

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

/**
 * Tests the {@link Region#getParentRegion} method
 */
@Test
public void testGetParentRegion() throws CacheException {
 if (!supportsSubregions()) {
  return;
 }
 String name = this.getUniqueName();
 Region region = createRegion(name);
 assertEquals(getRootRegion(), region.getParentRegion());
 Region sub = region.createSubregion("SUB", region.getAttributes());
 assertEquals(region, sub.getParentRegion());
 assertSame(sub, region.getSubregion("SUB"));
 assertNotNull(sub.getAttributes());
}

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

public static void main(String[] args) throws Exception {
 Region currRegion;
 Cache cache = null;
 // DistributedSystem system = null;
 // HashMap regionDefaultAttrMap = new HashMap();
 tableName = CacheUtils.init("TestXACache");
 cache = CacheUtils.getCache();
 currRegion = cache.getRegion("root");
 try {
  Context ctx = cache.getJNDIContext();
  UserTransaction utx = (UserTransaction) ctx.lookup("java:/UserTransaction");
  utx.begin();
  AttributesFactory fac = new AttributesFactory(currRegion.getAttributes());
  fac.setCacheLoader(new TestXACacheLoader());
  Region re = currRegion.createSubregion("employee", fac.create());
  System.out.println(re.get(args[0]));
  utx.rollback();
  System.out.println(re.get(args[0]));
  cache.close();
  ExitCode.FATAL.doSystemExit();
 } catch (Exception e) {
  e.printStackTrace();
  cache.close();
 }
}

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

newRegion = parentRegion.createSubregion(newRegionName, newRegionAttributes);
 this.cache.getLogger().fine("Created dynamic region " + newRegion);
} catch (RegionExistsException ex) {

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

entry = region.getEntry(key);
 assertEquals(value, entry.getValue());
 sub = region.createSubregion(subname, subRegAttrs);
} finally {
 System.getProperties().remove(LocalRegion.EXPIRY_MS_PROPERTY);

相关文章

微信公众号

最新文章

更多