ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject git commit: AMBARI-5639. Ambari will not respond to connections when CPU exceeds Jetty threads (ncole)
Date Wed, 30 Apr 2014 19:06:28 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 7140d3c36 -> e28a1f506


AMBARI-5639. Ambari will not respond to connections when CPU exceeds Jetty threads (ncole)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e28a1f50
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e28a1f50
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e28a1f50

Branch: refs/heads/trunk
Commit: e28a1f506a314ce60c381abba50d846b3927905b
Parents: 7140d3c
Author: Nate Cole <ncole@hortonworks.com>
Authored: Wed Apr 30 13:50:19 2014 -0400
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Wed Apr 30 13:50:25 2014 -0400

----------------------------------------------------------------------
 ambari-server/conf/unix/ambari.properties       |  4 ++
 .../server/configuration/Configuration.java     | 43 +++++++++++++----
 .../ambari/server/controller/AmbariServer.java  |  6 ++-
 .../server/configuration/ConfigurationTest.java | 51 ++++++++++++++------
 4 files changed, 78 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e28a1f50/ambari-server/conf/unix/ambari.properties
----------------------------------------------------------------------
diff --git a/ambari-server/conf/unix/ambari.properties b/ambari-server/conf/unix/ambari.properties
index 5880dfe..764328e 100644
--- a/ambari-server/conf/unix/ambari.properties
+++ b/ambari-server/conf/unix/ambari.properties
@@ -42,3 +42,7 @@ server.execution.scheduler.misfire.toleration.minutes=480
 
 # Default timeout in seconds before task is killed
 agent.task.timeout=600
+
+# thread pool maximums
+client.threadpool.size.max=25
+agent.threadpool.size.max=25

http://git-wip-us.apache.org/repos/asf/ambari/blob/e28a1f50/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index 19b3c9a..6576861 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -17,7 +17,15 @@
  */
 package org.apache.ambari.server.configuration;
 
-import com.google.inject.Singleton;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.orm.JPATableGenerationStrategy;
 import org.apache.ambari.server.orm.PersistenceType;
@@ -30,14 +38,8 @@ import org.apache.commons.lang.RandomStringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Map.Entry;
+
+import com.google.inject.Singleton;
 
 
 /**
@@ -274,6 +276,13 @@ public class Configuration {
   private static final String REPO_SUFFIX_UBUNTU = "/dists/HDP/Release.gpg,/dists/HDP/Release";
   
   private static final String PARALLEL_STAGE_EXECUTION_DEFAULT = "true";
+  
+  private static final String CLIENT_THREADPOOL_SIZE_KEY = "client.threadpool.size.max";
+  private static final int CLIENT_THREADPOOL_SIZE_DEFAULT = 25;
+  private static final String AGENT_THREADPOOL_SIZE_KEY = "agent.threadpool.size.max";
+  private static final int AGENT_THREADPOOL_SIZE_DEFAULT = 25;
+  
+  
   private static final Logger LOG = LoggerFactory.getLogger(
       Configuration.class);
   private Properties properties;
@@ -968,4 +977,20 @@ public class Configuration {
   public String getServerJDBCSchemaName() {
     return properties.getProperty(SERVER_JDBC_SCHEMA_NAME, SERVER_DB_NAME_DEFAULT);
   }
+
+  /**
+   * @return max thread pool size for clients, default 25
+   */
+  public int getClientThreadPoolSize() {
+    return Integer.parseInt(properties.getProperty(
+        CLIENT_THREADPOOL_SIZE_KEY, String.valueOf(CLIENT_THREADPOOL_SIZE_DEFAULT)));
+  }
+  
+  /**
+   * @return max thread pool size for agents, default 25
+   */
+  public int getAgentThreadPoolSize() {
+    return Integer.parseInt(properties.getProperty(
+        AGENT_THREADPOOL_SIZE_KEY, String.valueOf(AGENT_THREADPOOL_SIZE_DEFAULT)));
+  }  
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/e28a1f50/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index 91632c0..cdb7fea 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -341,8 +341,10 @@ public class AmbariServer {
       }
 
       //Set jetty thread pool
-      serverForAgent.setThreadPool(new QueuedThreadPool(25));
-      server.setThreadPool(new QueuedThreadPool(25));
+      serverForAgent.setThreadPool(
+          new QueuedThreadPool(configs.getAgentThreadPoolSize()));
+      server.setThreadPool(
+          new QueuedThreadPool(configs.getClientThreadPoolSize()));
 
       /* Configure the API server to use the NIO connectors */
       SelectChannelConnector apiConnector;

http://git-wip-us.apache.org/repos/asf/ambari/blob/e28a1f50/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
index 8da66f4..c47c7fb 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
@@ -18,10 +18,22 @@
 
 package org.apache.ambari.server.configuration;
 
-import com.google.inject.Guice;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.powermock.api.easymock.PowerMock.mockStatic;
+import static org.powermock.api.easymock.PowerMock.replayAll;
+import static org.powermock.api.easymock.PowerMock.verifyAll;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.Properties;
+
 import junit.framework.Assert;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.commons.io.FileUtils;
@@ -38,18 +50,9 @@ import org.powermock.api.support.membermodification.MemberMatcher;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
-import static org.mockito.Mockito.*;
-import static org.powermock.api.easymock.PowerMock.mockStatic;
-import static org.powermock.api.easymock.PowerMock.replayAll;
-import static org.powermock.api.easymock.PowerMock.verifyAll;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.Map;
-import java.util.Properties;
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
 
 
 @RunWith(PowerMockRunner.class)
@@ -258,4 +261,22 @@ public class ConfigurationTest {
     conf.getLocalDatabaseUrl();
   }
 
+  @Test()
+  public void testServerPoolSizes() {
+    Properties ambariProperties = new Properties();
+    Configuration conf = new Configuration(ambariProperties);
+    
+    Assert.assertEquals(25, conf.getClientThreadPoolSize());
+    Assert.assertEquals(25, conf.getAgentThreadPoolSize());
+    
+    ambariProperties = new Properties();
+    ambariProperties.setProperty("client.threadpool.size.max", "4");
+    ambariProperties.setProperty("agent.threadpool.size.max", "82");
+    conf = new Configuration(ambariProperties);
+    
+    Assert.assertEquals(4, conf.getClientThreadPoolSize());
+    Assert.assertEquals(82, conf.getAgentThreadPoolSize());
+    
+  }  
+  
 }


Mime
View raw message