org.apache.geode.cache.RegionAttributes类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(16.1k)|赞(0)|评价(0)|浏览(96)

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

RegionAttributes介绍

[英]Defines attributes for configuring a region. These are EvictionAttributes, CacheListener, CacheLoader, CacheWriter, scope, data policy, and expiration attributes for the region itself, expiration attributes for the region entries, and whether statistics are enabled for the region and its entries. To create an instance of this interface use AttributesFactory#createRegionAttributes. For compatibility rules and default values, see AttributesFactory.

Note that the RegionAttributes are not distributed with the region.
[中]定义用于配置区域的属性。这些是EvictionAttributesCacheListenerCacheLoaderCacheWriter、范围、数据策略和区域本身的过期属性、区域条目的过期属性,以及是否为区域及其条目启用了统计信息。要创建此接口的实例,请使用AttributesFactory#CreateRegionatAttributes。有关兼容性规则和默认值,请参阅AttributesFactory。
请注意,RegionAttributes不随地区一起分发。

代码示例

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

this.cacheListeners = new ArrayList(Arrays.asList(attrs.getCacheListeners()));
this.gatewaySenderIds = new HashSet<String>(attrs.getGatewaySenderIds());
this.asyncEventQueueIds = new HashSet<String>(attrs.getAsyncEventQueueIds());
this.cacheLoader = attrs.getCacheLoader();
this.cacheWriter = attrs.getCacheWriter();
this.entryIdleTimeout = attrs.getEntryIdleTimeout();
this.customEntryIdleTimeout = attrs.getCustomEntryIdleTimeout();
this.entryTimeToLive = attrs.getEntryTimeToLive();
this.customEntryTimeToLive = attrs.getCustomEntryTimeToLive();
this.initialCapacity = attrs.getInitialCapacity();
this.keyConstraint = attrs.getKeyConstraint();
this.valueConstraint = attrs.getValueConstraint();
this.loadFactor = attrs.getLoadFactor();
this.regionIdleTimeout = attrs.getRegionIdleTimeout();
this.regionTimeToLive = attrs.getRegionTimeToLive();
this.scope = attrs.getScope();
this.statisticsEnabled = attrs.getStatisticsEnabled();
this.ignoreJTA = attrs.getIgnoreJTA();
this.concurrencyLevel = attrs.getConcurrencyLevel();
this.concurrencyChecksEnabled = attrs.getConcurrencyChecksEnabled();
this.earlyAck = attrs.getEarlyAck();
this.diskStoreName = attrs.getDiskStoreName();
if (this.diskStoreName == null) {
 this.diskWriteAttributes = attrs.getDiskWriteAttributes();
 this.diskDirs = attrs.getDiskDirs();
 this.diskSizes = attrs.getDiskDirSizes();
} else {
 this.diskWriteAttributes = null;

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

if (regAttrs.getCacheLoader() != null) {
 cacheLoaderClassName = regAttrs.getCacheLoader().getClass().getCanonicalName();
if (regAttrs.getCacheWriter() != null) {
 cacheWriteClassName = regAttrs.getCacheWriter().getClass().getCanonicalName();
if (regAttrs.getKeyConstraint() != null) {
 keyConstraintClassName = regAttrs.getKeyConstraint().getName();
if (regAttrs.getValueConstraint() != null) {
 valueContstraintClassName = regAttrs.getValueConstraint().getName();
CacheListener[] listeners = regAttrs.getCacheListeners();
int regionTimeToLive = regAttrs.getRegionTimeToLive().getTimeout();
int regionIdleTimeout = regAttrs.getRegionIdleTimeout().getTimeout();
int entryTimeToLive = regAttrs.getEntryTimeToLive().getTimeout();
int entryIdleTimeout = regAttrs.getEntryIdleTimeout().getTimeout();
Object o1 = regAttrs.getCustomEntryTimeToLive();
if (o1 != null) {
 customEntryTimeToLive = o1.toString();
Object o2 = regAttrs.getCustomEntryIdleTimeout();
if (o2 != null) {
 customEntryIdleTimeout = o2.toString();
boolean ignoreJTA = regAttrs.getIgnoreJTA();
String dataPolicy = regAttrs.getDataPolicy().toString();

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

protected static boolean isLocalAccessor(CacheDistributionAdvisee region) {
 if (!region.getAttributes().getDataPolicy().withStorage()) {
  return true;
 }
 if (region.getAttributes().getPartitionAttributes() != null
   && region.getAttributes().getPartitionAttributes().getLocalMaxMemory() == 0) {
  return true;
 }
 return false;
}

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

AttributesFactory factory = new AttributesFactory();
RegionAttributes attrs = factory.create();
assertNull(attrs.getCacheLoader());
assertNull(attrs.getCacheWriter());
assertNull(attrs.getCacheListener());
assertEquals(Arrays.asList(new CacheListener[0]), Arrays.asList(attrs.getCacheListeners()));
assertEquals(0, attrs.getRegionTimeToLive().getTimeout());
assertEquals(0, attrs.getRegionIdleTimeout().getTimeout());
assertEquals(0, attrs.getEntryTimeToLive().getTimeout());
assertEquals(null, attrs.getCustomEntryTimeToLive());
assertEquals(0, attrs.getEntryIdleTimeout().getTimeout());
assertEquals(null, attrs.getCustomEntryIdleTimeout());
assertEquals(Scope.DISTRIBUTED_NO_ACK, attrs.getScope());
assertEquals(DataPolicy.DEFAULT, attrs.getDataPolicy());
assertEquals(InterestPolicy.DEFAULT, attrs.getSubscriptionAttributes().getInterestPolicy());
assertEquals(MirrorType.NONE, attrs.getMirrorType());
assertEquals(null, attrs.getDiskStoreName());
assertEquals(AttributesFactory.DEFAULT_DISK_SYNCHRONOUS, attrs.isDiskSynchronous());
assertNull(attrs.getKeyConstraint());
assertEquals(16, attrs.getInitialCapacity());
assertEquals(0.75, attrs.getLoadFactor(), 0.0);
assertFalse(attrs.getStatisticsEnabled());
assertFalse(attrs.getPersistBackup());
DiskWriteAttributes dwa = attrs.getDiskWriteAttributes();
assertNotNull(dwa);
assertNull(attrs.getDiskStoreName());
File[] diskDirs = attrs.getDiskDirs();
assertNotNull(diskDirs);

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

CacheListener listener = ra.getCacheListener();
if (listener != null) {
 allListeners.add(listener.toString());
CacheWriter writer = ra.getCacheWriter();
if (writer != null) {
 allCacheWriters.add(writer.toString());
CacheLoader loader = ra.getCacheLoader();
if (loader != null) {
 allCacheLoaders.add(loader);
allDataPolicies.add(ra.getDataPolicy());
allRegionTtl.add(ra.getRegionTimeToLive());
allEntryTtl.add(ra.getEntryTimeToLive());
allCustomTtl.add(ra.getCustomEntryTimeToLive().toString());
allRegionIdleTimeout.add(ra.getRegionIdleTimeout());
allEntryIdleTimeout.add(ra.getEntryIdleTimeout());
allCustomIdle.add(ra.getCustomEntryIdleTimeout().toString());
allScopes.add(ra.getScope());
allLoadFactors.add(new Float(ra.getLoadFactor()));
allInitialCaps.add(Integer.valueOf(ra.getInitialCapacity()));
allConcLevels.add(Integer.valueOf(ra.getConcurrencyLevel()));
allStatsEnabled.add(Boolean.valueOf(ra.getStatisticsEnabled()));
allUserAttributes.add(snap.getUserAttribute());
allKeyConstraints.add(ra.getKeyConstraint());
allValueConstraints.add(ra.getValueConstraint());

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

operation = mock(Operation.class);
when(regionAttributes.getEvictionAttributes()).thenReturn(evictionAttributes);
when(regionAttributes.getRegionTimeToLive()).thenReturn(expirationAttributes);
when(regionAttributes.getRegionIdleTimeout()).thenReturn(expirationAttributes);
when(regionAttributes.getEntryTimeToLive()).thenReturn(expirationAttributes);
when(regionAttributes.getEntryIdleTimeout()).thenReturn(expirationAttributes);
when(regionAttributes.getDataPolicy()).thenReturn(dataPolicy);
when(regionAttributes.getDiskStoreName()).thenReturn("store");
when(regionAttributes.getConcurrencyLevel()).thenReturn(16);
when(regionAttributes.getLoadFactor()).thenReturn(0.75f);
when(regionAttributes.getMembershipAttributes()).thenReturn(membershipAttributes);
when(regionAttributes.getScope()).thenReturn(scope);
when(partitionedRegion.getFullPath()).thenReturn("parent");
when(internalRegionArgs.getPartitionedRegion()).thenReturn(partitionedRegion);

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

public DataPolicy getDataPolicy() {
 if (this.event != null) {
  return this.event.getRegion().getAttributes().getDataPolicy();
 }
 return null;
}

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

@Test
public void testIsRegionUsingDiskStoreWhenDiskStoresMismatch() {
 final Region mockRegion = mock(Region.class, "Region");
 final DiskStore mockDiskStore = mock(DiskStore.class, "DiskStore");
 final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes");
 when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes);
 when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_PARTITION);
 when(mockRegionAttributes.getDiskStoreName()).thenReturn("mockDiskStore");
 when(mockDiskStore.getName()).thenReturn("testDiskStore");
 final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction();
 assertThat(function.isUsingDiskStore(mockRegion, mockDiskStore)).isFalse();
}

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

private PartitionAttributes initializeAttributes(final Cache cache) {
 PartitionAttributes partitionAttributes = mock(PartitionAttributes.class);
 RegionAttributes attributes = mock(RegionAttributes.class);
 when(attributes.getCacheListeners()).thenReturn(new CacheListener[0]);
 when(attributes.getRegionTimeToLive()).thenReturn(ExpirationAttributes.DEFAULT);
 when(attributes.getRegionIdleTimeout()).thenReturn(ExpirationAttributes.DEFAULT);
 when(attributes.getEntryTimeToLive()).thenReturn(ExpirationAttributes.DEFAULT);
 when(attributes.getEntryIdleTimeout()).thenReturn(ExpirationAttributes.DEFAULT);
 when(attributes.getMembershipAttributes()).thenReturn(new MembershipAttributes());
 when(cache.getRegionAttributes(RegionShortcut.PARTITION.toString())).thenReturn(attributes);
 when(partitionAttributes.getTotalNumBuckets()).thenReturn(113);
 return partitionAttributes;
}

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

@Test
public void processReturnsCacheRegions() throws Exception {
 RegionAttributes regionAttributesStub = mock(RegionAttributes.class);
 when(cacheStub.getRegion(TEST_REGION1)).thenReturn(region1Stub);
 when(region1Stub.getName()).thenReturn(TEST_REGION1);
 when(region1Stub.size()).thenReturn(10);
 when(region1Stub.getAttributes()).thenReturn(regionAttributesStub);
 when(regionAttributesStub.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_REPLICATE);
 when(regionAttributesStub.getKeyConstraint()).thenReturn(String.class);
 when(regionAttributesStub.getValueConstraint()).thenReturn(Integer.class);
 when(regionAttributesStub.getScope()).thenReturn(Scope.DISTRIBUTED_ACK);
 Result result = operationHandler.process(serializationService,
   MessageUtil.makeGetSizeRequest(TEST_REGION1), getNoAuthCacheExecutionContext(cacheStub));
 RegionAPI.GetSizeResponse response = (RegionAPI.GetSizeResponse) result.getMessage();
 Assert.assertEquals(10, response.getSize());
}

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

protected void checkVersionTag(DistributedRegion rgn, VersionTag tag) {
 RegionAttributes attr = rgn.getAttributes();
 if (attr.getConcurrencyChecksEnabled() && attr.getDataPolicy().withPersistence()
   && attr.getScope() != Scope.GLOBAL
   && (tag.getMemberID() == null || test_InvalidVersion)) {
  if (logger.isDebugEnabled()) {
   logger.debug("Version tag is missing the memberID: {}", tag);
  }
  String msg =
    String.format("memberID cannot be null for persistent regions: %s", tag);
  RuntimeException ex = (sender.getVersionObject().compareTo(Version.GFE_80) < 0)
    ? new InternalGemFireException(msg) : new InvalidVersionException(msg);
  throw ex;
 }
}

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

@Test
public void testIsRegionUsingDiskStoreWhenOverflowing() {
 final String diskStoreName = "testDiskStore";
 final Region mockRegion = mock(Region.class, "Region");
 final DiskStore mockDiskStore = mock(DiskStore.class, "DiskStore");
 final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes");
 final EvictionAttributes mockEvictionAttributes =
   mock(EvictionAttributes.class, "EvictionAttributes");
 when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes);
 when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.PARTITION);
 when(mockRegionAttributes.getDiskStoreName()).thenReturn(diskStoreName);
 when(mockRegionAttributes.getEvictionAttributes()).thenReturn(mockEvictionAttributes);
 when(mockEvictionAttributes.getAction()).thenReturn(EvictionAction.OVERFLOW_TO_DISK);
 when(mockDiskStore.getName()).thenReturn(diskStoreName);
 final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction();
 assertThat(function.isUsingDiskStore(mockRegion, mockDiskStore)).isTrue();
 verify(mockRegion, times(4)).getAttributes();
 verify(mockRegionAttributes, times(2)).getEvictionAttributes();
}

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

private AsyncEventQueueFactoryImpl createAEQFactory(final RegionAttributes attributes) {
 AsyncEventQueueFactoryImpl factory =
   (AsyncEventQueueFactoryImpl) cache.createAsyncEventQueueFactory();
 if (attributes.getPartitionAttributes() != null) {
  factory.setParallel(true); // parallel AEQ for PR
 } else {
  factory.setParallel(false); // TODO: not sure if serial AEQ working or not
 }
 factory.setMaximumQueueMemory(1000);
 factory.setDispatcherThreads(10);
 factory.setBatchSize(1000);
 factory.setIsMetaQueue(true);
 if (attributes.getDataPolicy().withPersistence()) {
  factory.setPersistent(true);
 }
 factory.setDiskStoreName(attributes.getDiskStoreName());
 factory.setDiskSynchronous(true);
 factory.setForwardExpirationDestroy(true);
 return factory;
}

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

static void validateRegionAttributes(RegionAttributes attrs) {
 if (!attrs.getDataPolicy().withPartitioning()) {
  // replicated region
  throw new UnsupportedOperationException(
    "Lucene indexes on replicated regions are not supported");
 }
 // For now we cannot support eviction with local destroy.
 // Eviction with overflow to disk still needs to be supported
 EvictionAttributes evictionAttributes = attrs.getEvictionAttributes();
 EvictionAlgorithm evictionAlgorithm = evictionAttributes.getAlgorithm();
 if (evictionAlgorithm != EvictionAlgorithm.NONE
   && evictionAttributes.getAction().isLocalDestroy()) {
  throw new UnsupportedOperationException(
    "Lucene indexes on regions with eviction and action local destroy are not supported");
 }
}

代码示例来源: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

if (!attr.getDataPolicy().withReplication() || attr.getConcurrencyChecksEnabled()) {
 events = TxEventTestUtil.getPutEvents(tl.lastEvent.getEvents());
} else {

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

private void validateExpirationAttributes(final RegionAttributes userRA,
  final PartitionRegionConfig prconf) {
 if (!userRA.getRegionIdleTimeout().equals(prconf.getRegionIdleTimeout())) {
  throw new IllegalStateException(
    String.format(
      "The %1$s set in RegionAttributes is incompatible with %1$s used by other distributed members.",
      new Object[] {" region idle timout "}));
 }
 if (!userRA.getRegionTimeToLive().equals(prconf.getRegionTimeToLive())) {
  throw new IllegalStateException(
    String.format(
      "The %1$s set in RegionAttributes is incompatible with %1$s used by other distributed members.",
      new Object[] {" region time to live "}));
 }
 if (!userRA.getEntryIdleTimeout().equals(prconf.getEntryIdleTimeout())) {
  throw new IllegalStateException(
    String.format(
      "The %1$s set in RegionAttributes is incompatible with %1$s used by other distributed members.",
      new Object[] {" entry idle timout "}));
 }
 if (!userRA.getEntryTimeToLive().equals(prconf.getEntryTimeToLive())) {
  throw new IllegalStateException(
    String.format(
      "The %1$s set in RegionAttributes is incompatible with %1$s used by other distributed members.",
      new Object[] {" entry time to live "}));
 }
}

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

public BucketRegion(String regionName, RegionAttributes attrs, LocalRegion parentRegion,
  InternalCache cache, InternalRegionArguments internalRegionArgs) {
 super(regionName, attrs, parentRegion, cache, internalRegionArgs);
 if (PartitionedRegion.DISABLE_SECONDARY_BUCKET_ACK) {
  Assert.assertTrue(attrs.getScope().isDistributedNoAck());
 } else {
  Assert.assertTrue(attrs.getScope().isDistributedAck());
 }
 Assert.assertTrue(attrs.getDataPolicy().withReplication());
 Assert.assertTrue(!attrs.getEarlyAck());
 Assert.assertTrue(isUsedForPartitionedRegionBucket());
 Assert.assertTrue(!isUsedForPartitionedRegionAdmin());
 Assert.assertTrue(internalRegionArgs.getBucketAdvisor() != null);
 Assert.assertTrue(internalRegionArgs.getPartitionedRegion() != null);
 this.redundancy = internalRegionArgs.getPartitionedRegionBucketRedundancy();
 this.partitionedRegion = internalRegionArgs.getPartitionedRegion();
 setEventSeqNum();
}

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

@Override
public EvictionAttributes getEvictionAttributes() {
 return this.ra.getEvictionAttributes();
}

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

@Override
public PartitionAttributes getPartitionAttributes() {
 return this.ra.getPartitionAttributes();
}

相关文章

微信公众号

最新文章

更多

RegionAttributes类方法