@Override public boolean equals(Object obj) { if (obj instanceof Duration) { return duration.equals(((Duration) obj).duration); } return false; }
@Override public boolean equals(Object obj) { return obj instanceof TimeToIdleExpiryPolicy && tti.equals(((TimeToIdleExpiryPolicy) obj).tti); }
@Override public boolean equals(Object obj) { return obj instanceof TimeToLiveExpiryPolicy && ttl.equals(((TimeToLiveExpiryPolicy) obj).ttl); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Timeouts timeouts = (Timeouts) o; if (!readOperationTimeout.equals(timeouts.readOperationTimeout)) { return false; } if (!writeOperationTimeout.equals(timeouts.writeOperationTimeout)) { return false; } return connectionTimeout.equals(timeouts.connectionTimeout); }
/** * Sets a callable to be repeated the given number of times. If there is also an expected result * for the callable, that expectation must be met for each iteration of the callable. * * @param iterations the number of times to run the callable * @return this, the ConcurrentOperation (containing a callable) that has been set to repeat */ public ConcurrentOperation repeatForIterations(int iterations) { if (!duration.equals(DEFAULT_DURATION)) { throw new IllegalArgumentException("Specify only Duration or Iterations"); } this.iterations = iterations; return this; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; LatencyHistogramConfiguration that = (LatencyHistogramConfiguration) o; if (that.phi != phi) return false; if (bucketCount != that.bucketCount) return false; return window.equals(that.window); }
private static TimeType convertToTimeType(Duration duration) { return Stream.of(java.util.concurrent.TimeUnit.values()) .sorted(comparing(unit -> unit.convert(duration.toNanos(), NANOSECONDS))) .filter(unit -> duration.equals(Duration.of(unit.convert(duration.toNanos(), NANOSECONDS), jucTimeUnitToTemporalUnit(unit)))) .findFirst() .map(unit -> new TimeType() .withValue(BigInteger.valueOf(unit.convert(duration.toNanos(), NANOSECONDS))) .withUnit(convertToXmlTimeUnit(unit)) ).orElseThrow(AssertionError::new); } }
protected static <K, V> boolean newValueAlreadyExpired(Logger logger, ExpiryPolicy<? super K, ? super V> expiry, K key, V oldValue, V newValue) { if (newValue == null) { return false; } Duration duration; try { if (oldValue == null) { duration = expiry.getExpiryForCreation(key, newValue); } else { duration = expiry.getExpiryForUpdate(key, () -> oldValue, newValue); } } catch (RuntimeException re) { logger.error("Expiry computation caused an exception - Expiry duration will be 0 ", re); return true; } return Duration.ZERO.equals(duration); }
private static <K, V> boolean newValueAlreadyExpired(Logger logger, ExpiryPolicy<? super K, ? super V> expiry, K key, V oldValue, V newValue) { if (newValue == null) { return false; } Duration duration; try { if (oldValue == null) { duration = expiry.getExpiryForCreation(key, newValue); } else { duration = expiry.getExpiryForUpdate(key, () -> oldValue, newValue); } } catch (RuntimeException re) { logger.error("Expiry computation caused an exception - Expiry duration will be 0 ", re); return true; } return Duration.ZERO.equals(duration); } }
@Override public void setAccessAndExpiryTimeWhenCallerOutsideLock(K key, OnHeapValueHolder<V> valueHolder, long now) { Duration duration = getAccessDuration(key, valueHolder); if (Duration.ZERO.equals(duration)) { // Expires mapping through computeIfPresent store.expireMappingUnderLock(key, valueHolder); } else { valueHolder.accessed(now, duration); } }
public OnHeapValueHolder<V> setAccessAndExpiryWhenCallerlUnderLock(K key, OnHeapValueHolder<V> valueHolder, long now, StoreEventSink<K, V> eventSink) { Duration duration = getAccessDuration(key, valueHolder); if (Duration.ZERO.equals(duration)) { // Fires event, must happen under lock store.fireOnExpirationEvent(key, valueHolder, eventSink); return null; } else { valueHolder.accessed(now, duration); } return valueHolder; }
private OffHeapValueHolder<V> setAccessTimeAndExpiryThenReturnMapping(K key, OffHeapValueHolder<V> valueHolder, long now, StoreEventSink<K, V> eventSink) { Duration duration = Duration.ZERO; try { duration = expiry.getExpiryForAccess(key, valueHolder); if (duration != null && duration.isNegative()) { duration = Duration.ZERO; } } catch (RuntimeException re) { LOG.error("Expiry computation caused an exception - Expiry duration will be 0 ", re); } if (Duration.ZERO.equals(duration)) { onExpiration(key, valueHolder, eventSink); return null; } valueHolder.accessed(now, duration); valueHolder.writeBack(); return valueHolder; }
private OnHeapValueHolder<V> importValueFromLowerTier(K key, ValueHolder<V> valueHolder, long now, Backend<K, V> backEnd, Fault<V> fault) { Duration expiration = strategy.getAccessDuration(key, valueHolder); if (Duration.ZERO.equals(expiration)) { invalidateInGetOrComputeIfAbsent(backEnd, key, valueHolder, fault, now, Duration.ZERO); getOrComputeIfAbsentObserver.end(CachingTierOperationOutcomes.GetOrComputeIfAbsentOutcome.FAULT_FAILED); return null; } try{ return cloneValueHolder(key, valueHolder, now, expiration, true); } catch (LimitExceededException e) { LOG.warn(e.getMessage()); invalidateInGetOrComputeIfAbsent(backEnd, key, valueHolder, fault, now, expiration); getOrComputeIfAbsentObserver.end(CachingTierOperationOutcomes.GetOrComputeIfAbsentOutcome.FAULT_FAILED); return null; } }
if (bufferingTimespan.equals(openBufferEvery)) { return buffer(bufferingTimespan, timer);
if (openWindowEvery.equals(windowingTimespan)) { return window(windowingTimespan);
private OnHeapValueHolder<V> newUpdateValueHolder(K key, OnHeapValueHolder<V> oldValue, V newValue, long now, StoreEventSink<K, V> eventSink) { Objects.requireNonNull(oldValue); Objects.requireNonNull(newValue); Duration duration = strategy.getUpdateDuration(key, oldValue, newValue); if (Duration.ZERO.equals(duration)) { eventSink.updated(key, oldValue, newValue); eventSink.expired(key, () -> newValue); return null; } long expirationTime; if (duration == null) { expirationTime = oldValue.expirationTime(); } else { if (isExpiryDurationInfinite(duration)) { expirationTime = ValueHolder.NO_EXPIRE; } else { expirationTime = ExpiryUtils.getExpirationMillis(now, duration); } } OnHeapValueHolder<V> holder = null; try { holder = makeValue(key, newValue, now, expirationTime, this.valueCopier); eventSink.updated(key, oldValue, newValue); } catch (LimitExceededException e) { LOG.warn(e.getMessage()); eventSink.removed(key, oldValue); } return holder; }
if (converter.reverse().convert(nextValue).equals(duration)) {
private OffHeapValueHolder<V> newUpdatedValueHolder(K key, V value, OffHeapValueHolder<V> existing, long now, StoreEventSink<K, V> eventSink) { eventSink.updated(key, existing, value); Duration duration = Duration.ZERO; try { duration = expiry.getExpiryForUpdate(key, existing, value); if (duration != null && duration.isNegative()) { duration = Duration.ZERO; } } catch (RuntimeException re) { LOG.error("Expiry computation caused an exception - Expiry duration will be 0 ", re); } if (Duration.ZERO.equals(duration)) { eventSink.expired(key, () -> value); return null; } if (duration == null) { return new BasicOffHeapValueHolder<>(backingMap().nextIdFor(key), value, now, existing.expirationTime()); } else if (isExpiryDurationInfinite(duration)) { return new BasicOffHeapValueHolder<>(backingMap().nextIdFor(key), value, now, OffHeapValueHolder.NO_EXPIRE); } else { return new BasicOffHeapValueHolder<>(backingMap().nextIdFor(key), value, now, ExpiryUtils.getExpirationMillis(now, duration)); } }
Preconditions.checkState(true == ALLOW_STALE_CONFIG.getDefaultValue()); Preconditions.checkState(ALLOW_STALE_CONFIG.getType().equals(ConfigOption.Type.MASKABLE)); Preconditions.checkState(!customCommitTime.equals(MAX_COMMIT_TIME.getDefaultValue()));
Preconditions.checkState(ALLOW_STALE_CONFIG.getDefaultValue()); Preconditions.checkState(ALLOW_STALE_CONFIG.getType().equals(ConfigOption.Type.MASKABLE)); Preconditions.checkState(!customCommitTime.equals(MAX_COMMIT_TIME.getDefaultValue()));