Search in sources :

Example 1 with UserSpecifiedRegionAttributes

use of org.apache.geode.internal.cache.UserSpecifiedRegionAttributes in project geode by apache.

the class ClientRegionFactoryImpl method createRegionAttributes.

@SuppressWarnings("deprecation")
private RegionAttributes<K, V> createRegionAttributes() {
    RegionAttributes<K, V> ra = this.attrsFactory.create();
    if (isEmpty(ra.getPoolName())) {
        UserSpecifiedRegionAttributes<K, V> ura = (UserSpecifiedRegionAttributes<K, V>) ra;
        if (ura.requiresPoolName) {
            Pool dp = getDefaultPool();
            if (dp != null) {
                this.attrsFactory.setPoolName(dp.getName());
                ra = this.attrsFactory.create();
            } else {
                throw new IllegalStateException("The poolName must be set on a client.");
            }
        }
    }
    return ra;
}
Also used : UserSpecifiedRegionAttributes(org.apache.geode.internal.cache.UserSpecifiedRegionAttributes) Pool(org.apache.geode.cache.client.Pool)

Example 2 with UserSpecifiedRegionAttributes

use of org.apache.geode.internal.cache.UserSpecifiedRegionAttributes in project geode by apache.

the class RegionAttributesCreation method inheritAttributes.

void inheritAttributes(Cache cache, boolean setDefaultPool) {
    if (this.refid == null) {
        // No attributes to inherit
        if (setDefaultPool && this.requiresPoolName && !hasPoolName()) {
            String defaultPoolName = null;
            if (cache instanceof GemFireCacheImpl) {
                InternalClientCache gfc = (InternalClientCache) cache;
                if (gfc.getDefaultPool() != null) {
                    defaultPoolName = gfc.getDefaultPool().getName();
                }
            } else if (cache instanceof ClientCacheCreation) {
                ClientCacheCreation ccc = (ClientCacheCreation) cache;
                defaultPoolName = ccc.getDefaultPoolName();
            }
            if (defaultPoolName != null) {
                setPoolName(defaultPoolName);
            }
        }
        return;
    }
    RegionAttributes parent = cache.getRegionAttributes(this.refid);
    if (parent == null) {
        throw new IllegalStateException(LocalizedStrings.RegionAttributesCreation_CANNOT_REFERENCE_NONEXISTING_REGION_ATTRIBUTES_NAMED_0.toLocalizedString(this.refid));
    }
    final boolean parentIsUserSpecified = parent instanceof UserSpecifiedRegionAttributes;
    final UserSpecifiedRegionAttributes parentWithHas;
    if (parentIsUserSpecified) {
        parentWithHas = (UserSpecifiedRegionAttributes) parent;
    } else {
        parentWithHas = null;
    }
    if (parentWithHas != null) {
        if (setDefaultPool && parentWithHas.requiresPoolName) {
            this.requiresPoolName = true;
            if (!hasPoolName()) {
                String defaultPoolName = null;
                if (cache instanceof GemFireCacheImpl) {
                    InternalClientCache gfc = (InternalClientCache) cache;
                    if (gfc.getDefaultPool() != null) {
                        defaultPoolName = gfc.getDefaultPool().getName();
                    }
                } else if (cache instanceof ClientCacheCreation) {
                    ClientCacheCreation ccc = (ClientCacheCreation) cache;
                    defaultPoolName = ccc.getDefaultPoolName();
                }
                if (defaultPoolName != null) {
                    setPoolName(defaultPoolName);
                }
            }
        }
    }
    // Inherit attributes that are not overridden
    if (!hasCacheListeners()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasCacheListeners()) {
                initCacheListeners(parent.getCacheListeners());
            }
        } else {
            initCacheListeners(parent.getCacheListeners());
        }
    }
    if (!hasGatewaySenderId()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasGatewaySenderId()) {
                initGatewaySenders(parent.getGatewaySenderIds());
            }
        } else {
            initGatewaySenders(parent.getGatewaySenderIds());
        }
    }
    if (!hasAsyncEventListeners()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasAsyncEventListeners()) {
                initAsyncEventQueues(parent.getAsyncEventQueueIds());
            }
        } else {
            initAsyncEventQueues(parent.getAsyncEventQueueIds());
        }
    }
    if (!hasCacheLoader()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasCacheLoader()) {
                setCacheLoader(parent.getCacheLoader());
            }
        } else {
            setCacheLoader(parent.getCacheLoader());
        }
    }
    if (!hasCacheWriter()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasCacheWriter()) {
                setCacheWriter(parent.getCacheWriter());
            }
        } else {
            setCacheWriter(parent.getCacheWriter());
        }
    }
    if (!hasEntryIdleTimeout()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasEntryIdleTimeout()) {
                setEntryIdleTimeout(parent.getEntryIdleTimeout());
            }
        } else {
            setEntryIdleTimeout(parent.getEntryIdleTimeout());
        }
    }
    if (!hasCustomEntryIdleTimeout()) {
        setCustomEntryIdleTimeout(parent.getCustomEntryIdleTimeout());
    }
    if (!hasEntryTimeToLive()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasEntryTimeToLive()) {
                setEntryTimeToLive(parent.getEntryTimeToLive());
            }
        } else {
            setEntryTimeToLive(parent.getEntryTimeToLive());
        }
    }
    if (!hasCustomEntryTimeToLive()) {
        setCustomEntryTimeToLive(parent.getCustomEntryTimeToLive());
    }
    if (!hasInitialCapacity()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasInitialCapacity()) {
                setInitialCapacity(parent.getInitialCapacity());
            }
        } else {
            setInitialCapacity(parent.getInitialCapacity());
        }
    }
    if (!hasKeyConstraint()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasKeyConstraint()) {
                setKeyConstraint(parent.getKeyConstraint());
            }
        } else {
            setKeyConstraint(parent.getKeyConstraint());
        }
    }
    if (!hasValueConstraint()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasValueConstraint()) {
                setValueConstraint(parent.getValueConstraint());
            }
        } else {
            setValueConstraint(parent.getValueConstraint());
        }
    }
    if (!hasLoadFactor()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasLoadFactor()) {
                setLoadFactor(parent.getLoadFactor());
            }
        } else {
            setLoadFactor(parent.getLoadFactor());
        }
    }
    if (!hasRegionIdleTimeout()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasRegionIdleTimeout()) {
                setRegionIdleTimeout(parent.getRegionIdleTimeout());
            }
        } else {
            setRegionIdleTimeout(parent.getRegionIdleTimeout());
        }
    }
    if (!hasRegionTimeToLive()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasRegionTimeToLive()) {
                setRegionTimeToLive(parent.getRegionTimeToLive());
            }
        } else {
            setRegionTimeToLive(parent.getRegionTimeToLive());
        }
    }
    if (!hasScope()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasScope()) {
                setScope(parent.getScope());
            }
        } else {
            setScope(parent.getScope());
        }
    }
    if (!hasStatisticsEnabled()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasStatisticsEnabled()) {
                setStatisticsEnabled(parent.getStatisticsEnabled());
            }
        } else {
            setStatisticsEnabled(parent.getStatisticsEnabled());
        }
    }
    if (!hasIgnoreJTA()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasIgnoreJTA()) {
                setIgnoreJTA(parent.getIgnoreJTA());
            }
        } else {
            setIgnoreJTA(parent.getIgnoreJTA());
        }
    }
    if (!hasIsLockGrantor()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasIsLockGrantor()) {
                setLockGrantor(parent.isLockGrantor());
            }
        } else {
            setLockGrantor(parent.isLockGrantor());
        }
    }
    if (!hasConcurrencyLevel()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasConcurrencyLevel()) {
                setConcurrencyLevel(parent.getConcurrencyLevel());
            }
        } else {
            setConcurrencyLevel(parent.getConcurrencyLevel());
        }
    }
    if (!hasConcurrencyChecksEnabled()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasConcurrencyChecksEnabled()) {
                setConcurrencyChecksEnabled(parent.getConcurrencyChecksEnabled());
            }
        } else {
            setConcurrencyChecksEnabled(parent.getConcurrencyChecksEnabled());
        }
    }
    if (!hasEarlyAck()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasEarlyAck()) {
                setEarlyAck(parent.getEarlyAck());
            }
        } else {
            setEarlyAck(parent.getEarlyAck());
        }
    }
    if (!this.hasEnableSubscriptionConflation()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasEnableSubscriptionConflation()) {
                setEnableSubscriptionConflation(parent.getEnableSubscriptionConflation());
            }
        } else {
            setEnableSubscriptionConflation(parent.getEnableSubscriptionConflation());
        }
    }
    if (!hasPublisher()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasPublisher()) {
                setPublisher(parent.getPublisher());
            }
        } else {
            setPublisher(parent.getPublisher());
        }
    }
    if (!hasEnableAsyncConflation()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasEnableAsyncConflation()) {
                setEnableAsyncConflation(parent.getEnableAsyncConflation());
            }
        } else {
            setEnableAsyncConflation(parent.getEnableAsyncConflation());
        }
    }
    if (!hasMulticastEnabled()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasMulticastEnabled()) {
                setMulticastEnabled(parent.getMulticastEnabled());
            }
        } else {
            setMulticastEnabled(parent.getMulticastEnabled());
        }
    }
    if (!hasDiskWriteAttributes()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasDiskWriteAttributes()) {
                setDiskWriteAttributes(parent.getDiskWriteAttributes());
            }
        } else {
            setDiskWriteAttributes(parent.getDiskWriteAttributes());
        }
    }
    if (!hasDiskDirs()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasDiskDirs()) {
                setDiskDirs(parent.getDiskDirs());
            }
        } else {
            setDiskDirs(parent.getDiskDirs());
        }
    }
    if (!hasIndexMaintenanceSynchronous()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasIndexMaintenanceSynchronous()) {
                setIndexMaintenanceSynchronous(parent.getIndexMaintenanceSynchronous());
            }
        } else {
            setIndexMaintenanceSynchronous(parent.getIndexMaintenanceSynchronous());
        }
    }
    if (!hasPartitionAttributes()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasPartitionAttributes()) {
                setPartitionAttributes(parent.getPartitionAttributes());
            }
        } else {
            setPartitionAttributes(parent.getPartitionAttributes());
        }
    }
    if (!hasSubscriptionAttributes()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasSubscriptionAttributes()) {
                setSubscriptionAttributes(parent.getSubscriptionAttributes());
            }
        } else {
            setSubscriptionAttributes(parent.getSubscriptionAttributes());
        }
    }
    if (!hasDataPolicy()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasDataPolicy()) {
                setDataPolicy(parent.getDataPolicy());
            }
        } else {
            setDataPolicy(parent.getDataPolicy());
        }
    }
    if (!hasEvictionAttributes()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasEvictionAttributes()) {
                setEvictionAttributes(parent.getEvictionAttributes());
            }
        } else {
            setEvictionAttributes(parent.getEvictionAttributes());
        }
    }
    if (!hasPoolName()) {
        setPoolName(parent.getPoolName());
    }
    if (!hasDiskStoreName()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasDiskStoreName()) {
                setDiskStoreName(parent.getDiskStoreName());
            }
        } else {
            setDiskStoreName(parent.getDiskStoreName());
        }
    }
    if (!hasDiskSynchronous()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasDiskSynchronous()) {
                setDiskSynchronous(parent.isDiskSynchronous());
            }
        } else {
            setDiskSynchronous(parent.isDiskSynchronous());
        }
    }
    if (!hasCompressor()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasCompressor()) {
                setCompressor(parent.getCompressor());
            }
        } else {
            setCompressor(parent.getCompressor());
        }
    }
    if (!hasConcurrencyChecksEnabled()) {
        if (parentIsUserSpecified) {
            if (parentWithHas.hasConcurrencyChecksEnabled()) {
                setConcurrencyChecksEnabled(parent.getConcurrencyChecksEnabled());
            }
        } else {
            setConcurrencyChecksEnabled(parent.getConcurrencyChecksEnabled());
        }
    }
    if (!hasMulticastEnabled()) {
        // bug #38836 - inherit multicast setting
        if (parentIsUserSpecified) {
            if (parentWithHas.hasMulticastEnabled()) {
                setMulticastEnabled(parent.getMulticastEnabled());
            }
        } else {
            setMulticastEnabled(parent.getMulticastEnabled());
        }
    }
}
Also used : UserSpecifiedRegionAttributes(org.apache.geode.internal.cache.UserSpecifiedRegionAttributes) InternalClientCache(org.apache.geode.cache.client.internal.InternalClientCache) RegionAttributes(org.apache.geode.cache.RegionAttributes) UserSpecifiedRegionAttributes(org.apache.geode.internal.cache.UserSpecifiedRegionAttributes) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl)

Aggregations

UserSpecifiedRegionAttributes (org.apache.geode.internal.cache.UserSpecifiedRegionAttributes)2 RegionAttributes (org.apache.geode.cache.RegionAttributes)1 Pool (org.apache.geode.cache.client.Pool)1 InternalClientCache (org.apache.geode.cache.client.internal.InternalClientCache)1 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)1