/** * Blocks until the clock used for expiration moves forward. * * @param cacheTimeMillisSource region that provides cacheTimeMillis * @param baseTime the timestamp that the clock must exceed * @return the last time stamp observed * @deprecated Please use {@link GeodeAwaitility} instead. */ public static long waitForExpiryClockToChange(final LocalRegion cacheTimeMillisSource, final long baseTime) { long nowTime; do { Thread.yield(); nowTime = cacheTimeMillisSource.cacheTimeMillis(); } while ((nowTime - baseTime) <= 0L); return nowTime; } }
/** * Blocks until the clock used for expiration moves forward. * * @param cacheTimeMillisSource region that provides cacheTimeMillis * @return the last time stamp observed * @deprecated Please use {@link GeodeAwaitility} instead. */ public static long waitForExpiryClockToChange(final LocalRegion cacheTimeMillisSource) { return waitForExpiryClockToChange(cacheTimeMillisSource, cacheTimeMillisSource.cacheTimeMillis()); }
@Override public long getLastAccessedTime() { return (getRegion() != null) ? ((LocalRegion) getRegion()).cacheTimeMillis() : System.currentTimeMillis(); }
@Override public long getLastModifiedTime() { return (getRegion() != null) ? ((LocalRegion) getRegion()).cacheTimeMillis() : System.currentTimeMillis(); }
@Test public void testGetEventTimeWithNullVersionTag() { long timestamp = System.currentTimeMillis(); LocalRegion region = mock(LocalRegion.class); when(region.cacheTimeMillis()).thenReturn(timestamp); EntryEventImpl e = createEntryEvent(region, null); assertThat(e.getEventTime(0l)).isEqualTo(timestamp); }
tag = VersionTag.create(getVersionMember()); map.initialImagePut(key, cacheTimeMillis(), value, false, false, tag, null, false);
@Test public void testGetEventTimeWithVersionTagConcurrencyChecksDisabledNoSuggestedTime() { long timestamp = System.currentTimeMillis(); LocalRegion region = mock(LocalRegion.class); when(region.getConcurrencyChecksEnabled()).thenReturn(false); when(region.cacheTimeMillis()).thenReturn(timestamp); EntryEventImpl e = createEntryEvent(region, null); VersionTag tag = VersionTag.create(mock(InternalDistributedMember.class)); tag.setVersionTimeStamp(timestamp + 1000l); e.setVersionTag(tag); assertThat(e.getEventTime(0l)).isEqualTo(timestamp); }
/** * Determines whether the receiver is unexpired with regard to the given timeToLive and idleTime * attributes, which may different from this entry's actual attributes. Used for validation of * objects during netSearch(), which must validate remote entries against local timeout * attributes. */ boolean isExpiredWithRegardTo(Object key, int ttl, int idleTime) { if (!getAttributes().getStatisticsEnabled()) { return false; } long expTime; try { expTime = new NetSearchExpirationCalculator(this, key, ttl, idleTime).getExpirationTime(); } catch (EntryNotFoundException ignore) { return true; } return expTime != 0 && expTime <= cacheTimeMillis(); }
/** * Update the API statistics appropriately for returning this value from get. * * @param regionEntry the entry whose value was accessed */ public void updateStatsForGet(final RegionEntry regionEntry, final boolean hit) { if (!this.statisticsEnabled) { return; } final long now = cacheTimeMillis(); if (regionEntry != null) { regionEntry.updateStatsForGet(hit, now); if (isEntryIdleExpiryPossible()) { addExpiryTaskIfAbsent(regionEntry); } } // update region stats setLastAccessedTime(now, hit); }
@Test public void testGetEventTimeWithVersionTagConcurrencyChecksEnabledWithSuggestedTime() { long timestamp = System.currentTimeMillis(); long timestampPlus1 = timestamp + 1000l; long timestampPlus2 = timestamp + 2000l; LocalRegion region = mock(LocalRegion.class); when(region.getConcurrencyChecksEnabled()).thenReturn(true); when(region.cacheTimeMillis()).thenReturn(timestamp); EntryEventImpl e = createEntryEvent(region, null); VersionTag tag = VersionTag.create(mock(InternalDistributedMember.class)); tag.setVersionTimeStamp(timestampPlus1); e.setVersionTag(tag); assertThat(e.getEventTime(timestampPlus2)).isEqualTo(timestampPlus2); assertThat(tag.getVersionTimeStamp()).isEqualTo(timestampPlus2); }
long lastAccessed = cacheTimeMillis(); if (lruRecentUse) {
@Override public void txApplyPut(Operation putOp, Object key, Object newValue, boolean didDestroy, TransactionId rmtOrigin, TXRmtEvent event, EventID eventId, Object aCallbackArgument, List<EntryEventImpl> pendingCallbacks, FilterRoutingInfo filterRoutingInfo, ClientProxyMembershipID bridgeContext, TXEntryState txEntryState, VersionTag versionTag, long tailKey) { Operation putOperation = putOp.getCorrespondingCreateOp(); long lastMod = owner.cacheTimeMillis(); this.owner.txApplyPutPart2(markerEntry, key, lastMod, true, didDestroy, false); if (this.owner.isInitialized()) { if (event != null) { event.addPut(putOperation, this.owner, markerEntry, key, newValue, aCallbackArgument); } if (AbstractRegionMap.shouldInvokeCallbacks(this.owner, this.owner.isInitialized())) { // fix for bug 39526 @Released EntryEventImpl e = AbstractRegionMap.createCallbackEvent(this.owner, putOperation, key, newValue, rmtOrigin, event, eventId, aCallbackArgument, filterRoutingInfo, bridgeContext, txEntryState, versionTag, tailKey); AbstractRegionMap.switchEventOwnerAndOriginRemote(e, txEntryState == null); pendingCallbacks.add(e); } } }
/** * @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 public 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().isRegionInvalid()) { int timeout = getIdleAttributes().getTimeout(); if (timeout == 0) return 0L; if (!getLocalRegion().EXPIRY_UNITS_MS) { timeout *= 1000; } // Expiration should always use the DSClock instead of the System clock. return timeout + getLocalRegion().cacheTimeMillis(); } } // otherwise, expire at timeout plus last accessed time return getIdleExpirationTime(); }
/** * @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 public 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().isRegionInvalid()) { int timeout = getTTLAttributes().getTimeout(); if (timeout == 0) return 0L; if (!getLocalRegion().EXPIRY_UNITS_MS) { timeout *= 1000; } // Sometimes region expiration depends on lastModifiedTime which in turn // depends on entry modification time. To make it consistent always use // cache time here. return timeout + getLocalRegion().cacheTimeMillis(); } } // otherwise, expire at timeout plus last modified time return getTTLExpirationTime(); }
throw new IndexMaintenanceException(e); } finally { IndexManager.setIndexBufferTime(lastModifiedTime, cacheTimeMillis());
tag.setVersionTimeStamp(cacheTimeMillis()); tag.setRegionVersion(myVector.getNextVersionWhileLocked()); if (isRvvDebugEnabled) {
oldRe.txDidDestroy(owner.cacheTimeMillis()); txRemoveOldIndexEntry(Operation.INVALIDATE, re); if (didDestroy) { re.txDidDestroy(owner.cacheTimeMillis());