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

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

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

RegionAttributes.getKeyConstraint介绍

[英]Returns the class that the keys in this region are constrained to.
[中]返回此区域中的键约束到的类。

代码示例

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

@Override
public String getKeyConstraint() {
 Class constraint = this.ra.getKeyConstraint();
 if (constraint == null) {
  return "";
 } else {
  return constraint.getName();
 }
}

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

protected ObjectType getKeyType() {
 Class constraint = this.region.getAttributes().getKeyConstraint();
 if (constraint == null) {
  constraint = Object.class;
 }
 return TypeUtils.getObjectType(constraint);
}

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

allStatsEnabled.add(Boolean.valueOf(ra.getStatisticsEnabled()));
allUserAttributes.add(snap.getUserAttribute());
allKeyConstraints.add(ra.getKeyConstraint());
allValueConstraints.add(ra.getValueConstraint());

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

"initial Capacity is not the same");
if (!equal(this.keyConstraint, other.getKeyConstraint())) {
 throw new RuntimeException(
   "Key Constraints are not the same");

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

if (regAttrs.getKeyConstraint() != null) {
 keyConstraintClassName = regAttrs.getKeyConstraint().getName();

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

generate(attrs.getKeyConstraint(), KEY_CONSTRAINT);

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

public DummyQRegion(Region region) {
 super(region, false);
 Class constraint = region.getAttributes().getValueConstraint();
 if (constraint != null)
  valueType = TypeUtils.getObjectType(constraint);
 constraint = region.getAttributes().getKeyConstraint();
 if (constraint != null)
  keyType = TypeUtils.getObjectType(constraint);
 values = new ResultsBag(((HasCachePerfStats) region.getCache()).getCachePerfStats());
 values.setElementType(valueType);
 keys = new ResultsSet();
 keys.setElementType(keyType);
 entries = new ResultsSet();
 // gets key and value types from region
 entries.setElementType(TypeUtils.getRegionEntryType(region));
}

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

this.customEntryTimeToLive = attrs.getCustomEntryTimeToLive();
this.initialCapacity = attrs.getInitialCapacity();
this.keyConstraint = attrs.getKeyConstraint();
this.valueConstraint = attrs.getValueConstraint();
this.loadFactor = attrs.getLoadFactor();

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

this.ignoreJTA = attrs.getIgnoreJTA();
this.isLockGrantor = attrs.isLockGrantor();
this.keyConstraint = attrs.getKeyConstraint();
this.valueConstraint = attrs.getValueConstraint();
this.initialCapacity = attrs.getInitialCapacity();

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

this.regionAttributes.statisticsEnabled = regionAttributes.getStatisticsEnabled();
this.regionAttributes.ignoreJTA = regionAttributes.getIgnoreJTA();
this.regionAttributes.keyConstraint = regionAttributes.getKeyConstraint();
this.regionAttributes.valueConstraint = regionAttributes.getValueConstraint();
this.regionAttributes.initialCapacity = regionAttributes.getInitialCapacity();

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

this.cacheWriterDesc = getDesc(attr.getCacheWriter());
this.cacheListenerDescs = getDescs(attr.getCacheListeners());
this.keyConstraint = attr.getKeyConstraint();
this.valueConstraint = attr.getValueConstraint();
this.rTtl = attr.getRegionTimeToLive();

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

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

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

if (parentIsUserSpecified) {
 if (parentWithHas.hasKeyConstraint()) {
  setKeyConstraint(parent.getKeyConstraint());
 setKeyConstraint(parent.getKeyConstraint());

代码示例来源:origin: org.springframework.data/spring-data-geode

private Region<?, ?> validate(RepositoryMetadata repositoryMetadata, GemfirePersistentEntity<?> entity,
    Region<?, ?> region) {
  Assert.notNull(region, "Region is required");
  Class<?> repositoryIdType = repositoryMetadata.getIdType();
  Optional.ofNullable(region.getAttributes().getKeyConstraint())
    .ifPresent(regionKeyType -> Assert.isTrue(regionKeyType.isAssignableFrom(repositoryIdType),
      () -> String.format(REGION_REPOSITORY_ID_TYPE_MISMATCH, region.getFullPath(), regionKeyType.getName(),
        repositoryMetadata.getRepositoryInterface().getName(), repositoryIdType.getName())));
  Optional.ofNullable(entity)
    .map(GemfirePersistentEntity::getIdProperty)
    .ifPresent(entityIdProperty -> Assert.isTrue(repositoryIdType.isAssignableFrom(entityIdProperty.getType()),
      () -> String.format(REPOSITORY_ENTITY_ID_TYPE_MISMATCH, repositoryMetadata.getRepositoryInterface().getName(),
        repositoryIdType.getName(), entityIdProperty.getOwner().getName(), entityIdProperty.getTypeName())));
  return region;
}

代码示例来源:origin: org.springframework.data/spring-data-gemfire

private Region<?, ?> validate(RepositoryMetadata repositoryMetadata, GemfirePersistentEntity<?> entity,
    Region<?, ?> region) {
  Assert.notNull(region, "Region is required");
  Class<?> repositoryIdType = repositoryMetadata.getIdType();
  Optional.ofNullable(region.getAttributes().getKeyConstraint())
    .ifPresent(regionKeyType -> Assert.isTrue(regionKeyType.isAssignableFrom(repositoryIdType),
      () -> String.format(REGION_REPOSITORY_ID_TYPE_MISMATCH, region.getFullPath(), regionKeyType.getName(),
        repositoryMetadata.getRepositoryInterface().getName(), repositoryIdType.getName())));
  Optional.ofNullable(entity)
    .map(GemfirePersistentEntity::getIdProperty)
    .ifPresent(entityIdProperty -> Assert.isTrue(repositoryIdType.isAssignableFrom(entityIdProperty.getType()),
      () -> String.format(REPOSITORY_ENTITY_ID_TYPE_MISMATCH, repositoryMetadata.getRepositoryInterface().getName(),
        repositoryIdType.getName(), entityIdProperty.getOwner().getName(), entityIdProperty.getTypeName())));
  return region;
}

代码示例来源:origin: org.springframework.data/spring-data-gemfire

private Optional<String> configureWithRegionAttributes(ClientRegionFactory<K, V> clientRegionFactory) {
  AtomicReference<String> regionAttributesPoolName = new AtomicReference<>(null);
  Optional.ofNullable(getAttributes()).ifPresent(regionAttributes -> {
    regionAttributesPoolName.set(regionAttributes.getPoolName());
    stream(nullSafeArray(regionAttributes.getCacheListeners(), CacheListener.class))
      .forEach(clientRegionFactory::addCacheListener);
    clientRegionFactory.setCloningEnabled(regionAttributes.getCloningEnabled());
    clientRegionFactory.setCompressor(regionAttributes.getCompressor());
    clientRegionFactory.setConcurrencyChecksEnabled(regionAttributes.getConcurrencyChecksEnabled());
    clientRegionFactory.setConcurrencyLevel(regionAttributes.getConcurrencyLevel());
    clientRegionFactory.setCustomEntryIdleTimeout(regionAttributes.getCustomEntryIdleTimeout());
    clientRegionFactory.setCustomEntryTimeToLive(regionAttributes.getCustomEntryTimeToLive());
    clientRegionFactory.setDiskStoreName(regionAttributes.getDiskStoreName());
    clientRegionFactory.setDiskSynchronous(regionAttributes.isDiskSynchronous());
    clientRegionFactory.setEntryIdleTimeout(regionAttributes.getEntryIdleTimeout());
    clientRegionFactory.setEntryTimeToLive(regionAttributes.getEntryTimeToLive());
    clientRegionFactory.setEvictionAttributes(regionAttributes.getEvictionAttributes());
    clientRegionFactory.setInitialCapacity(regionAttributes.getInitialCapacity());
    clientRegionFactory.setKeyConstraint(regionAttributes.getKeyConstraint());
    clientRegionFactory.setLoadFactor(regionAttributes.getLoadFactor());
    clientRegionFactory.setRegionIdleTimeout(regionAttributes.getRegionIdleTimeout());
    clientRegionFactory.setRegionTimeToLive(regionAttributes.getRegionTimeToLive());
    clientRegionFactory.setStatisticsEnabled(regionAttributes.getStatisticsEnabled());
    clientRegionFactory.setValueConstraint(regionAttributes.getValueConstraint());
  });
  return Optional.ofNullable(regionAttributesPoolName.get()).filter(StringUtils::hasText);
}

代码示例来源:origin: org.springframework.data/spring-data-geode

private Optional<String> configureWithRegionAttributes(ClientRegionFactory<K, V> clientRegionFactory) {
  AtomicReference<String> regionAttributesPoolName = new AtomicReference<>(null);
  Optional.ofNullable(getAttributes()).ifPresent(regionAttributes -> {
    regionAttributesPoolName.set(regionAttributes.getPoolName());
    stream(nullSafeArray(regionAttributes.getCacheListeners(), CacheListener.class))
      .forEach(clientRegionFactory::addCacheListener);
    clientRegionFactory.setCloningEnabled(regionAttributes.getCloningEnabled());
    clientRegionFactory.setCompressor(regionAttributes.getCompressor());
    clientRegionFactory.setConcurrencyChecksEnabled(regionAttributes.getConcurrencyChecksEnabled());
    clientRegionFactory.setConcurrencyLevel(regionAttributes.getConcurrencyLevel());
    clientRegionFactory.setCustomEntryIdleTimeout(regionAttributes.getCustomEntryIdleTimeout());
    clientRegionFactory.setCustomEntryTimeToLive(regionAttributes.getCustomEntryTimeToLive());
    clientRegionFactory.setDiskStoreName(regionAttributes.getDiskStoreName());
    clientRegionFactory.setDiskSynchronous(regionAttributes.isDiskSynchronous());
    clientRegionFactory.setEntryIdleTimeout(regionAttributes.getEntryIdleTimeout());
    clientRegionFactory.setEntryTimeToLive(regionAttributes.getEntryTimeToLive());
    clientRegionFactory.setEvictionAttributes(regionAttributes.getEvictionAttributes());
    clientRegionFactory.setInitialCapacity(regionAttributes.getInitialCapacity());
    clientRegionFactory.setKeyConstraint(regionAttributes.getKeyConstraint());
    clientRegionFactory.setLoadFactor(regionAttributes.getLoadFactor());
    clientRegionFactory.setRegionIdleTimeout(regionAttributes.getRegionIdleTimeout());
    clientRegionFactory.setRegionTimeToLive(regionAttributes.getRegionTimeToLive());
    clientRegionFactory.setStatisticsEnabled(regionAttributes.getStatisticsEnabled());
    clientRegionFactory.setValueConstraint(regionAttributes.getValueConstraint());
  });
  return Optional.ofNullable(regionAttributesPoolName.get()).filter(StringUtils::hasText);
}

代码示例来源:origin: org.springframework.geode/spring-geode-actuator

private BiConsumer<Region<?, ?>, Health.Builder> withRegionDetails() {
  return (region, builder) -> {
    String regionName = region.getName();
    builder.withDetail(cacheRegionKey(regionName, "full-path"), region.getFullPath());
    Optional.ofNullable(region.getAttributes())
      .ifPresent(regionAttributes -> builder
        .withDetail(cacheRegionKey(regionName, "cloning-enabled"), toYesNoString(regionAttributes.getCloningEnabled()))
        .withDetail(cacheRegionKey(regionName, "data-policy"), String.valueOf(regionAttributes.getDataPolicy()))
        .withDetail(cacheRegionKey(regionName, "initial-capacity"), regionAttributes.getInitialCapacity())
        .withDetail(cacheRegionKey(regionName, "load-factor"), regionAttributes.getLoadFactor())
        .withDetail(cacheRegionKey(regionName, "key-constraint"), nullSafeClassName(regionAttributes.getKeyConstraint()))
        .withDetail(cacheRegionKey(regionName, "off-heap"), toYesNoString(regionAttributes.getOffHeap()))
        .withDetail(cacheRegionKey(regionName, "pool-name"), Optional.ofNullable(regionAttributes.getPoolName())
          .filter(StringUtils::hasText)
          .orElse(""))
        .withDetail(cacheRegionKey(regionName, "scope"), String.valueOf(regionAttributes.getScope()))
        .withDetail(cacheRegionKey(regionName, "statistics-enabled"), toYesNoString(regionAttributes.getStatisticsEnabled()))
        .withDetail(cacheRegionKey(regionName, "value-constraint"), nullSafeClassName(regionAttributes.getValueConstraint())));
  };
}

代码示例来源:origin: org.springframework.data/spring-data-geode

regionFactory.setIndexMaintenanceSynchronous(regionAttributes.getIndexMaintenanceSynchronous());
regionFactory.setInitialCapacity(regionAttributes.getInitialCapacity());
regionFactory.setKeyConstraint(regionAttributes.getKeyConstraint());
regionFactory.setLoadFactor(regionAttributes.getLoadFactor());
regionFactory.setLockGrantor(regionAttributes.isLockGrantor());

相关文章

微信公众号

最新文章

更多

RegionAttributes类方法