public CompoundCachingTier(HigherCachingTier<K, V> higher, final LowerCachingTier<K, V> lower) { this.higher = higher; this.lower = lower; this.higher.setInvalidationListener((key, valueHolder) -> { try { CompoundCachingTier.this.lower.installMapping(key, k -> valueHolder); } catch (StoreAccessException cae) { notifyInvalidation(key, valueHolder); LOGGER.warn("Error overflowing '{}' into lower caching tier {}", key, lower, cae); } }); StatisticsManager.associate(higher).withParent(this); StatisticsManager.associate(lower).withParent(this); }
protected <T extends Serializable> void registerStatistic(String name, StatisticType type, Set<String> tags, Supplier<T> valueSupplier) { StatisticsManager.createPassThroughStatistic(this, name, tags, type, valueSupplier); }
private void unRegisterPoolStatistics(ResourcePageSource pageSource) { TreeNode node = StatisticsManager.nodeFor(pageSource); if(node != null) { node.clean(); } }
private void registerStatistic(Object context, String name, String observerName, String tag, String propertyKey, ValueStatistic<Number> source) { Map<String, Object> properties = new HashMap<>(); properties.put("discriminator", tag); properties.put(propertyKey, name); StatisticsManager.createPassThroughStatistic(context, observerName, tags(tag, "tier"), properties, source); }
@Before public void before() { CacheConfiguration<Long, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, heap(10)) .add(new StoreStatisticsConfiguration(true)) // explicitly enable statistics .build(); cacheManager = CacheManagerBuilder.newCacheManagerBuilder() .withCache("aCache", cacheConfiguration) .build(true); cache = cacheManager.getCache("aCache", Long.class, String.class); StatisticsManager.createPassThroughStatistic(cache, "test", tags(), properties("myproperty=myvalue"), StatisticType.COUNTER, () -> 0); cache.get(1L); }
@SuppressWarnings("unchecked") private OperationStatistic<StoreOperationOutcomes.ExpirationOutcome> getExpirationStatistic(Store<?, ?> store) { StatisticsManager statisticsManager = new StatisticsManager(); statisticsManager.root(store); TreeNode treeNode = statisticsManager.queryForSingleton(QueryBuilder.queryBuilder() .descendants() .filter(org.terracotta.context.query.Matchers.context( org.terracotta.context.query.Matchers.allOf(org.terracotta.context.query.Matchers.identifier(org.terracotta.context.query.Matchers .subclassOf(OperationStatistic.class)), org.terracotta.context.query.Matchers.attributes(org.terracotta.context.query.Matchers.hasAttribute("name", "expiration"))))) .build()); return (OperationStatistic<StoreOperationOutcomes.ExpirationOutcome>) treeNode.getContext().attributes().get("this"); }
public static <T extends Enum<T>> OperationObserver<T> createOperationStatistic(Object context, String name, Set<String> tags, Map<String, ? extends Object> properties, Class<T> resultType) { OperationStatistic<T> stat = createOperationStatistic(name, tags, properties, resultType); associate(context).withChild(stat); return stat; }
/** * Builds the. * * @return the operation observer */ public OperationObserver<T> build() { if (context == null || name == null) { throw new IllegalStateException(); } else { return StatisticsManager.createOperationStatistic(context, name, tags, type); } } }
/** * Instantiates a new statistics placeholder. * * @param ehcache the ehcache * @param executor the executor */ public StatisticsGateway(Ehcache ehcache, ScheduledExecutorService executor) { StatisticsManager statsManager = new StatisticsManager(); statsManager.root(ehcache); this.assocCacheName = ehcache.getName(); ManagementRESTServiceConfiguration mRest = null; if (ehcache != null && ehcache.getCacheManager() != null && ehcache.getCacheManager().getConfiguration() != null) { mRest = ehcache.getCacheManager().getConfiguration().getManagementRESTService(); } this.extended = new ExtendedStatisticsImpl(statsManager, executor, DEFAULT_TIME_TO_DISABLE_MINS, TimeUnit.MINUTES, getProperSampleHistorySize(mRest), getProperSampleIntervalSeconds(mRest), getProperSampleSearchIntervalSeconds(mRest)); this.core = new CoreStatisticsImpl(extended); }
/** * Creates a pool participant * @param pooledBasedBackEnd the backend this participant represents */ public PoolParticipant(final PooledBasedBackEnd<Object, Object> pooledBasedBackEnd) { this.pooledBasedBackEnd = pooledBasedBackEnd; OperationStatistic<GetOutcome> getStatistic = StatisticsManager.getOperationStatisticFor(pooledBasedBackEnd.getObserver); getStatistic.addDerivedStatistic(new OperationResultFilter<GetOutcome>(EnumSet.of(GetOutcome.HIT), hitRate)); getStatistic.addDerivedStatistic(new OperationResultFilter<GetOutcome>(EnumSet.of(GetOutcome.MISS), missRate)); }
this.installMappingObserver= createObserver("installMapping", LowerCachingTierOperationsOutcome.InstallMappingOutcome.class, true); Set<String> tags = tags(getStatisticsTag(), "tier"); registerStatistic("allocatedMemory", GAUGE, tags, EhcacheOffHeapBackingMap::allocatedMemory); registerStatistic("occupiedMemory", GAUGE, tags, EhcacheOffHeapBackingMap::occupiedMemory);
public static <T extends Enum<T>> OperationObserver<T> createOperationStatistic(Object context, String name, Set<String> tags, Map<String, ? extends Object> properties, Class<T> resultType) { OperationStatistic<T> stat = createOperationStatistic(name, tags, properties, resultType); associate(context).withChild(stat); return stat; }
public static <T extends Enum<T>> OperationObserver<T> createOperationStatistic(Object context, String name, Set<String> tags, Class<T> eventTypes) { return createOperationStatistic(context, name, tags, Collections.<String, Object>emptyMap(), eventTypes); }
/** * Instantiates a new statistics placeholder. * * @param ehcache the ehcache * @param executor the executor */ public StatisticsGateway(Ehcache ehcache, ScheduledExecutorService executor) { StatisticsManager statsManager = new StatisticsManager(); statsManager.root(ehcache); this.assocCacheName = ehcache.getName(); ManagementRESTServiceConfiguration mRest = null; if (ehcache != null && ehcache.getCacheManager() != null && ehcache.getCacheManager().getConfiguration() != null) { mRest = ehcache.getCacheManager().getConfiguration().getManagementRESTService(); } this.extended = new ExtendedStatisticsImpl(statsManager, executor, DEFAULT_TIME_TO_DISABLE_MINS, TimeUnit.MINUTES, getProperSampleHistorySize(mRest), getProperSampleIntervalSeconds(mRest), getProperSampleSearchIntervalSeconds(mRest)); this.core = new CoreStatisticsImpl(extended); }
private Participant() { OperationStatistic<GetOutcome> getStatistic = StatisticsManager.getOperationStatisticFor(getObserver); getStatistic.addDerivedStatistic(new OperationResultFilter<GetOutcome>(EnumSet.of(GetOutcome.HIT), hitRate)); getStatistic.addDerivedStatistic(new OperationResultFilter<GetOutcome>(EnumSet.of(GetOutcome.MISS), missRate)); }
this.installMappingObserver= createObserver("installMapping", LowerCachingTierOperationsOutcome.InstallMappingOutcome.class, true); Set<String> tags = tags(getStatisticsTag(), "tier"); registerStatistic("allocatedMemory", GAUGE, tags, EhcacheOffHeapBackingMap::allocatedMemory); registerStatistic("occupiedMemory", GAUGE, tags, EhcacheOffHeapBackingMap::occupiedMemory);
public TieredStore(CachingTier<K, V> cachingTier, AuthoritativeTier<K, V> authoritativeTier) { this.cachingTierRef = new AtomicReference<>(cachingTier); this.authoritativeTier = authoritativeTier; this.realCachingTier = cachingTier; this.noopCachingTier = new NoopCachingTier<>(authoritativeTier); this.realCachingTier.setInvalidationListener(TieredStore.this.authoritativeTier::flush); this.authoritativeTier.setInvalidationValve(new AuthoritativeTier.InvalidationValve() { @Override public void invalidateAll() throws StoreAccessException { invalidateAllInternal(); } @Override public void invalidateAllWithHash(long hash) throws StoreAccessException { cachingTier().invalidateAllWithHash(hash); } }); StatisticsManager.associate(cachingTier).withParent(this); StatisticsManager.associate(authoritativeTier).withParent(this); }
public static <T extends Enum<T>> OperationObserver<T> createOperationStatistic(Object context, String name, Set<String> tags, Map<String, ? extends Object> properties, Class<T> resultType) { OperationStatistic<T> stat = createOperationStatistic(name, tags, properties, resultType); associate(context).withChild(stat); return stat; }
public static <T extends Number> void createPassThroughStatistic(Object context, String name, Set<String> tags, Callable<T> source) { createPassThroughStatistic(context, name, tags, Collections.<String, Object>emptyMap(), source); }
private void unRegisterStoreStatistics(ServerStoreImpl store) { TreeNode node = StatisticsManager.nodeFor(store); if(node != null) { node.clean(); } }