Search in sources :

Example 16 with Scope

use of org.apache.geode.cache.Scope in project geode by apache.

the class PartitionRegionConfigValidator method validatePartitionAttrsFromPRConfig.

/**
   * This method validates the PartitionedAttributes that user provided PR Attributes with PR
   * Attributes set in PR Config obtained from global meta-data allPartitionedRegion region
   */
void validatePartitionAttrsFromPRConfig(PartitionRegionConfig prconf) {
    final PartitionAttributes prconfPA = prconf.getPartitionAttrs();
    final PartitionAttributes userPA = pr.getAttributes().getPartitionAttributes();
    if (userPA.getTotalSize() != prconfPA.getTotalSize()) {
        throw new IllegalStateException(LocalizedStrings.PartitionedRegion_TOTAL_SIZE_IN_PARTITIONATTRIBUTES_IS_INCOMPATIBLE_WITH_GLOBALLY_SET_TOTAL_SIZE_SET_THE_TOTAL_SIZE_TO_0MB.toLocalizedString(Long.valueOf(prconfPA.getTotalSize())));
    }
    if (userPA.getRedundantCopies() != prconfPA.getRedundantCopies()) {
        throw new IllegalStateException(LocalizedStrings.PartitionedRegion_REQUESTED_REDUNDANCY_0_IS_INCOMPATIBLE_WITH_EXISTING_REDUNDANCY_1.toLocalizedString(new Object[] { Integer.valueOf(userPA.getRedundantCopies()), Integer.valueOf(prconfPA.getRedundantCopies()) }));
    }
    if (prconf.isFirstDataStoreCreated() && pr.isDataStore()) {
        validateDistributedEvictionAttributes(prconf.getEvictionAttributes());
    }
    Scope prconfScope = prconf.getScope();
    Scope myScope = pr.getScope();
    if (!myScope.equals(prconfScope)) {
        throw new IllegalStateException(LocalizedStrings.PartitionedRegion_SCOPE_IN_PARTITIONATTRIBUTES_IS_INCOMPATIBLE_WITH_ALREADY_SET_SCOPESET_THE_SCOPE_TO_0.toLocalizedString(prconfScope));
    }
    final int prconfTotalNumBuckets = prconfPA.getTotalNumBuckets();
    if (userPA.getTotalNumBuckets() != prconfTotalNumBuckets) {
        throw new IllegalStateException(LocalizedStrings.PartitionedRegion_THE_TOTAL_NUMBER_OF_BUCKETS_FOUND_IN_PARTITIONATTRIBUTES_0_IS_INCOMPATIBLE_WITH_THE_TOTAL_NUMBER_OF_BUCKETS_USED_BY_OTHER_DISTRIBUTED_MEMBERS_SET_THE_NUMBER_OF_BUCKETS_TO_1.toLocalizedString(new Object[] { Integer.valueOf(userPA.getTotalNumBuckets()), Integer.valueOf(prconfTotalNumBuckets) }));
    }
    validatePartitionListeners(prconf, userPA);
    validatePartitionResolver(prconf, userPA);
    validateColocatedWith(prconf, userPA);
    validateExpirationAttributes(pr.getAttributes(), prconf);
}
Also used : Scope(org.apache.geode.cache.Scope) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes)

Aggregations

Scope (org.apache.geode.cache.Scope)16 RegionAttributes (org.apache.geode.cache.RegionAttributes)11 AttributesFactory (org.apache.geode.cache.AttributesFactory)4 Cache (org.apache.geode.cache.Cache)4 CacheLoader (org.apache.geode.cache.CacheLoader)3 DataPolicy (org.apache.geode.cache.DataPolicy)3 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)3 Region (org.apache.geode.cache.Region)3 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 CacheException (org.apache.geode.cache.CacheException)2 FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)2 PartitionAttributes (org.apache.geode.cache.PartitionAttributes)2 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)2 File (java.io.File)1 Set (java.util.Set)1 CancelCriterion (org.apache.geode.CancelCriterion)1 InternalGemFireException (org.apache.geode.InternalGemFireException)1 CacheEvent (org.apache.geode.cache.CacheEvent)1