@Override protected final void basicPerformTimeout(boolean isPending) throws CacheException { if (isCanceled) { return; } super.basicPerformTimeout(isPending); }
@Override public boolean cancel() { isCanceled = true; return super.cancel(); }
protected final boolean expire(boolean isPending) throws CacheException { waitOnExpirationSuspension(); ExpirationAction action = getAction(); if (action == null) return false; return expire(action, isPending); }
/** * Called by LocalRegion#basicProcessPendingExpires and LocalRegion#handleInitialPendingExpires */ protected void basicPerformTimeout(boolean isPending) throws CacheException { if (!isExpirationAllowed()) { return; } if (isExpirationPossible()) { expire(isPending); } reschedule(); }
/** * Return true if current task could have expired. * Return false if expiration is impossible. */ protected boolean isExpirationPossible() throws EntryNotFoundException { long expTime = getExpirationTime(); if (expTime > 0L && getNow() >= expTime) { return true; } return false; }
/** Why did this expire? * @return the action to perform or null if NONE */ protected ExpirationAction getAction() { long ttl = getTTLExpirationTime(); long idle = getIdleExpirationTime(); if (ttl == 0) { if (idle == 0) return null; return getIdleAttributes().getAction(); } if (idle == 0) { // we know ttl != 0 return getTTLAttributes().getAction(); } // Neither is 0 if (idle < ttl) { return getIdleAttributes().getAction(); } return getTTLAttributes().getAction(); }
protected final boolean expire(ExpirationAction action, boolean isPending) throws CacheException { if (action.isInvalidate()) return invalidate(); if (action.isDestroy()) return destroy(isPending); if (action.isLocalInvalidate()) return localInvalidate(); if (action.isLocalDestroy()) return localDestroy(); throw new InternalGemFireError(LocalizedStrings.ExpiryTask_UNRECOGNIZED_EXPIRATION_ACTION_0.toLocalizedString(action)); }
protected void performTimeout() throws CacheException { if (getLoggerI18n().fineEnabled()) { getLoggerI18n().fine(this.toString() + ".performTimeout(): getExpirationTime() returns " + getExpirationTime()); } getLocalRegion().performExpiryTimeout(this); }
/** Return the absolute time when idle expiration occurs, or 0 if not used */ public final long getIdleExpirationTime() throws EntryNotFoundException { long idle = getIdleAttributes().getTimeout(); long tilt = 0; if (idle > 0) { if (getLocalRegion()!=null && !getLocalRegion().EXPIRY_UNITS_MS) { idle *= 1000; } tilt = getLastAccessedTime() + idle; } return tilt; }
protected void performTimeout() throws CacheException { if (logger.isDebugEnabled()) { logger.debug("{}.performTimeout(): getExpirationTime() returns {}", this.toString(), getExpirationTime()); } getLocalRegion().performExpiryTimeout(this); }
/** schedules the given expiration task */ public ExpiryTask addExpiryTask(ExpiryTask task) { LogWriterI18n log = task.getLocalRegion().getCache().getLoggerI18n(); try { if (DEBUG) { log.info(LocalizedStrings.ExpirationScheduler_SCHEDULING__0__TO_FIRE_IN__1__MS, new Object[] {task, Long.valueOf(task.getExpiryMillis())}); } // By using getExpirationTime and passing a Date to schedule // we get rid of two calls of System.currentTimeMillis(). // The Date object creation is very simple and has a very short life. timer.schedule(task, new Date(task.getExpirationTime())); } catch (EntryNotFoundException e) { // ignore - there are unsynchronized paths that allow an entry to // be destroyed out from under us. } catch (IllegalStateException e) { // task must have been cancelled by another thread so don't schedule it } return task; }
/** * @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. */ public long getExpirationTime() throws EntryNotFoundException { long ttl = getTTLExpirationTime(); long idle = getIdleExpirationTime(); if (ttl == 0) { return idle; } else if (idle == 0) { return ttl; } return Math.min(ttl, idle); }
protected void rescheduleEntryExpiryTasks() { if (isProxy()) { return; } if (!isInitialized()) { return; // don't schedule expiration until region is initialized (bug } // OK to ignore transaction since Expiry only done non-tran Iterator<RegionEntry> it = this.entries.regionEntries().iterator(); if (it.hasNext()) { try { if (isEntryExpiryPossible()) { ExpiryTask.setNow(); } while (it.hasNext()) { addExpiryTask(it.next()); } } finally { ExpiryTask.clearNow(); } } }
try { if (logger.fineEnabled()) { logger.fine(tasks[i].toString() + " fired at " + System.currentTimeMillis()); tasks[i].basicPerformTimeout(true); if (isCacheClosing() || isClosed() || isDestroyed()) { return;
/** Returns true if the ExpirationAction is a distributed action. */ protected boolean isDistributedAction() { ExpirationAction action = getAction(); return action != null && (action.isInvalidate() || action.isDestroy()); }
/** schedules the given expiration task */ public ExpiryTask addExpiryTask(ExpiryTask task) { try { if(logger.isTraceEnabled()) { logger.trace(LocalizedMessage.create(LocalizedStrings.ExpirationScheduler_SCHEDULING__0__TO_FIRE_IN__1__MS, new Object[] {task, Long.valueOf(task.getExpiryMillis())})); } // To fix bug 52267 do not create a Date here; instead calculate the relative duration. timer.schedule(task, task.getExpiryMillis()); } catch (EntryNotFoundException e) { // ignore - there are unsynchronized paths that allow an entry to // be destroyed out from under us. return null; } catch (IllegalStateException e) { // task must have been cancelled by another thread so don't schedule it return null; } return task; }
String expIdle = "<unavailable>"; try { if (getTTLAttributes() != null) { expTtl = String.valueOf(getTTLExpirationTime()); if (getIdleAttributes() != null) { expIdle = String.valueOf(getIdleExpirationTime()); return super.toString() + " for " + getLocalRegion() + ", ttl expiration time: " + expTtl + ", idle expiration time: " + expIdle + ("[now:" + calculateNow() + "]");
protected final boolean expire(ExpirationAction action, boolean isPending) throws CacheException { if (action.isInvalidate()) return invalidate(); if (action.isDestroy()) return destroy(isPending); if (action.isLocalInvalidate()) return localInvalidate(); if (action.isLocalDestroy()) return localDestroy(); throw new InternalGemFireError(LocalizedStrings.ExpiryTask_UNRECOGNIZED_EXPIRATION_ACTION_0.toLocalizedString(action)); }
/** Return the absolute time when idle expiration occurs, or 0 if not used */ protected final long getIdleExpirationTime() throws EntryNotFoundException { long idle = getIdleAttributes().getTimeout(); long tilt = 0; if (idle > 0) { if (!getLocalRegion().EXPIRY_UNITS_MS) { idle *= 1000; } tilt = getLastAccessedTime() + idle; } return tilt; }