private boolean isThreadPoolExists(ThreadPools threadPools) { for (ThreadPool pool : threadPools.getThreadPool()) { String currPoolId = pool.getName(); if (currPoolId != null && currPoolId.equals(threadpool_id)) { return true; } } return false; }
public Object run(ThreadPool param) { param.setName(param.getThreadPoolId()); param.setThreadPoolId(null); if (param.getMinThreadPoolSize() == null || Integer.parseInt(param.getMinThreadPoolSize()) < 2) { param.setMinThreadPoolSize("2"); } return null; } }, pool);
public Object run(ThreadPools param) throws PropertyVetoException, TransactionFailure { ThreadPool newPool = param.createChild(ThreadPool.class); newPool.setName(threadpool_id); newPool.setMaxThreadPoolSize(maxthreadpoolsize); newPool.setMinThreadPoolSize(minthreadpoolsize); newPool.setMaxQueueSize(maxQueueSize); newPool.setIdleThreadTimeoutSeconds(idletimeout); param.getThreadPool().add(newPool); return newPool; } }, threadPools);
@Override public Object run(ThreadPools param) throws PropertyVetoException, TransactionFailure { final ThreadPool pool = param.createChild(ThreadPool.class); param.getThreadPool().add(pool); pool.setName("admin-thread-pool"); pool.setMaxThreadPoolSize("50"); pool.setMaxQueueSize("256"); return null; } }, threadPools);
protected ThreadPoolConfig configureThreadPoolConfig(final NetworkListener networkListener, final ThreadPool threadPool) { final int maxQueueSize = threadPool.getMaxQueueSize() == null ? Integer.MAX_VALUE : Integer.parseInt(threadPool.getMaxQueueSize()); final int minThreads = Integer.parseInt(threadPool.getMinThreadPoolSize()); final int maxThreads = Integer.parseInt(threadPool.getMaxThreadPoolSize()); final int timeout = Integer.parseInt(threadPool.getIdleThreadTimeoutSeconds()); final ThreadPoolConfig poolConfig = ThreadPoolConfig.defaultConfig(); poolConfig.setPoolName(networkListener.getName()); poolConfig.setCorePoolSize(minThreads); poolConfig.setMaxPoolSize(maxThreads); poolConfig.setQueueLimit(maxQueueSize); // we specify the classloader that loaded this class to ensure // we present the same initial classloader no matter what mode // GlassFish is being run in. // See http://java.net/jira/browse/GLASSFISH-19639 poolConfig.setInitialClassLoader(this.getClass().getClassLoader()); poolConfig.setKeepAliveTime(timeout < 0 ? Long.MAX_VALUE : timeout, TimeUnit.SECONDS); if (transactionTimeoutMillis > 0 && !Utils.isDebugVM()) { poolConfig.setTransactionTimeout(delayedExecutor, transactionTimeoutMillis, TimeUnit.MILLISECONDS); } return poolConfig; }
static public List<NetworkListener> findNetworkListeners(ThreadPool threadpool) { NetworkConfig config = threadpool.getParent().getParent(NetworkConfig.class); if (!Dom.unwrap(config).getProxyType().equals(NetworkConfig.class)) { config = Dom.unwrap(config).element("network-config").createProxy(); } List<NetworkListener> listeners = config.getNetworkListeners().getNetworkListener(); List<NetworkListener> refs = new ArrayList<NetworkListener>(); for (NetworkListener listener : listeners) { if (listener.getThreadPool().equals(threadpool.getName())) { refs.add(listener); } } return refs; }
String val = parser.getAttributeValue(i); if (attr.equals("max-thread-pool-size")) { t.setMaxThreadPoolSize(val); t.setIdleThreadTimeoutSeconds(val); t.setName(val);
if (tp != null) { try { maxThreadPoolSize = Integer.parseInt(tp.getMaxThreadPoolSize()); } catch (NumberFormatException ne) {
for (ThreadPool pool : list) { httpListenerFound |= HTTP_THREAD_POOL.equals(pool.getThreadPoolId()) || HTTP_THREAD_POOL.equals(pool.getName()); if (pool.getName() == null) { ConfigSupport.apply(new SingleConfigCode<ThreadPool>() { public Object run(ThreadPool param) {
if (tp.getName().equals(threadpool_id)) { pool = tp; List<NetworkListener> nwlsnrList = pool.findNetworkListeners(); for (NetworkListener nwlsnr : nwlsnrList) { if (pool.getName().equals(nwlsnr.getThreadPool())) { report.setMessage(localStrings.getLocalString( "delete.threadpool.beingused",
final ThreadPool threadPool) { final String classname = threadPool.getClassname(); if (classname != null && !ThreadPool.DEFAULT_THREAD_POOL_CLASS_NAME.equals(classname)) {
protected ThreadPoolConfig configureThreadPoolConfig(final NetworkListener networkListener, final ThreadPool threadPool) { final int maxQueueSize = threadPool.getMaxQueueSize() == null ? Integer.MAX_VALUE : Integer.parseInt(threadPool.getMaxQueueSize()); final int minThreads = Integer.parseInt(threadPool.getMinThreadPoolSize()); final int maxThreads = Integer.parseInt(threadPool.getMaxThreadPoolSize()); final int timeout = Integer.parseInt(threadPool.getIdleThreadTimeoutSeconds()); final ThreadPoolConfig poolConfig = ThreadPoolConfig.defaultConfig(); poolConfig.setPoolName(networkListener.getName()); poolConfig.setCorePoolSize(minThreads); poolConfig.setMaxPoolSize(maxThreads); poolConfig.setQueueLimit(maxQueueSize); // we specify the classloader that loaded this class to ensure // we present the same initial classloader no matter what mode // GlassFish is being run in. // See http://java.net/jira/browse/GLASSFISH-19639 poolConfig.setInitialClassLoader(this.getClass().getClassLoader()); poolConfig.setKeepAliveTime(timeout < 0 ? Long.MAX_VALUE : timeout, TimeUnit.SECONDS); if (transactionTimeoutMillis > 0 && !Utils.isDebugVM()) { poolConfig.setTransactionTimeout(obtainDelayedExecutor(), transactionTimeoutMillis, TimeUnit.MILLISECONDS); } return poolConfig; }
static public List<NetworkListener> findNetworkListeners(ThreadPool threadpool) { NetworkConfig config = threadpool.getParent().getParent(NetworkConfig.class); if (!Dom.unwrap(config).getProxyType().equals(NetworkConfig.class)) { config = Dom.unwrap(config).element("network-config").createProxy(); } List<NetworkListener> listeners = config.getNetworkListeners().getNetworkListener(); List<NetworkListener> refs = new ArrayList<NetworkListener>(); for (NetworkListener listener : listeners) { if (listener.getThreadPool().equals(threadpool.getName())) { refs.add(listener); } } return refs; }
/** * Process the instance file if this is DAS and there are instances configured already in this domain */ @Override public void postConstruct() { // If this is not the DAS, no need for this pool if(serverEnv.isInstance()) { return; } int poolSize = 5; Config svrConfig = domain.getConfigNamed("server-config"); // I am doing this code instead of a simple svrConfig.getAdminListener() here because embedded tests are failing // during build; got to check the reason why later. if(svrConfig != null) { NetworkConfig nwc = svrConfig.getNetworkConfig(); if (nwc != null) { List<NetworkListener> lss = nwc.getNetworkListeners().getNetworkListener(); if ( (lss != null) && (!lss.isEmpty()) ) { for (NetworkListener ls : lss) { if (ServerTags.ADMIN_LISTENER_ID.equals(ls.getName())) { if(ls.findThreadPool() != null) { poolSize = Integer.parseInt(ls.findThreadPool().getMaxThreadPoolSize()); } } } } } } svc = Executors.newFixedThreadPool(poolSize, new InstanceStateThreadFactory()); }
final ThreadPool threadPool) { final String classname = threadPool.getClassname(); if (classname != null && !ThreadPool.DEFAULT_THREAD_POOL_CLASS_NAME.equals(classname)) {
public Object run(ThreadPools param) throws PropertyVetoException, TransactionFailure { List<ThreadPool> poolList = param.getThreadPool(); for (ThreadPool pool : poolList) { String currPoolId = pool.getName(); if (currPoolId != null && currPoolId.equals (threadpool_id)) { poolList.remove(pool); break; } } return poolList; } }, threadPools);
private void ensureAdminThreadPool() throws TransactionFailure { final ThreadPools threadPools = currentConfig.getThreadPools(); boolean adminThreadPoolFound = false; for (ThreadPool pool : threadPools.getThreadPool()) { adminThreadPoolFound |= "admin-thread-pool".equals(pool.getName()); } if (!adminThreadPoolFound) { ConfigSupport.apply(new SingleConfigCode<ThreadPools>() { @Override public Object run(ThreadPools param) throws PropertyVetoException, TransactionFailure { final ThreadPool pool = param.createChild(ThreadPool.class); param.getThreadPool().add(pool); pool.setName("admin-thread-pool"); pool.setMaxThreadPoolSize("50"); pool.setMaxQueueSize("256"); return null; } }, threadPools); } }
public static ThreadPool findThreadPool(NetworkListener listener) { final NetworkListeners listeners = listener.getParent(); List<ThreadPool> list = listeners.getThreadPool(); if (list == null || list.isEmpty()) { final ConfigBeanProxy parent = listener.getParent().getParent().getParent(); final Dom proxy = Dom.unwrap(parent).element("thread-pools"); final List<Dom> domList = proxy.nodeElements("thread-pool"); list = new ArrayList<ThreadPool>(domList.size()); for (Dom dom : domList) { list.add(dom.<ThreadPool>createProxy()); } } for (ThreadPool pool : list) { if (listener.getThreadPool().equals(pool.getName())) { return pool; } } return null; }
public static ThreadPool findThreadPool(NetworkListener listener) { final NetworkListeners listeners = listener.getParent(); List<ThreadPool> list = listeners.getThreadPool(); if (list == null || list.isEmpty()) { final ConfigBeanProxy parent = listener.getParent().getParent().getParent(); final Dom proxy = Dom.unwrap(parent).element("thread-pools"); final List<Dom> domList = proxy.nodeElements("thread-pool"); list = new ArrayList<ThreadPool>(domList.size()); for (Dom dom : domList) { list.add(dom.<ThreadPool>createProxy()); } } for (ThreadPool pool : list) { if (listener.getThreadPool().equals(pool.getName())) { return pool; } } return null; }
@Override public boolean preAuthorization(AdminCommandContext context) { config = CLIUtil.updateConfigIfNeeded(config, target, habitat); threadPools = config.getThreadPools(); for (ThreadPool pool: threadPools.getThreadPool()) { final ActionReport report = context.getActionReport(); if (pool.getName().equals(threadpool_id)) { report.setMessage(localStrings.getLocalString("create.threadpool.duplicate", "Thread Pool named {0} already exists.", threadpool_id)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return false; } } return true; }