Search in sources :

Example 51 with ExpirationAttributes

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

the class HARegionQueue method disableEntryExpiryTasks.

/**
   * Disables EntryExpiryTask for the HARegion ({@code this.region}).
   * 
   */
private void disableEntryExpiryTasks() {
    int oldTimeToLive = this.region.getEntryTimeToLive().getTimeout();
    if (oldTimeToLive > 0) {
        ExpirationAttributes ea = new // disables expiration
        ExpirationAttributes(// disables expiration
        0, ExpirationAction.LOCAL_INVALIDATE);
        this.region.setEntryTimeToLive(ea);
        this.region.setCustomEntryTimeToLive(new ThreadIdentifierCustomExpiry());
        logger.info(LocalizedMessage.create(LocalizedStrings.HARegionQueue_ENYTRY_EXPIRY_TASKS_DISABLED_BECAUSE_QUEUE_BECAME_PRIMARY_OLD_MSG_TTL_0, new Object[] { oldTimeToLive }));
    }
}
Also used : ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Example 52 with ExpirationAttributes

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

the class CacheXmlParser method endRegionTimeToLive.

/**
   * When a <code>region-time-to-live</code> element is finished, the {@link ExpirationAttributes}
   * are on top of the stack followed by the {@link RegionAttributesCreation} to which the
   * expiration attributes are assigned.
   */
private void endRegionTimeToLive() {
    ExpirationAttributes expire = (ExpirationAttributes) stack.pop();
    RegionAttributesCreation attrs = peekRegionAttributesContext("region-time-to-live");
    attrs.setRegionTimeToLive(expire);
}
Also used : ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Example 53 with ExpirationAttributes

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

the class CacheXmlParser method endRegionIdleTime.

/**
   * When a <code>region-idle-time</code> element is finished, the {@link ExpirationAttributes} are
   * on top of the stack followed by the {@link RegionAttributesCreation} to which the expiration
   * attributes are assigned.
   */
private void endRegionIdleTime() {
    ExpirationAttributes expire = (ExpirationAttributes) stack.pop();
    RegionAttributesCreation attrs = peekRegionAttributesContext("region-idle-time");
    attrs.setRegionIdleTimeout(expire);
}
Also used : ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Example 54 with ExpirationAttributes

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

the class HARegion method setEntryTimeToLive.

/**
   * Overriding this method so as to allow expiry action of local invalidate even if the scope is
   * distributed mirrored.
   * 
   * <p>
   * author Asif
   */
@Override
public ExpirationAttributes setEntryTimeToLive(ExpirationAttributes timeToLive) {
    // checkReadiness();
    if (timeToLive == null) {
        throw new IllegalArgumentException(LocalizedStrings.HARegion_TIMETOLIVE_MUST_NOT_BE_NULL.toLocalizedString());
    }
    if ((timeToLive.getAction() == ExpirationAction.LOCAL_DESTROY && this.dataPolicy.withReplication())) {
        throw new IllegalArgumentException(LocalizedStrings.HARegion_TIMETOLIVE_ACTION_IS_INCOMPATIBLE_WITH_THIS_REGIONS_MIRROR_TYPE.toLocalizedString());
    }
    if (!this.statisticsEnabled) {
        throw new IllegalStateException(LocalizedStrings.HARegion_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)

Example 55 with ExpirationAttributes

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

the class RegionAttributesCreation method setEntryTimeToLive.

public ExpirationAttributes setEntryTimeToLive(ExpirationAttributes timeToLive) {
    ExpirationAttributes old = this.entryTimeToLive;
    this.entryTimeToLive = timeToLive;
    setHasEntryTimeToLive(true);
    return old;
}
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