@Override public long getExpirations() { return expiration.sum() - compensatingCounters.expirations; }
protected <T extends Serializable> void registerStatistic(String name, StatisticType type, Set<String> tags, Supplier<T> valueSupplier) { StatisticsManager.createPassThroughStatistic(this, name, tags, type, valueSupplier); }
/** * Create an {@code OperationObserver} using {@code this} for the context. * * @param name name of the statistic * @param outcome class of the possible outcomes * @param canBeDisabled if this statistic can be disabled by a {@link StoreStatisticsConfiguration} * @param <T> type of the outcome * @return the created observer */ protected <T extends Enum<T>> OperationObserver<T> createObserver(String name, Class<T> outcome, boolean canBeDisabled) { if(!operationStatisticsEnabled && canBeDisabled) { return ZeroOperationStatistic.get(); } return operation(outcome).named(name).of(this).tag(getStatisticsTag()).build(); }
/** * Gets the value of the statistic indicated from an {@link OperationStatistic} * instance. * * @param operationStatistic the {@code OperationStatistic} instance from which the statistic is to * be obtained * @param statId the {@code Enum} constant identifying the statistic for which the value must be obtained * @param <E> The {@code Enum} type for the statistics * * @return the value, possibly null, for {@code statId} about {@code ehcache} */ private static <E extends Enum<E>> Number getStatistic(final OperationStatistic<E> operationStatistic, final E statId) { if (operationStatistic != null) { final ValueStatistic<Long> valueStatistic = operationStatistic.statistic(statId); return (valueStatistic == null ? null : valueStatistic.value()); } return null; }
protected <K, V, S extends Enum<S>, T extends Enum<T>> OperationStatistic<T> createTranslatedStatistic(BaseStore<K, V> store, String statisticName, Map<T, Set<S>> translation, String targetName) { Class<S> outcomeType = getOutcomeType(translation); // If the original stat doesn't exist, we do not need to translate it if (StatsUtils.hasOperationStat(store, outcomeType, targetName)) { int tierHeight = getResourceType().getTierHeight(); OperationStatistic<T> stat = new MappedOperationStatistic<>(store, translation, statisticName, tierHeight, targetName, store .getStatisticsTag()); StatisticsManager.associate(stat).withParent(store); return stat; } return ZeroOperationStatistic.get(); }
@Override protected boolean matchesSafely(OperationStatistic<T> object) { return object.type().equals(statisticType); } })
public <T extends Enum<T>, S extends ChainedOperationObserver<? super T>> void registerDerivedStatistic(Class<T> outcomeClass, String statName, S derivedStatistic) { OperationStatistic<T> stat = findOperationStatisticOnChildren(cache, outcomeClass, statName); stat.addDerivedStatistic(derivedStatistic); }
private void unRegisterPoolStatistics(ResourcePageSource pageSource) { TreeNode node = StatisticsManager.nodeFor(pageSource); if(node != null) { node.clean(); } }
/** * Add the statistic as a known statistic only if the reference statistic is available. We consider that the reference statistic can only be * an instance of {@code ZeroOperationStatistic} when statistics are disabled. * * @param knownStatistics map of known statistics * @param name the name of the statistic to add * @param reference the reference statistic that should be available for the statistic to be added * @param valueSupplier the supplier that will provide the current value for the statistic * @param <T> type of the supplied value */ private static <T extends Number> void addIfPresent(Map<String, ValueStatistic<?>> knownStatistics, String name, OperationStatistic<?> reference, Supplier<T> valueSupplier) { if(!(reference instanceof ZeroOperationStatistic)) { knownStatistics.put(name, counter(valueSupplier)); } }
/** * Gets the value of the statistic indicated from an {@link org.terracotta.statistics.OperationStatistic} * instance. * * @param operationStatistic the {@code OperationStatistic} instance from which the statistic is to * be obtained * @param statId the {@code Enum} constant identifying the statistic for which the value must be obtained * @param <E> The {@code Enum} type for the statistics * * @return the value, possibly null, for {@code statId} about {@code ehcache} */ private static <E extends Enum<E>> Number getStatistic(final OperationStatistic<E> operationStatistic, final E statId) { if (operationStatistic != null) { final ValueStatistic<Long> valueStatistic = operationStatistic.statistic(statId); return (valueStatistic == null ? null : valueStatistic.value()); } return null; }
@Override public long getRemovals() { return remove.sum(EnumSet.of(StoreOperationOutcomes.RemoveOutcome.REMOVED)) + compute.sum(EnumSet.of(StoreOperationOutcomes.ComputeOutcome.REMOVED)) + conditionalRemove.sum(EnumSet.of(StoreOperationOutcomes.ConditionalRemoveOutcome.REMOVED)) - compensatingCounters.removals; }
private void unRegisterStoreStatistics(ServerStoreImpl store) { TreeNode node = StatisticsManager.nodeFor(store); if(node != null) { node.clean(); } }
/** * Gets the value of the statistic indicated from an {@link OperationStatistic} * instance. * * @param operationStatistic the {@code OperationStatistic} instance from which the statistic is to * be obtained * @param statId the {@code Enum} constant identifying the statistic for which the value must be obtained * @param <E> The {@code Enum} type for the statistics * * @return the value, possibly null, for {@code statId} about {@code ehcache} */ private static <E extends Enum<E>> Number getStatistic(final OperationStatistic<E> operationStatistic, final E statId) { if (operationStatistic != null) { final ValueStatistic<Long> valueStatistic = operationStatistic.statistic(statId); return (valueStatistic == null ? null : valueStatistic.value()); } return null; }
@Override public long getPuts() { return put.sum(EnumSet.of(StoreOperationOutcomes.PutOutcome.PUT)) + putIfAbsent.sum(EnumSet.of(StoreOperationOutcomes.PutIfAbsentOutcome.PUT)) + compute.sum(EnumSet.of(StoreOperationOutcomes.ComputeOutcome.PUT)) + computeIfAbsent.sum(EnumSet.of(StoreOperationOutcomes.ComputeIfAbsentOutcome.PUT)) + replace.sum(EnumSet.of(StoreOperationOutcomes.ReplaceOutcome.REPLACED)) + conditionalReplace.sum(EnumSet.of(StoreOperationOutcomes.ConditionalReplaceOutcome.REPLACED)) - compensatingCounters.puts; }
@Override public long getMisses() { return get.sum(EnumSet.of(TierOperationOutcomes.GetOutcome.MISS)) + putIfAbsent.sum(EnumSet.of(StoreOperationOutcomes.PutIfAbsentOutcome.PUT)) + replace.sum(EnumSet.of(StoreOperationOutcomes.ReplaceOutcome.MISS)) + computeIfAbsent.sum(EnumSet.of(StoreOperationOutcomes.ComputeIfAbsentOutcome.NOOP)) + conditionalReplace.sum(EnumSet.of(StoreOperationOutcomes.ConditionalReplaceOutcome.MISS)) + conditionalRemove.sum(EnumSet.of(StoreOperationOutcomes.ConditionalRemoveOutcome.MISS)) - compensatingCounters.misses; }
@Override public long getEvictions() { return eviction.sum(EnumSet.of(TierOperationOutcomes.EvictionOutcome.SUCCESS)) - compensatingCounters.evictions; }
@Override public long getHits() { return get.sum(EnumSet.of(TierOperationOutcomes.GetOutcome.HIT)) + putIfAbsent.sum(EnumSet.of(StoreOperationOutcomes.PutIfAbsentOutcome.HIT)) + replace.sum(EnumSet.of(StoreOperationOutcomes.ReplaceOutcome.REPLACED)) + compute.sum(EnumSet.of(StoreOperationOutcomes.ComputeOutcome.HIT)) + computeIfAbsent.sum(EnumSet.of(StoreOperationOutcomes.ComputeIfAbsentOutcome.HIT)) + conditionalReplace.sum(EnumSet.of(StoreOperationOutcomes.ConditionalReplaceOutcome.REPLACED)) + conditionalRemove.sum(EnumSet.of(StoreOperationOutcomes.ConditionalRemoveOutcome.REMOVED)) - compensatingCounters.hits; }
private long getMisses() { return getBulkCount(BulkOps.GET_ALL_MISS) + get.sum(EnumSet.of(GetOutcome.MISS)) + putIfAbsent.sum(EnumSet.of(PutIfAbsentOutcome.PUT)) + replace.sum(EnumSet.of(ReplaceOutcome.MISS_NOT_PRESENT)) + conditionalRemove.sum(EnumSet.of(ConditionalRemoveOutcome.FAILURE_KEY_MISSING)); }
private long getHits() { return getBulkCount(BulkOps.GET_ALL_HITS) + get.sum(EnumSet.of(GetOutcome.HIT)) + putIfAbsent.sum(EnumSet.of(PutIfAbsentOutcome.HIT)) + replace.sum(EnumSet.of(ReplaceOutcome.HIT, ReplaceOutcome.MISS_PRESENT)) + conditionalRemove.sum(EnumSet.of(ConditionalRemoveOutcome.SUCCESS, ConditionalRemoveOutcome.FAILURE_KEY_PRESENT)); }