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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations