public NonBatchingLocalHeapWriteBehindQueue(ExecutionService executionService, String defaultThreadPool, WriteBehindConfiguration config, CacheLoaderWriter<K, V> cacheLoaderWriter) { super(cacheLoaderWriter); this.cacheLoaderWriter = cacheLoaderWriter; this.executorQueue = new LinkedBlockingQueue<>(config.getMaxQueueSize()); if (config.getThreadPoolAlias() == null) { this.executor = executionService.getOrderedExecutor(defaultThreadPool, executorQueue); } else { this.executor = executionService.getOrderedExecutor(config.getThreadPoolAlias(), executorQueue); } }
public BatchingLocalHeapWriteBehindQueue(ExecutionService executionService, String defaultThreadPool, WriteBehindConfiguration config, CacheLoaderWriter<K, V> cacheLoaderWriter) { super(cacheLoaderWriter); this.cacheLoaderWriter = cacheLoaderWriter; BatchingConfiguration batchingConfig = config.getBatchingConfiguration(); this.maxWriteDelayMs = batchingConfig.getMaxDelayUnit().toMillis(batchingConfig.getMaxDelay()); this.batchSize = batchingConfig.getBatchSize(); this.coalescing = batchingConfig.isCoalescing(); this.executorQueue = new LinkedBlockingQueue<>(config.getMaxQueueSize() / batchSize); if (config.getThreadPoolAlias() == null) { this.executor = executionService.getOrderedExecutor(defaultThreadPool, executorQueue); } else { this.executor = executionService.getOrderedExecutor(config.getThreadPoolAlias(), executorQueue); } if (config.getThreadPoolAlias() == null) { this.scheduledExecutor = executionService.getScheduledExecutor(defaultThreadPool); } else { this.scheduledExecutor = executionService.getScheduledExecutor(config.getThreadPoolAlias()); } }
@Override protected <K, V> ClusteredStore<K, V> createStore(Configuration<K, V> storeConfig, OperationsCodec<K, V> codec, ChainResolver<K, V> resolver, TimeSource timeSource, boolean useLoaderInAtomics, Object[] serviceConfigs) { WriteBehindConfiguration writeBehindConfiguration = findSingletonAmongst(WriteBehindConfiguration.class, serviceConfigs); if (writeBehindConfiguration != null) { ExecutorService executorService = executionService.getOrderedExecutor(writeBehindConfiguration.getThreadPoolAlias(), new LinkedBlockingQueue<>()); return new ClusteredWriteBehindStore<>(storeConfig, codec, resolver, timeSource, storeConfig.getCacheLoaderWriter(), executorService); } throw new AssertionError(); }
@Test public void testDefaultBatchedThreadPoolAlias() { assertThat(newBatchedWriteBehindConfiguration(1, TimeUnit.MINUTES, 10).build().getThreadPoolAlias(), nullValue()); }
@Test public void testDefaultUnBatchedThreadPoolAlias() { assertThat(newUnBatchedWriteBehindConfiguration().build().getThreadPoolAlias(), nullValue()); }
config -> { CacheLoaderWriterType.WriteBehind writeBehind = new CacheLoaderWriterType.WriteBehind() .withThreadPool(config.getThreadPoolAlias()) .withConcurrency(BigInteger.valueOf(config.getConcurrency())) .withSize(BigInteger.valueOf(config.getMaxQueueSize()));
public NonBatchingLocalHeapWriteBehindQueue(ExecutionService executionService, String defaultThreadPool, WriteBehindConfiguration config, CacheLoaderWriter<K, V> cacheLoaderWriter) { super(cacheLoaderWriter); this.cacheLoaderWriter = cacheLoaderWriter; this.executorQueue = new LinkedBlockingQueue<>(config.getMaxQueueSize()); if (config.getThreadPoolAlias() == null) { this.executor = executionService.getOrderedExecutor(defaultThreadPool, executorQueue); } else { this.executor = executionService.getOrderedExecutor(config.getThreadPoolAlias(), executorQueue); } }
public BatchingLocalHeapWriteBehindQueue(ExecutionService executionService, String defaultThreadPool, WriteBehindConfiguration config, CacheLoaderWriter<K, V> cacheLoaderWriter) { super(cacheLoaderWriter); this.cacheLoaderWriter = cacheLoaderWriter; BatchingConfiguration batchingConfig = config.getBatchingConfiguration(); this.maxWriteDelayMs = batchingConfig.getMaxDelayUnit().toMillis(batchingConfig.getMaxDelay()); this.batchSize = batchingConfig.getBatchSize(); this.coalescing = batchingConfig.isCoalescing(); this.executorQueue = new LinkedBlockingQueue<>(config.getMaxQueueSize() / batchSize); if (config.getThreadPoolAlias() == null) { this.executor = executionService.getOrderedExecutor(defaultThreadPool, executorQueue); } else { this.executor = executionService.getOrderedExecutor(config.getThreadPoolAlias(), executorQueue); } if (config.getThreadPoolAlias() == null) { this.scheduledExecutor = executionService.getScheduledExecutor(defaultThreadPool); } else { this.scheduledExecutor = executionService.getScheduledExecutor(config.getThreadPoolAlias()); } }
config -> { CacheLoaderWriterType.WriteBehind writeBehind = new CacheLoaderWriterType.WriteBehind() .withThreadPool(config.getThreadPoolAlias()) .withConcurrency(BigInteger.valueOf(config.getConcurrency())) .withSize(BigInteger.valueOf(config.getMaxQueueSize()));