Search in sources :

Example 26 with ExpirationAttributes

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

the class PartitionedRegion method setEntryTimeToLive.

/**
   * Changes the timeToLive expiration attributes for values in this region.
   * 
   * @param timeToLive the timeToLive expiration attributes for entries
   * @return the previous value of entry timeToLive
   * @throws IllegalArgumentException if timeToLive is null or if the ExpirationAction is
   *         LOCAL_DESTROY and the region is {@link DataPolicy#withReplication replicated} 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 setEntryTimeToLive(ExpirationAttributes timeToLive) {
    ExpirationAttributes attr = super.setEntryTimeToLive(timeToLive);
    // 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().setEntryTimeToLive(timeToLive);
        }
    }
    updatePRConfig(getPRConfigWithLatestExpirationAttributes(), false);
    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)

Example 27 with ExpirationAttributes

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

the class PartitionedRegion method setRegionTimeToLive.

/**
   * Changes the timeToLive expiration attributes for the partitioned region as a whole
   * 
   * @param timeToLive the expiration attributes for the region timeToLive
   * @return the previous value of region timeToLive
   * @throws IllegalArgumentException if timeToLive 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 setRegionTimeToLive(ExpirationAttributes timeToLive) {
    ExpirationAttributes attr = super.setRegionTimeToLive(timeToLive);
    // 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().setRegionTimeToLive(timeToLive);
        }
    }
    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)

Example 28 with ExpirationAttributes

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

the class RegionAttributesCreation method setRegionTimeToLive.

public ExpirationAttributes setRegionTimeToLive(ExpirationAttributes timeToLive) {
    ExpirationAttributes old = this.regionTimeToLive;
    this.regionTimeToLive = timeToLive;
    setHasRegionTimeToLive(true);
    return old;
}
Also used : ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Example 29 with ExpirationAttributes

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

the class RegionAttributesCreation method setEntryIdleTimeout.

public ExpirationAttributes setEntryIdleTimeout(ExpirationAttributes idleTimeout) {
    ExpirationAttributes old = this.entryIdleTimeout;
    this.entryIdleTimeout = idleTimeout;
    setHasEntryIdleTimeout(true);
    return old;
}
Also used : ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Example 30 with ExpirationAttributes

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

the class AbstractRegion method setEntryTimeToLive.

@Override
public ExpirationAttributes setEntryTimeToLive(ExpirationAttributes timeToLive) {
    checkReadiness();
    if (timeToLive == null) {
        throw new IllegalArgumentException(LocalizedStrings.AbstractRegion_TIMETOLIVE_MUST_NOT_BE_NULL.toLocalizedString());
    }
    checkEntryTimeoutAction("timeToLive", timeToLive.getAction());
    if (!this.statisticsEnabled) {
        throw new IllegalStateException(LocalizedStrings.AbstractRegion_CANNOT_SET_TIME_TO_LIVE_WHEN_STATISTICS_ARE_DISABLED.toLocalizedString());
    }
    ExpirationAttributes oldAttrs = getEntryTimeToLive();
    this.entryTimeToLive = timeToLive.getTimeout();
    this.entryTimeToLiveExpirationAction = timeToLive.getAction();
    setEntryTimeToLiveAttributes();
    updateEntryExpiryPossible();
    timeToLiveChanged(oldAttrs);
    return oldAttrs;
}
Also used : ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

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