json.put("Logging Enabled", config.getLogging()); json.put("Terracotta Configuration", config.getTerracottaConfiguration()); json.put("Cache Writer Configuration", config.getCacheWriterConfiguration()); json.put("Cache Loader Configurations", config.getCacheLoaderConfigurations()); json.put("Frozen", config.isFrozen());
/** * Create the write behind queue manager with queues created via the passed in {@link WriteBehindQueueFactory} * * @param config configuration for the cache this write behind queue manager is working with * @param queueFactory factory used to create the write behind queues. */ protected WriteBehindQueueManager(CacheConfiguration config, WriteBehindQueueFactory queueFactory) { CacheWriterConfiguration cacheWriterConfiguration = config.getCacheWriterConfiguration(); int writeBehindConcurrency = cacheWriterConfiguration.getWriteBehindConcurrency(); for (int i = 0; i < writeBehindConcurrency; i++) { this.queues.add(queueFactory.createQueue(i, config)); } }
/** * {@inheritDoc} */ @Override public int getWriterConcurrency() { return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindConcurrency(); }
/** * {@inheritDoc} */ public int getWriterMaxQueueSize() { return ehcache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindMaxQueueSize(); }
/** * {@inheritDoc} */ @Override public int getWriterMaxQueueSize() { return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindMaxQueueSize(); }
/** * A factory method to register cache writers * * @param cacheConfiguration the cache configuration * @param cache the cache * @param loader */ private static void registerCacheWriter(CacheConfiguration cacheConfiguration, Ehcache cache, ClassLoader loader) { CacheWriterConfiguration config = cacheConfiguration.getCacheWriterConfiguration(); if (config != null) { CacheWriter cacheWriter = createCacheWriter(config, cache, loader); cache.registerCacheWriter(cacheWriter); } }
private static void addCacheWriterConfigurationElement(NodeElement element, CacheConfiguration cacheConfiguration) { CacheWriterConfiguration cacheWriterConfiguration = cacheConfiguration.getCacheWriterConfiguration(); if (cacheWriterConfiguration != null && !CacheConfiguration.DEFAULT_CACHE_WRITER_CONFIGURATION.equals(cacheWriterConfiguration)) { element.addChildElement(new CacheWriterConfigurationElement(element, cacheWriterConfiguration)); } }
/** * {@inheritDoc} */ public int getWriterMaxQueueSize() { int result = 0; for (String cacheName : getCacheNames()) { Ehcache cache = cacheManager.getEhcache(cacheName); if (cache != null) { CacheWriterConfiguration writerConfig = cache.getCacheConfiguration().getCacheWriterConfiguration(); result += (writerConfig.getWriteBehindMaxQueueSize() * writerConfig.getWriteBehindConcurrency()); } } return result; }
/** * {@inheritDoc} */ public void init(Cache cache) throws CacheException { CacheWriter cacheWriter = cache.getRegisteredCacheWriter(); if (null == cacheWriter) { throw new CacheException("No cache writer was registered for cache " + cache.getName()); } if (cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteCoalescing()) { writeBehind.setOperationsFilter(new CoalesceKeysFilter()); } writeBehind.start(cacheWriter); }
/** * Create a new write behind queue. * * @param config the configuration for the queue */ public AbstractWriteBehindQueue(CacheConfiguration config) { this.stopping = false; this.stopped = true; this.cacheName = config.getName(); // making a copy of the configuration locally to ensure that it will not be changed at runtime final CacheWriterConfiguration cacheWriterConfig = config.getCacheWriterConfiguration(); this.minWriteDelayMs = cacheWriterConfig.getMinWriteDelay() * MS_IN_SEC; this.maxWriteDelayMs = cacheWriterConfig.getMaxWriteDelay() * MS_IN_SEC; this.rateLimitPerSecond = cacheWriterConfig.getRateLimitPerSecond(); this.maxQueueSize = cacheWriterConfig.getWriteBehindMaxQueueSize(); this.writeBatching = cacheWriterConfig.getWriteBatching(); this.writeBatchSize = cacheWriterConfig.getWriteBatchSize(); this.retryAttempts = cacheWriterConfig.getRetryAttempts(); this.retryAttemptDelaySeconds = cacheWriterConfig.getRetryAttemptDelaySeconds(); this.processingThread = new Thread(new ProcessingThread(), cacheName + " write-behind"); this.processingThread.setDaemon(true); }
elementFromStore = compoundStore.removeWithWriter(key, cacheWriterManager); } catch (CacheWriterManagerException e) { if (configuration.getCacheWriterConfiguration().getNotifyListenersOnException()) { notifyRemoveInternalListeners(key, expiry, notifyListeners, doNotNotifyCacheReplicators, elementFromStore);
@Override public WriteBehind createWriteBehind(Ehcache cache) { final CacheWriterConfiguration config = cache.getCacheConfiguration().getCacheWriterConfiguration(); final AsyncConfig asyncConfig = new WriteBehindAsyncConfig(config.getMinWriteDelay() * 1000, config.getMaxWriteDelay() * 1000, config.getWriteBatching(), config.getWriteBatchSize(), cache.getCacheConfiguration() .getTerracottaConfiguration().isSynchronousWrites(), config.getRetryAttempts(), config.getRetryAttemptDelaySeconds() * 1000, config.getRateLimitPerSecond(), config.getWriteBehindMaxQueueSize()); final AsyncCoordinator asyncCoordinator = asyncCoordinatorFactory.getOrCreateAsyncCoordinator(cache, asyncConfig); return new AsyncWriteBehind(asyncCoordinator, config.getWriteBehindConcurrency()); }
} catch (StoreUpdateException e) { elementExists = e.isUpdate(); notifyListeners = configuration.getCacheWriterConfiguration().getNotifyListenersOnException(); RuntimeException cause = e.getCause(); if (cause instanceof CacheWriterManagerException) {
/** * {@inheritDoc} */ @Override public int getWriterConcurrency() { return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindConcurrency(); }
/** * {@inheritDoc} */ public int getWriterMaxQueueSize() { return ehcache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindMaxQueueSize(); }
/** * {@inheritDoc} */ public int getWriterMaxQueueSize() { return ehcache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindMaxQueueSize(); }
/** * {@inheritDoc} */ @Override public int getWriterMaxQueueSize() { return cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteBehindMaxQueueSize(); }
this.cacheWriterManager = configuration.getCacheWriterConfiguration().getWriteMode().createWriterManager(this, compoundStore); StatisticsManager.associate(this).withChild(cacheWriterManager); cacheStatus.changeState(Status.STATUS_ALIVE);
private static void addCacheWriterConfigurationElement(NodeElement element, CacheConfiguration cacheConfiguration) { CacheWriterConfiguration cacheWriterConfiguration = cacheConfiguration.getCacheWriterConfiguration(); if (cacheWriterConfiguration != null && !CacheConfiguration.DEFAULT_CACHE_WRITER_CONFIGURATION.equals(cacheWriterConfiguration)) { element.addChildElement(new CacheWriterConfigurationElement(element, cacheWriterConfiguration)); } }
private static void addCacheWriterConfigurationElement(NodeElement element, CacheConfiguration cacheConfiguration) { CacheWriterConfiguration cacheWriterConfiguration = cacheConfiguration.getCacheWriterConfiguration(); if (cacheWriterConfiguration != null && !CacheConfiguration.DEFAULT_CACHE_WRITER_CONFIGURATION.equals(cacheWriterConfiguration)) { element.addChildElement(new CacheWriterConfigurationElement(element, cacheWriterConfiguration)); } }