/** * 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 pass through statistic. * * @param manager the manager * @param statistic the statistic * @return the value statistic */ private static ValueStatistic findPassThroughStatistic(StatisticsManager manager, StandardPassThroughStatistic statistic) { Set<ValueStatistic<?>> results = findPassThroughStatistic(manager, statistic.context(), statistic.statisticName(), statistic.tags()); switch (results.size()) { case 0: return null; case 1: return results.iterator().next(); default: throw new IllegalStateException("Duplicate statistics found for " + statistic); } }
/** * 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; } }
/** * 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 pass through statistic. * * @param manager the manager * @param statistic the statistic * @return the value statistic */ private static ValueStatistic findPassThroughStatistic(StatisticsManager manager, StandardPassThroughStatistic statistic) { Set<ValueStatistic<?>> results = findPassThroughStatistic(manager, statistic.context(), statistic.statisticName(), statistic.tags()); switch (results.size()) { case 0: return null; case 1: return results.iterator().next(); default: throw new IllegalStateException("Duplicate statistics found for " + statistic); } }
/** * Find pass through statistic. * * @param manager the manager * @param statistic the statistic * @return the value statistic */ private static ValueStatistic findPassThroughStatistic(StatisticsManager manager, StandardPassThroughStatistic statistic) { Set<ValueStatistic<?>> results = findPassThroughStatistic(manager, statistic.context(), statistic.statisticName(), statistic.tags()); switch (results.size()) { case 0: return null; case 1: return results.iterator().next(); default: throw new IllegalStateException("Duplicate statistics found for " + statistic); } }
/** * 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; } }