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); }
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); }
@Override public void cacheAdded(String alias, Cache<?, ?> cache) { StatisticsManager.associate(cache).withParent(cacheManager); register(new CacheBinding(alias, cache)); }
/** * Creates a new {@code EhcacheBase} based on the provided parameters. * * @param runtimeConfiguration the cache configuration * @param store the store to use * @param eventDispatcher the event dispatcher * @param logger the logger */ EhcacheBase(EhcacheRuntimeConfiguration<K, V> runtimeConfiguration, Store<K, V> store, ResilienceStrategy<K, V> resilienceStrategy, CacheEventDispatcher<K, V> eventDispatcher, Logger logger, StatusTransitioner statusTransitioner) { this.store = store; runtimeConfiguration.addCacheConfigurationListener(store.getConfigurationChangeListeners()); StatisticsManager.associate(store).withParent(this); this.resilienceStrategy = resilienceStrategy; this.runtimeConfiguration = runtimeConfiguration; runtimeConfiguration.addCacheConfigurationListener(eventDispatcher.getConfigurationChangeListeners()); this.logger = logger; this.statusTransitioner = statusTransitioner; for (BulkOps bulkOp : BulkOps.values()) { bulkMethodEntries.put(bulkOp, new LongAdder()); } }
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(); }
/** * Construct a registered event listeners service * * @param cache the {@link Cache} * @param helper helper for getting the {@link net.sf.ehcache.store.Store} out of the {@link Cache} */ public RegisteredEventListeners(Ehcache cache, CacheStoreHelper helper) { //XXX this isn't really very nice StatisticsManager.associate(this).withParent(cache); this.cache = cache; this.helper = helper; }
/** * Instantiates a new cluster state statistics listener. * * @param cache the cache */ CacheClusterStateStatisticsListener(Cache cache) { this.cache = cache; StatisticsManager.associate(this).withParent(cache); }
/** * Constructor accepting the cache to be decorated * * @param underlyingCache */ public EhcacheDecoratorAdapter(Ehcache underlyingCache) { if (underlyingCache == null) { throw new NullPointerException("Underlying cache cannot be null"); } StatisticsManager.associate(this).withParent(underlyingCache); this.underlyingCache = underlyingCache; }
private void associateShadowCache(Ehcache shadow) { String parentCacheName = getParentCacheName(shadow); if (parentCacheName == null) { return; } Ehcache parent = initializingCaches.get(parentCacheName); if (parent == null) { parent = ehcaches.get(parentCacheName); } if (parent != null) { StatisticsManager.associate(shadow).withParent(parent); } }
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, Map<String, ? extends Object> properties, Callable<T> source) { PassThroughStatistic<T> stat = new PassThroughStatistic<T>(context, name, tags, properties, source); associate(context).withChild(stat); }
/** * Constructor. Create an extension with the specified config object against * the specified cache. * * @param config Configuration to use. * @param cache Cache to process against. */ public ScheduledRefreshCacheExtension(ScheduledRefreshConfiguration config, Ehcache cache) { if(cache == null) { throw new IllegalArgumentException("ScheduledRefresh Cache cannot be null"); } this.underlyingCache = cache; if(config == null) { throw new IllegalArgumentException("ScheduledRefresh extension config cannot be null"); } this.config = config; config.validate(); this.status = Status.STATUS_UNINITIALISED; StatisticsManager.associate(this).withParent(cache); }
private void doInit(Callable<TerracottaStore> clusteredStoreCreator) { // THIS IS HAND MADE CODE -- DO NOT GENERATED TerracottaStore delegateTemp = createTerracottaStore(clusteredStoreCreator); if (clusteredCacheInternalContext.getCacheLockProvider() instanceof NonStopCacheLockProvider) { ((NonStopCacheLockProvider) clusteredCacheInternalContext.getCacheLockProvider()) .init((CacheLockProvider) delegateTemp.getInternalContext()); } // create this to be sure that it's present on each node to receive clustered events, // even if this node is not sending out its events cacheEventListener = cache.getCacheManager().createTerracottaEventReplicator(cache); synchronized (this) { if (delegate == null) { this.delegate = delegateTemp; StatisticsManager.associate(this).withChild(delegateTemp); if (writeBehind != null && writeBehind instanceof NonStopWriteBehind) { ((NonStopWriteBehind) writeBehind).init(cache.getCacheManager().createTerracottaWriteBehind(cache)); } } } LOGGER.debug("Initialization Completed for Cache : {}", cache.getName()); }
public NonStopStoreWrapper(Callable<TerracottaStore> clusteredStoreCreator, ToolkitInstanceFactory toolkitInstanceFactory, Ehcache cache, TerracottaStoreInitializationService initializationService) { this.cache = cache; this.initializationService = initializationService; this.nonStop = toolkitInstanceFactory.getToolkit().getFeature(ToolkitFeatureType.NONSTOP); this.ehcacheNonStopConfiguration = cache.getCacheConfiguration().getTerracottaConfiguration() .getNonstopConfiguration(); this.toolkitNonStopConfiguration = new ToolkitNonStopExceptionOnTimeoutConfiguration(ehcacheNonStopConfiguration); this.bulkOpsToolkitNonStopConfiguration = new BulkOpsToolkitNonStopConfiguration(ehcacheNonStopConfiguration); Toolkit toolkit = toolkitInstanceFactory.getToolkit(); CacheLockProvider cacheLockProvider = createCacheLockProvider(toolkit, toolkitInstanceFactory); this.clusteredCacheInternalContext = new ClusteredCacheInternalContext(toolkit, cacheLockProvider); if (ehcacheNonStopConfiguration != null && ehcacheNonStopConfiguration.isEnabled()) { createStoreAsynchronously(toolkit, clusteredStoreCreator); } else { createStore(clusteredStoreCreator); } StatisticsManager.associate(this).withParent(cache); }
/** * Construct a registered event listeners service * * @param cache the {@link Cache} * @param helper helper for getting the {@link net.sf.ehcache.store.Store} out of the {@link Cache} */ public RegisteredEventListeners(Ehcache cache, CacheStoreHelper helper) { //XXX this isn't really very nice StatisticsManager.associate(this).withParent(cache); this.cache = cache; this.helper = helper; }
/** * Constructor accepting the cache to be decorated * * @param underlyingCache */ public EhcacheDecoratorAdapter(Ehcache underlyingCache) { StatisticsManager.associate(this).withParent(underlyingCache); this.underlyingCache = underlyingCache; }
/** * Instantiates a new cluster state statistics listener. * * @param cache the cache */ CacheClusterStateStatisticsListener(Cache cache) { this.cache = cache; StatisticsManager.associate(this).withParent(cache); }
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; }
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(); }