/** * 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; } }
/** * 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))); } } }
/** * Instantiates a new operation impl. * * @param source the source * @param targets the targets * @param averageNanos the average nanos * @param executor the executor * @param historySize the history size * @param historyNanos the history nanos */ public OperationImpl(OperationStatistic<T> source, Set<T> targets, long averageNanos, ScheduledExecutorService executor, int historySize, long historyNanos) { this.source = source; this.count = new SemiExpiringStatistic<Long>(source.statistic(targets), executor, historySize, historyNanos); this.latency = new LatencyImpl(source, targets, averageNanos, executor, historySize, historyNanos); this.rate = new RateImpl(source, targets, averageNanos, executor, historySize, historyNanos); }
@Override public Set<Statistic<Number>> passthru(String name, Set<String> tags) { ArrayList<String> key = new ArrayList<String>(tags.size() + 1); key.addAll(tags); Collections.sort(key); key.add(name); if (customPassthrus.containsKey(key)) { return customPassthrus.get(key); } // lets make sure we don't get it twice. synchronized (customPassthrus) { if (customPassthrus.containsKey(key)) { return customPassthrus.get(key); } Set<ValueStatistic<?>> interim = findPassThroughStatistic(manager, EhcacheQueryBuilder.cache().descendants(), name, tags); if (interim.isEmpty()) { return Collections.EMPTY_SET; } Set<Statistic<Number>> ret = new HashSet<Statistic<Number>>(interim.size()); for (ValueStatistic<?> vs : interim) { SemiExpiringStatistic stat = new SemiExpiringStatistic(vs, executor, defaultHistorySize, SECONDS.toNanos(defaultIntervalSeconds)); ret.add(stat); } customPassthrus.put(key, ret); return ret; } }
/** * 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; } }
/** * 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; } }
/** * 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))); } } }
/** * 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))); } } }
@Override public Set<Statistic<Number>> passthru(String name, Set<String> tags) { ArrayList<String> key = new ArrayList<String>(tags.size() + 1); key.addAll(tags); Collections.sort(key); key.add(name); if (customPassthrus.containsKey(key)) { return customPassthrus.get(key); } // lets make sure we don't get it twice. synchronized (customPassthrus) { if (customPassthrus.containsKey(key)) { return customPassthrus.get(key); } Set<ValueStatistic<?>> interim = findPassThroughStatistic(manager, EhcacheQueryBuilder.cache().descendants(), name, tags); if (interim.isEmpty()) { return Collections.EMPTY_SET; } Set<Statistic<Number>> ret = new HashSet<Statistic<Number>>(interim.size()); for (ValueStatistic<?> vs : interim) { SemiExpiringStatistic stat = new SemiExpiringStatistic(vs, executor, defaultHistorySize, SECONDS.toNanos(defaultIntervalSeconds)); ret.add(stat); } customPassthrus.put(key, ret); return ret; } }
@Override public Set<Statistic<Number>> passthru(String name, Set<String> tags) { ArrayList<String> key = new ArrayList<String>(tags.size() + 1); key.addAll(tags); Collections.sort(key); key.add(name); if (customPassthrus.containsKey(key)) { return customPassthrus.get(key); } // lets make sure we don't get it twice. synchronized (customPassthrus) { if (customPassthrus.containsKey(key)) { return customPassthrus.get(key); } Set<ValueStatistic<?>> interim = findPassThroughStatistic(manager, EhcacheQueryBuilder.cache().descendants(), name, tags); if (interim.isEmpty()) { return Collections.EMPTY_SET; } Set<Statistic<Number>> ret = new HashSet<Statistic<Number>>(interim.size()); for (ValueStatistic<?> vs : interim) { SemiExpiringStatistic stat = new SemiExpiringStatistic(vs, executor, defaultHistorySize, SECONDS.toNanos(defaultIntervalSeconds)); ret.add(stat); } customPassthrus.put(key, ret); return ret; } }
/** * Instantiates a new operation impl. * * @param source the source * @param targets the targets * @param averageNanos the average nanos * @param executor the executor * @param historySize the history size * @param historyNanos the history nanos */ public OperationImpl(OperationStatistic<T> source, Set<T> targets, long averageNanos, ScheduledExecutorService executor, int historySize, long historyNanos) { this.source = source; this.count = new SemiExpiringStatistic<Long>(source.statistic(targets), executor, historySize, historyNanos); this.latency = new LatencyImpl(source, targets, averageNanos, executor, historySize, historyNanos); this.rate = new RateImpl(source, targets, averageNanos, executor, historySize, historyNanos); }
/** * Instantiates a new operation impl. * * @param source the source * @param targets the targets * @param averageNanos the average nanos * @param executor the executor * @param historySize the history size * @param historyNanos the history nanos */ public OperationImpl(OperationStatistic<T> source, Set<T> targets, long averageNanos, ScheduledExecutorService executor, int historySize, long historyNanos) { this.source = source; this.count = new SemiExpiringStatistic<Long>(source.statistic(targets), executor, historySize, historyNanos); this.latency = new LatencyImpl(source, targets, averageNanos, executor, historySize, historyNanos); this.rate = new RateImpl(source, targets, averageNanos, executor, historySize, historyNanos); }