/** * Gets the standard pass through. * * @param statistic the statistic * @return the standard pass through */ private Statistic<Number> getStandardPassThrough(StandardPassThroughStatistic statistic) { Statistic<Number> passThrough = standardPassThroughs.get(statistic); if (passThrough instanceof NullStatistic<?>) { ValueStatistic discovered = findPassThroughStatistic(manager, statistic); if (discovered == null) { return passThrough; } else { Statistic<Number> newPassThrough = new SemiExpiringStatistic(discovered, executor, defaultHistorySize, SECONDS.toNanos(defaultIntervalSeconds)); if (standardPassThroughs.replace(statistic, passThrough, newPassThrough)) { return newPassThrough; } else { return standardPassThroughs.get(statistic); } } } else { return passThrough; } }
/** * Expire. * * @param expiryTime the expiry time * @return true, if successful */ boolean expire(long expiryTime) { return (count.expire(expiryTime) & rate.expire(expiryTime) & latency.expire(expiryTime)); }
/** * Sets the history. * * @param historySize the history size * @param historyNanos the history nanos */ void setHistory(int historySize, long historyNanos) { count.setHistory(historySize, historyNanos); rate.setHistory(historySize, historyNanos); latency.setHistory(historySize, historyNanos); } }
/** * Start. */ protected final synchronized void start() { if (!active) { startStatistic(); startSampling(); active = true; } }
/** * Expire. * * @param expiry the expiry * @return true, if successful */ protected final synchronized boolean expire(long expiry) { if (touchTimestamp < expiry) { if (active) { stopSampling(); stopStatistic(); active = false; } return true; } else { return false; } }
/** * Touch. */ protected final synchronized void touch() { touchTimestamp = Time.absoluteTime(); start(); }
@Override public List<Timestamped<T>> history() { touch(); return super.history(); }
@Override public T value() { touch(); return super.value(); } }
/** * Start. */ protected final synchronized void start() { if (!active) { startStatistic(); startSampling(); active = true; } }
/** * Expire. * * @param expiry the expiry * @return true, if successful */ protected final synchronized boolean expire(long expiry) { if (touchTimestamp < expiry) { if (active) { stopSampling(); stopStatistic(); active = false; } return true; } else { return false; } }
/** * Start. */ void start() { count.start(); rate.start(); latency.start(); }
@Override public List<Timestamped<T>> history() { touch(); return super.history(); }
@Override public T value() { touch(); return super.value(); } }
/** * Start. */ protected final synchronized void start() { if (!active) { startStatistic(); startSampling(); active = true; } }
/** * Find standard pass thru statistics. */ private void findStandardPassThruStatistics() { for (final StandardPassThroughStatistic t : StandardPassThroughStatistic.values()) { ValueStatistic statistic = findPassThroughStatistic(manager, t); if (statistic == null) { LOGGER.debug("Mocking Pass-Through Statistic: {}", t); standardPassThroughs.put(t, NullStatistic.instance(t.absentValue())); } else { standardPassThroughs.put(t, new SemiExpiringStatistic(statistic, executor, defaultHistorySize, SECONDS.toNanos(defaultIntervalSeconds))); } } }
/** * Expire. * * @param expiry the expiry * @return true, if successful */ protected final synchronized boolean expire(long expiry) { if (touchTimestamp < expiry) { if (active) { stopSampling(); stopStatistic(); active = false; } return true; } else { return false; } }
/** * Touch. */ protected final synchronized void touch() { touchTimestamp = Time.absoluteTime(); start(); }
/** * Sets the history. * * @param historySize the history size * @param historyNanos the history nanos */ void setHistory(int historySize, long historyNanos) { count.setHistory(historySize, historyNanos); rate.setHistory(historySize, historyNanos); latency.setHistory(historySize, historyNanos); } }
@Override public List<Timestamped<T>> history() { touch(); return super.history(); }
/** * Expire. * * @param expiryTime the expiry time * @return true, if successful */ boolean expire(long expiryTime) { return (count.expire(expiryTime) & rate.expire(expiryTime) & latency.expire(expiryTime)); }