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(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); } }
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; }
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; }
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; }
/** * Executes the command * * @param context information */ public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); try { List<ThreadPool> poolList = threadPools.getThreadPool(); for (ThreadPool pool : poolList) { final ActionReport.MessagePart part = report.getTopMessagePart() .addChild(); part.setMessage(pool.getName()); } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } catch (Exception e) { String str = e.getMessage(); report.setMessage(localStrings.getLocalString("list.thread.pools" + ".failed", "List Thread Pools failed because of: " + str)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); } } }