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