/** * 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); }
@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()); }
addAttribute(new SimpleNodeAttribute("notifyListenersOnException", cacheWriterConfiguration.getNotifyListenersOnException()) .optional(true).defaultValue(CacheWriterConfiguration.DEFAULT_NOTIFY_LISTENERS_ON_EXCEPTION)); addAttribute(new SimpleNodeAttribute("retryAttemptDelaySeconds", cacheWriterConfiguration.getRetryAttemptDelaySeconds()).optional( true).defaultValue(CacheWriterConfiguration.DEFAULT_RETRY_ATTEMPT_DELAY_SECONDS)); addAttribute(new SimpleNodeAttribute("writeBehindConcurrency", cacheWriterConfiguration.getWriteBehindConcurrency()).optional(
/** * 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); }
/** * 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); }
/** * 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); }
public WriteBehind createWriteBehind(Ehcache cache) { ConcurrentMap<String, ConcurrentMap<String, AsyncCoordinator>> asyncCoordinatorRoot = getAsyncCoordinatorRoot(); String cacheMgrName = cache.getCacheManager().getName(); if (!cache.getCacheManager().isNamed()) { cacheMgrName = DEFAULT_CACHE_MANAGER_NAME; } ConcurrentMap<String, AsyncCoordinator> asyncCoordinatorMap = getOrCreateAsyncCoordinatorMap(asyncCoordinatorRoot, cacheMgrName); 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()); AsyncCoordinator asyncCoordinator = getOrCreateAsyncCoordinator(asyncCoordinatorMap, cache, asyncConfig); return new AsyncWriteBehind(asyncCoordinator, cache, getSingletonDsoSerializationStrategy()); }
addAttribute(new SimpleNodeAttribute("notifyListenersOnException", cacheWriterConfiguration.getNotifyListenersOnException()) .optional(true).defaultValue(CacheWriterConfiguration.DEFAULT_NOTIFY_LISTENERS_ON_EXCEPTION)); addAttribute(new SimpleNodeAttribute("retryAttemptDelaySeconds", cacheWriterConfiguration.getRetryAttemptDelaySeconds()).optional( true).defaultValue(CacheWriterConfiguration.DEFAULT_RETRY_ATTEMPT_DELAY_SECONDS)); addAttribute(new SimpleNodeAttribute("writeBehindConcurrency", cacheWriterConfiguration.getWriteBehindConcurrency()).optional(
addAttribute(new SimpleNodeAttribute("notifyListenersOnException", cacheWriterConfiguration.getNotifyListenersOnException()) .optional(true).defaultValue(CacheWriterConfiguration.DEFAULT_NOTIFY_LISTENERS_ON_EXCEPTION)); addAttribute(new SimpleNodeAttribute("retryAttemptDelaySeconds", cacheWriterConfiguration.getRetryAttemptDelaySeconds()).optional( true).defaultValue(CacheWriterConfiguration.DEFAULT_RETRY_ATTEMPT_DELAY_SECONDS)); addAttribute(new SimpleNodeAttribute("writeBehindConcurrency", cacheWriterConfiguration.getWriteBehindConcurrency()).optional(
addAttribute(new SimpleNodeAttribute("notifyListenersOnException", cacheWriterConfiguration.getNotifyListenersOnException()) .optional(true).defaultValue(CacheWriterConfiguration.DEFAULT_NOTIFY_LISTENERS_ON_EXCEPTION)); addAttribute(new SimpleNodeAttribute("retryAttemptDelaySeconds", cacheWriterConfiguration.getRetryAttemptDelaySeconds()).optional( true).defaultValue(CacheWriterConfiguration.DEFAULT_RETRY_ATTEMPT_DELAY_SECONDS)); addAttribute(new SimpleNodeAttribute("writeBehindConcurrency", cacheWriterConfiguration.getWriteBehindConcurrency()).optional(