com.gemstone.gemfire.internal.cache.RegionIdleExpiryTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gemfire-core Show documentation
Show all versions of gemfire-core Show documentation
SnappyData store based off Pivotal GemFireXD
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire.internal.cache;
import com.gemstone.gemfire.cache.*;
/**
*
* @author Eric Zoerner
*/
class RegionIdleExpiryTask extends RegionExpiryTask {
/** Creates a new instance of RegionIdleExpiryTask */
RegionIdleExpiryTask(LocalRegion reg) {
super(reg);
}
/**
* @return the absolute time (ms since Jan 1, 1970) at which this
* region expires, due to either time-to-live or idle-timeout (whichever
* will occur first), or 0 if neither are used.
*/
@Override
long getExpirationTime() throws EntryNotFoundException {
// if this is an invalidate action and region has already been invalidated,
// then don't expire again until the full timeout from now.
ExpirationAction action = getAction();
if (action == ExpirationAction.INVALIDATE ||
action == ExpirationAction.LOCAL_INVALIDATE) {
if (getLocalRegion().regionInvalid) {
int timeout = getIdleAttributes().getTimeout();
if (timeout == 0) return 0L;
if (!getLocalRegion().EXPIRY_UNITS_MS) {
timeout *= 1000;
}
return timeout + System.currentTimeMillis();
}
}
// otherwise, expire at timeout plus last accessed time
return getIdleExpirationTime();
}
@Override
protected ExpirationAction getAction() {
return getIdleAttributes().getAction();
}
@Override
protected final void addExpiryTask() {
getLocalRegion().addIdleExpiryTask(this);
}
@Override
public boolean isPending() {
return false;
}
}