public boolean isExpired() { // entityAccess.getTimestamp(curValue) represents the time at which the current value // was last updated. If the last value is less than current time - 1 binPrecision, then it // means that we've rolled over and need to reset the value. final long maxExpectedTimePeriod = System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(numConfiguredBins, binPrecision); final S curValue = ref.get(); return (entityAccess.getTimestamp(curValue) < maxExpectedTimePeriod); }
public S addOrReset(final S event) { // entityAccess.getTimestamp(curValue) represents the time at which the current value // was last updated. If the last value is less than current time - 1 binPrecision, then it // means that we've rolled over and need to reset the value. final long maxExpectedTimePeriod = System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(1, binPrecision); final S curValue = ref.get(); if (entityAccess.getTimestamp(curValue) < maxExpectedTimePeriod) { ref.compareAndSet(curValue, entityAccess.createNew()); } return add(event); } }
public boolean isExpired() { // entityAccess.getTimestamp(curValue) represents the time at which the current value // was last updated. If the last value is less than current time - 1 binPrecision, then it // means that we've rolled over and need to reset the value. final long maxExpectedTimePeriod = System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(numConfiguredBins, binPrecision); final S curValue = ref.get(); return (entityAccess.getTimestamp(curValue) < maxExpectedTimePeriod); }
public S addOrReset(final S event) { // entityAccess.getTimestamp(curValue) represents the time at which the current value // was last updated. If the last value is less than current time - 1 binPrecision, then it // means that we've rolled over and need to reset the value. final long maxExpectedTimePeriod = System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(1, binPrecision); final S curValue = ref.get(); if (entityAccess.getTimestamp(curValue) < maxExpectedTimePeriod) { ref.compareAndSet(curValue, entityAccess.createNew()); } return add(event); } }