/** * Set the ThreadPoolExecutor's maximum pool size. * Default is {@code Integer.MAX_VALUE}. * <p><b>This setting can be modified at runtime, for example through JMX.</b> */ public void setMaxPoolSize(int maxPoolSize) { synchronized (this.poolSizeMonitor) { this.maxPoolSize = maxPoolSize; if (this.threadPoolExecutor != null) { this.threadPoolExecutor.setMaximumPoolSize(maxPoolSize); } } }
/** * Set the ThreadPoolExecutor's maximum pool size. * Default is {@code Integer.MAX_VALUE}. * <p><b>This setting can be modified at runtime, for example through JMX.</b> */ public void setMaxPoolSize(int maxPoolSize) { synchronized (this.poolSizeMonitor) { this.maxPoolSize = maxPoolSize; if (this.threadPoolExecutor != null) { this.threadPoolExecutor.setMaximumPoolSize(maxPoolSize); } } }
@Override public void setMaxPoolSize(int newMaxSize) { pool.setMaximumPoolSize(newMaxSize); }
public TP setThreadPoolMaxThreads(int size) { thread_pool_max_threads=size; if(thread_pool instanceof ThreadPoolExecutor) ((ThreadPoolExecutor)thread_pool).setMaximumPoolSize(size); return this; }
/** * Sets the max number of threads the channel will use for processing messages. The channel * will automatically allocate new worker threads as the queue size grows, up to the defined * maximum. This lets the channel meet higher concurrency needs, but prevents too many threads * from being allocated, which decreases overall system performance. * * @param maxThreadCount the max number of threads that can be used by the channel. */ public void setMaxThreadCount(int maxThreadCount) { executor.setMaximumPoolSize(maxThreadCount); }
/** * @param numThreads * the maximum number of threads that will be started to download images in parallel */ public void setThreadPoolSize(int numThreads) { executor.setMaximumPoolSize(numThreads); }
public void setMaximumPoolSize(final int size) { if (size > getCorePoolSize()) { super.setMaximumPoolSize(size); super.setCorePoolSize(size); } else { super.setCorePoolSize(size); super.setMaximumPoolSize(size); } }
/** * Set the number of threads to be used for processing connections. Defaults * to Integer.MAX_SIZE. Set this value to be lower to reduce the * number of simultaneous connection attempts. If not set then the maximum number of * threads will generally be controlled by the transport maxConnections setting: * {@link TcpTransportServer#setMaximumConnections(int)}. *<p> * Note that this setter controls two thread pools because connection attempts * require 1 thread to start processing the connection and another thread to read from the * socket and to detect the protocol. Two threads are needed because some transports * block on socket read so the first thread needs to be able to abort the second thread on timeout. * Therefore this setting will set each thread pool to the size passed in essentially giving * 2 times as many potential threads as the value set. *<p> * Both thread pools will close idle threads after a period of time * essentially allowing the thread pools to grow and shrink dynamically based on load. * * @see {@link TcpTransportServer#setMaximumConnections(int)}. * @param maxConnectionThreadPoolSize */ public void setMaxConnectionThreadPoolSize(int maxConnectionThreadPoolSize) { this.maxConnectionThreadPoolSize = maxConnectionThreadPoolSize; newConnectionExecutor.setCorePoolSize(maxConnectionThreadPoolSize); newConnectionExecutor.setMaximumPoolSize(maxConnectionThreadPoolSize); protocolDetectionExecutor.setCorePoolSize(maxConnectionThreadPoolSize); protocolDetectionExecutor.setMaximumPoolSize(maxConnectionThreadPoolSize); }
public void setWorkThread(int workThread) { if (workThread == 0) { throw new IllegalArgumentException("workThread can not be zero!"); } threadPoolExecutor.setMaximumPoolSize(workThread); threadPoolExecutor.setCorePoolSize(workThread); LOGGER.info("workThread update to {}", workThread); }
public void setWorkThread(int workThread) { if (workThread == 0) { throw new IllegalArgumentException("workThread can not be zero!"); } threadPoolExecutor.setMaximumPoolSize(workThread); threadPoolExecutor.setCorePoolSize(workThread); LOGGER.info("workThread update to {}", workThread); }
public void setMaxThreads(int size) {condSet(p -> p.setMaximumPoolSize(size));} public long getKeepAliveTime() {return condGet(p -> p.getKeepAliveTime(TimeUnit.MILLISECONDS), 0L);}
largeThreads); if(this.longCompactions.getCorePoolSize() < largeThreads) { this.longCompactions.setMaximumPoolSize(largeThreads); this.longCompactions.setCorePoolSize(largeThreads); } else { this.longCompactions.setCorePoolSize(largeThreads); this.longCompactions.setMaximumPoolSize(largeThreads); smallThreads); if(this.shortCompactions.getCorePoolSize() < smallThreads) { this.shortCompactions.setMaximumPoolSize(smallThreads); this.shortCompactions.setCorePoolSize(smallThreads); } else { this.shortCompactions.setCorePoolSize(smallThreads); this.shortCompactions.setMaximumPoolSize(smallThreads); splitThreads); if(this.splits.getCorePoolSize() < splitThreads) { this.splits.setMaximumPoolSize(splitThreads); this.splits.setCorePoolSize(splitThreads); } else { this.splits.setCorePoolSize(splitThreads); this.splits.setMaximumPoolSize(splitThreads);
threadPoolExecutor.setCorePoolSize(threads); if (core == max) { threadPoolExecutor.setMaximumPoolSize(threads); threadPoolExecutor.setMaximumPoolSize(threads); if (core == max) { threadPoolExecutor.setCorePoolSize(threads);
threadPoolExecutor.setCorePoolSize(threads); if (core == max) { threadPoolExecutor.setMaximumPoolSize(threads); threadPoolExecutor.setMaximumPoolSize(threads); if (core == max) { threadPoolExecutor.setCorePoolSize(threads);
private ThreadPoolExecutor disableHandlers(RpcScheduler scheduler) { ThreadPoolExecutor rpcExecutor=null; try { Field ExecutorField = scheduler.getClass().getDeclaredField("executor"); ExecutorField.setAccessible(true); scheduler.start(); rpcExecutor = (ThreadPoolExecutor) ExecutorField.get(scheduler); rpcExecutor.setMaximumPoolSize(1); rpcExecutor.allowCoreThreadTimeOut(true); rpcExecutor.setCorePoolSize(0); rpcExecutor.setKeepAliveTime(1, TimeUnit.MICROSECONDS); // Wait for 2 seconds, so that idle threads will die Thread.sleep(2000); } catch (NoSuchFieldException e) { LOG.error("No such field exception:"+e); } catch (IllegalAccessException e) { LOG.error("Illegal access exception:"+e); } catch (InterruptedException e) { LOG.error("Interrupted exception:"+e); } return rpcExecutor; }
private void touchConfig() { final int dynamicCoreSize = properties.coreSize().get(); final int configuredMaximumSize = properties.maximumSize().get(); int dynamicMaximumSize = properties.actualMaximumSize(); final boolean allowSizesToDiverge = properties.getAllowMaximumSizeToDivergeFromCoreSize().get(); boolean maxTooLow = false; if (allowSizesToDiverge && configuredMaximumSize < dynamicCoreSize) { //if user sets maximum < core (or defaults get us there), we need to maintain invariant of core <= maximum dynamicMaximumSize = dynamicCoreSize; maxTooLow = true; } // In JDK 6, setCorePoolSize and setMaximumPoolSize will execute a lock operation. Avoid them if the pool size is not changed. if (threadPool.getCorePoolSize() != dynamicCoreSize || (allowSizesToDiverge && threadPool.getMaximumPoolSize() != dynamicMaximumSize)) { if (maxTooLow) { logger.error("Hystrix ThreadPool configuration for : " + metrics.getThreadPoolKey().name() + " is trying to set coreSize = " + dynamicCoreSize + " and maximumSize = " + configuredMaximumSize + ". Maximum size will be set to " + dynamicMaximumSize + ", the coreSize value, since it must be equal to or greater than the coreSize value"); } threadPool.setCorePoolSize(dynamicCoreSize); threadPool.setMaximumPoolSize(dynamicMaximumSize); } threadPool.setKeepAliveTime(properties.keepAliveTimeMinutes().get(), TimeUnit.MINUTES); }
addConnectionExecutor.setMaximumPoolSize(Runtime.getRuntime().availableProcessors()); addConnectionExecutor.setCorePoolSize(Runtime.getRuntime().availableProcessors()); addConnectionExecutor.setMaximumPoolSize(1); addConnectionExecutor.setCorePoolSize(1);
|| (queue instanceof SynchronousQueue && queueType == QueueType.DIRECT)) { executor.setCorePoolSize(coverageAccess.getCorePoolSize()); executor.setMaximumPoolSize(coverageAccess.getMaxPoolSize()); executor.setKeepAliveTime( coverageAccess.getKeepAliveTime(), TimeUnit.MILLISECONDS);
( (ThreadPoolExecutor) executorFilter.getExecutor()).setMaximumPoolSize( ( configuration.getMaxThreadPoolSize() ) );
@Override public void setMaxThreads(int threads) { if (_budget!=null) _budget.check(threads); _executor.setCorePoolSize(threads); _executor.setMaximumPoolSize(threads); }