Search in sources :

Example 31 with ExpirationAttributes

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

the class AbstractRegion method setRegionIdleTimeout.

@Override
public ExpirationAttributes setRegionIdleTimeout(ExpirationAttributes idleTimeout) {
    checkReadiness();
    if (idleTimeout == null) {
        throw new IllegalArgumentException(LocalizedStrings.AbstractRegion_IDLETIMEOUT_MUST_NOT_BE_NULL.toLocalizedString());
    }
    if (this.getAttributes().getDataPolicy().withPartitioning()) {
        validatePRRegionExpirationAttributes(idleTimeout);
    }
    if (idleTimeout.getAction() == ExpirationAction.LOCAL_INVALIDATE && this.dataPolicy.withReplication()) {
        throw new IllegalArgumentException(LocalizedStrings.AbstractRegion_0_ACTION_IS_INCOMPATIBLE_WITH_THIS_REGIONS_DATA_POLICY.toLocalizedString("idleTimeout"));
    }
    if (!this.statisticsEnabled) {
        throw new IllegalStateException(LocalizedStrings.AbstractRegion_CANNOT_SET_IDLE_TIMEOUT_WHEN_STATISTICS_ARE_DISABLED.toLocalizedString());
    }
    ExpirationAttributes oldAttrs = getRegionIdleTimeout();
    this.regionIdleTimeout = idleTimeout.getTimeout();
    this.regionIdleTimeoutExpirationAction = idleTimeout.getAction();
    this.setRegionIdleTimeoutAttributes();
    regionIdleTimeoutChanged(oldAttrs);
    return oldAttrs;
}
Also used : ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Example 32 with ExpirationAttributes

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

the class AbstractRegion method setRegionTimeToLive.

@Override
public ExpirationAttributes setRegionTimeToLive(ExpirationAttributes timeToLive) {
    checkReadiness();
    if (timeToLive == null) {
        throw new IllegalArgumentException(LocalizedStrings.AbstractRegion_TIMETOLIVE_MUST_NOT_BE_NULL.toLocalizedString());
    }
    if (this.getAttributes().getDataPolicy().withPartitioning()) {
        validatePRRegionExpirationAttributes(timeToLive);
    }
    if (timeToLive.getAction() == ExpirationAction.LOCAL_INVALIDATE && this.dataPolicy.withReplication()) {
        throw new IllegalArgumentException(LocalizedStrings.AbstractRegion_0_ACTION_IS_INCOMPATIBLE_WITH_THIS_REGIONS_DATA_POLICY.toLocalizedString("timeToLive"));
    }
    if (!this.statisticsEnabled) {
        throw new IllegalStateException(LocalizedStrings.AbstractRegion_CANNOT_SET_TIME_TO_LIVE_WHEN_STATISTICS_ARE_DISABLED.toLocalizedString());
    }
    ExpirationAttributes oldAttrs = getRegionTimeToLive();
    this.regionTimeToLive = timeToLive.getTimeout();
    this.regionTimeToLiveExpirationAction = timeToLive.getAction();
    this.setRegionTimeToLiveAtts();
    regionTimeToLiveChanged(timeToLive);
    return oldAttrs;
}
Also used : ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Example 33 with ExpirationAttributes

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

the class AbstractRegion method setEntryIdleTimeout.

@Override
public ExpirationAttributes setEntryIdleTimeout(ExpirationAttributes idleTimeout) {
    checkReadiness();
    if (idleTimeout == null) {
        throw new IllegalArgumentException(LocalizedStrings.AbstractRegion_IDLETIMEOUT_MUST_NOT_BE_NULL.toLocalizedString());
    }
    checkEntryTimeoutAction("idleTimeout", idleTimeout.getAction());
    if (!this.statisticsEnabled) {
        throw new IllegalStateException(LocalizedStrings.AbstractRegion_CANNOT_SET_IDLE_TIMEOUT_WHEN_STATISTICS_ARE_DISABLED.toLocalizedString());
    }
    ExpirationAttributes oldAttrs = getEntryIdleTimeout();
    this.entryIdleTimeout = idleTimeout.getTimeout();
    this.entryIdleTimeoutExpirationAction = idleTimeout.getAction();
    setEntryIdleTimeoutAttributes();
    updateEntryExpiryPossible();
    idleTimeoutChanged(oldAttrs);
    return oldAttrs;
}
Also used : ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Example 34 with ExpirationAttributes

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

the class ClientHealthMonitoringRegion method initialize.

/**
   * This method creates the client health monitoring region.
   * <p>
   * GuardedBy ClientHealthMonitoringRegion.class
   *
   * @param cache The current GemFire Cache
   */
private static void initialize(InternalCache cache) {
    try {
        AttributesFactory factory = new AttributesFactory();
        factory.setScope(Scope.LOCAL);
        factory.setEntryTimeToLive(new ExpirationAttributes(ADMIN_REGION_EXPIRY_INTERVAL, ExpirationAction.DESTROY));
        cache.getLogger().fine("ClientHealthMonitoringRegion, setting TTL for entry....");
        factory.addCacheListener(prepareCacheListener());
        factory.setStatisticsEnabled(true);
        RegionAttributes regionAttrs = factory.create();
        InternalRegionArguments internalArgs = new InternalRegionArguments();
        internalArgs.setIsUsedForMetaRegion(true);
        internalArgs.setIsUsedForPartitionedRegionAdmin(false);
        currentInstance = cache.createVMRegion(ADMIN_REGION_NAME, regionAttrs, internalArgs);
    } catch (Exception ex) {
        cache.getLoggerI18n().error(LocalizedStrings.ClientHealthMonitoringRegion_ERROR_WHILE_CREATING_AN_ADMIN_REGION, ex);
    }
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) InternalRegionArguments(org.apache.geode.internal.cache.InternalRegionArguments) ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Example 35 with ExpirationAttributes

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

the class PartitionedRegion method setRegionIdleTimeout.

/**
   * Changes the idleTimeout expiration attributes for the region as a whole. Resets the
   * {@link CacheStatistics#getLastAccessedTime} for the region.
   * 
   * @param idleTimeout the ExpirationAttributes for this region idleTimeout
   * @return the previous value of region idleTimeout
   * @throws IllegalArgumentException if idleTimeout is null or if the ExpirationAction is
   *         LOCAL_INVALIDATE and the region is {@link DataPolicy#withReplication replicated}
   * @throws IllegalStateException if statistics are disabled for this region.
   */
@Override
public ExpirationAttributes setRegionIdleTimeout(ExpirationAttributes idleTimeout) {
    ExpirationAttributes attr = super.setRegionIdleTimeout(idleTimeout);
    // Set to Bucket regions as well
    if (this.getDataStore() != null) {
        // not for accessors
        for (Object o : this.getDataStore().getAllLocalBuckets()) {
            Map.Entry entry = (Map.Entry) o;
            Region bucketRegion = (Region) entry.getValue();
            bucketRegion.getAttributesMutator().setRegionIdleTimeout(idleTimeout);
        }
    }
    return attr;
}
Also used : Region(org.apache.geode.cache.Region) DumpB2NRegion(org.apache.geode.internal.cache.partitioned.DumpB2NRegion) ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashMap(java.util.HashMap)

Aggregations

ExpirationAttributes (org.apache.geode.cache.ExpirationAttributes)84 Region (org.apache.geode.cache.Region)51 AttributesFactory (org.apache.geode.cache.AttributesFactory)50 Test (org.junit.Test)50 RegionAttributes (org.apache.geode.cache.RegionAttributes)41 LocalRegion (org.apache.geode.internal.cache.LocalRegion)41 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)35 Entry (org.apache.geode.cache.Region.Entry)21 EntryEvent (org.apache.geode.cache.EntryEvent)15 CacheException (org.apache.geode.cache.CacheException)12 AttributesMutator (org.apache.geode.cache.AttributesMutator)11 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)11 Host (org.apache.geode.test.dunit.Host)11 VM (org.apache.geode.test.dunit.VM)11 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)11 Properties (java.util.Properties)10 EntryExpiryTask (org.apache.geode.internal.cache.EntryExpiryTask)10 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)10 Cache (org.apache.geode.cache.Cache)8 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)8