@Test public void testJettyThreadPoolCalculation() throws Exception { Server server = new Server(); AmbariServer ambariServer = new AmbariServer(); ambariServer.configureJettyThreadPool(server, 12, "mock-pool", 25); Assert.assertEquals(44, ((QueuedThreadPool) server.getThreadPool()).getMaxThreads()); ambariServer.configureJettyThreadPool(server, 2, "mock-pool", 25); Assert.assertEquals(25, ((QueuedThreadPool) server.getThreadPool()).getMaxThreads()); ambariServer.configureJettyThreadPool(server, 16, "mock-pool", 35); Assert.assertEquals(52, ((QueuedThreadPool) server.getThreadPool()).getMaxThreads()); }
protected void configureJettyThreadPool(Server server, int acceptorThreads, String threadPoolName, int configuredThreadPoolSize) { int minumumAvailableThreads = 20; int reservedJettyThreads = acceptorThreads * 2; if (configuredThreadPoolSize < reservedJettyThreads + minumumAvailableThreads) { int newThreadPoolSize = reservedJettyThreads + minumumAvailableThreads; LOG.warn( "The configured Jetty {} thread pool value of {} is not sufficient on a host with {} processors. Increasing the value to {}.", threadPoolName, configuredThreadPoolSize, Runtime.getRuntime().availableProcessors(), newThreadPoolSize); configuredThreadPoolSize = newThreadPoolSize; } LOG.info( "Jetty is configuring {} with {} reserved acceptors/selectors and a total pool size of {} for {} processors.", threadPoolName, acceptorThreads * 2, configuredThreadPoolSize, Runtime.getRuntime().availableProcessors()); QueuedThreadPool qtp = new QueuedThreadPool(configuredThreadPoolSize); qtp.setName(threadPoolName); server.setThreadPool(qtp); }
AmbariServer { protected void configureJettyThreadPool(Server server, int acceptorThreads, String threadPoolName, int configuredThreadPoolSize) { int minumumAvailableThreads = 20; int reservedJettyThreads = acceptorThreads * 2; if (configuredThreadPoolSize < reservedJettyThreads + minumumAvailableThreads) { int newThreadPoolSize = reservedJettyThreads + minumumAvailableThreads; LOG.warn( "The configured Jetty {} thread pool value of {} is not sufficient on a host with {} processors. Increasing the value to {}.", threadPoolName, configuredThreadPoolSize, Runtime.getRuntime().availableProcessors(), newThreadPoolSize); configuredThreadPoolSize = newThreadPoolSize; } LOG.info( "Jetty is configuring {} with {} reserved acceptors/selectors and a total pool size of {} for {} processors.", threadPoolName, acceptorThreads * 2, configuredThreadPoolSize, Runtime.getRuntime().availableProcessors()); QueuedThreadPool qtp = new QueuedThreadPool(configuredThreadPoolSize); qtp.setName(threadPoolName); server.setThreadPool(qtp); } }
AmbariServer { protected void configureJettyThreadPool(Server server, int acceptorThreads, String threadPoolName, int configuredThreadPoolSize) { int minumumAvailableThreads = 20; int reservedJettyThreads = acceptorThreads * 2; if (configuredThreadPoolSize < reservedJettyThreads + minumumAvailableThreads) { int newThreadPoolSize = reservedJettyThreads + minumumAvailableThreads; LOG.warn( "The configured Jetty {} thread pool value of {} is not sufficient on a host with {} processors. Increasing the value to {}.", threadPoolName, configuredThreadPoolSize, Runtime.getRuntime().availableProcessors(), newThreadPoolSize); configuredThreadPoolSize = newThreadPoolSize; } LOG.info( "Jetty is configuring {} with {} reserved acceptors/selectors and a total pool size of {} for {} processors.", threadPoolName, acceptorThreads * 2, configuredThreadPoolSize, Runtime.getRuntime().availableProcessors()); QueuedThreadPool qtp = new QueuedThreadPool(configuredThreadPoolSize); qtp.setName(threadPoolName); server.setThreadPool(qtp); }  }
AmbariServer { protected void configureJettyThreadPool(Server server, int acceptorThreads, String threadPoolName, int configuredThreadPoolSize) { int minumumAvailableThreads = 20; int reservedJettyThreads = acceptorThreads * 2; if (configuredThreadPoolSize < reservedJettyThreads + minumumAvailableThreads) { int newThreadPoolSize = reservedJettyThreads + minumumAvailableThreads; LOG.warn( "The configured Jetty {} thread pool value of {} is not sufficient on a host with {} processors. Increasing the value to {}.", threadPoolName, configuredThreadPoolSize, Runtime.getRuntime().availableProcessors(), newThreadPoolSize); configuredThreadPoolSize = newThreadPoolSize; } LOG.info( "Jetty is configuring {} with {} reserved acceptors/selectors and a total pool size of {} for {} processors.", threadPoolName, acceptorThreads * 2, configuredThreadPoolSize, Runtime.getRuntime().availableProcessors()); QueuedThreadPool qtp = new QueuedThreadPool(configuredThreadPoolSize); qtp.setName(threadPoolName); server.setThreadPool(qtp); }  String getServerOsType(); static AmbariManagementController getController(); @SuppressWarnings("deprecation") void run(); void stop(); @Deprecated void performStaticInjection(); void initViewRegistry(); static void setupProxyAuth(); static void enableLog4jMonitor(Map<String, String> configsMap); static void main(String[] args); }
AmbariServer { protected void configureJettyThreadPool(Server server, int acceptorThreads, String threadPoolName, int configuredThreadPoolSize) { int minumumAvailableThreads = 20; int reservedJettyThreads = acceptorThreads * 2; if (configuredThreadPoolSize < reservedJettyThreads + minumumAvailableThreads) { int newThreadPoolSize = reservedJettyThreads + minumumAvailableThreads; LOG.warn( "The configured Jetty {} thread pool value of {} is not sufficient on a host with {} processors. Increasing the value to {}.", threadPoolName, configuredThreadPoolSize, Runtime.getRuntime().availableProcessors(), newThreadPoolSize); configuredThreadPoolSize = newThreadPoolSize; } LOG.info( "Jetty is configuring {} with {} reserved acceptors/selectors and a total pool size of {} for {} processors.", threadPoolName, acceptorThreads * 2, configuredThreadPoolSize, Runtime.getRuntime().availableProcessors()); QueuedThreadPool qtp = new QueuedThreadPool(configuredThreadPoolSize); qtp.setName(threadPoolName); server.setThreadPool(qtp); }  String getServerOsType(); static AmbariManagementController getController(); @SuppressWarnings("deprecation") void run(); void stop(); @Deprecated void performStaticInjection(); void initViewRegistry(); static void setupProxyAuth(); static void enableLog4jMonitor(Map<String, String> configsMap); static void main(String[] args); static final String VIEWS_URL_PATTERN; static final EnumSet<DispatcherType> DISPATCHER_TYPES; volatile boolean running; }