Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 99c64cdbf -> 690fa082a


AMBARI-7802. 'Form too large' during 'Cluster install wizard>>Review'


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

Branch: refs/heads/branch-1.7.0
Commit: 690fa082a42e97380094fa3d55e36343bb902e71
Parents: 99c64cd
Author: Srimanth Gunturi <[email protected]>
Authored: Wed Oct 15 14:41:04 2014 -0700
Committer: Srimanth Gunturi <[email protected]>
Committed: Wed Oct 15 16:10:20 2014 -0700

----------------------------------------------------------------------
 .../ambari/server/controller/AmbariServer.java  | 53 +++++++++++++-------
 .../server/controller/AmbariServerTest.java     | 22 ++++++--
 2 files changed, 54 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/690fa082/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 efbfc98..f61341d 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
@@ -228,28 +228,13 @@ public class AmbariServer {
       ServletContextHandler root = new ServletContextHandler(
           ServletContextHandler.SECURITY | ServletContextHandler.SESSIONS);
 
-      root.setContextPath(CONTEXT_PATH);
-      root.setErrorHandler(injector.getInstance(AmbariErrorHandler.class));
+      configureRootHandler(root);
+      configureSessionManager(sessionManager);
       root.getSessionHandler().setSessionManager(sessionManager);
 
-      SessionManager jettySessionManager = 
root.getSessionHandler().getSessionManager();
-
-      // use AMBARISESSIONID instead of JSESSIONID to avoid conflicts with
-      // other services (like HDFS) that run on the same context but a 
different
-      // port
-      jettySessionManager.setSessionCookie("AMBARISESSIONID");
-
-      // each request that does not use AMBARISESSIONID will create a new
-      // HashedSession in Jetty; these MUST be reaped after inactivity in order
-      // to prevent a memory leak
-      int sessionInactivityTimeout = configs.getHttpSessionInactiveTimeout();
-      jettySessionManager.setMaxInactiveInterval(sessionInactivityTimeout);
-
       GenericWebApplicationContext springWebAppContext = new 
GenericWebApplicationContext();
       springWebAppContext.setServletContext(root.getServletContext());
       springWebAppContext.setParent(springAppContext);
-      /* Configure web app context */
-      root.setResourceBase(configs.getWebAppDir());
 
       root.getServletContext().setAttribute(
           WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
@@ -483,6 +468,40 @@ public class AmbariServer {
   }
 
   /**
+   * Performs basic configuration of root handler with static values and 
values from
+   * configuration file.
+   *
+   * @param root root handler
+   */
+  protected void configureRootHandler(ServletContextHandler root) {
+    root.setContextPath(CONTEXT_PATH);
+    root.setErrorHandler(injector.getInstance(AmbariErrorHandler.class));
+    root.setMaxFormContentSize(-1);
+
+    /* Configure web app context */
+    root.setResourceBase(configs.getWebAppDir());
+  }
+
+  /**
+   * Performs basic configuration of session manager with static values and 
values from
+   * configuration file.
+   *
+   * @param sessionManager session manager
+   */
+  protected void configureSessionManager(SessionManager sessionManager) {
+    // use AMBARISESSIONID instead of JSESSIONID to avoid conflicts with
+    // other services (like HDFS) that run on the same context but a different
+    // port
+    sessionManager.setSessionCookie("AMBARISESSIONID");
+
+    // each request that does not use AMBARISESSIONID will create a new
+    // HashedSession in Jetty; these MUST be reaped after inactivity in order
+    // to prevent a memory leak
+    int sessionInactivityTimeout = configs.getHttpSessionInactiveTimeout();
+    sessionManager.setMaxInactiveInterval(sessionInactivityTimeout);
+  }
+
+  /**
    * Creates default users if in-memory database is used
    */
   @Transactional

http://git-wip-us.apache.org/repos/asf/ambari/blob/690fa082/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
index f5911f0..8b7a641 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
@@ -34,6 +34,8 @@ import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.dao.MetainfoDAO;
 import org.apache.ambari.server.orm.entities.MetainfoEntity;
+import org.easymock.EasyMock;
+import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -100,17 +102,17 @@ public class AmbariServerTest {
       // Expected
     }
   }
-  
+
   @Test
   public void testProxyUser() throws Exception {
-    
+
     PasswordAuthentication pa = Authenticator.requestPasswordAuthentication(
         InetAddress.getLocalHost(), 80, null, null, null);
     Assert.assertNull(pa);
-    
+
     System.setProperty("http.proxyUser", "abc");
     System.setProperty("http.proxyPassword", "def");
-    
+
     AmbariServer.setupProxyAuth();
 
     pa = Authenticator.requestPasswordAuthentication(
@@ -121,5 +123,17 @@ public class AmbariServerTest {
 
   }
 
+  @Test
+  public void testConfigureRootHandler() throws Exception {
+    final ServletContextHandler handler = 
EasyMock.createNiceMock(ServletContextHandler.class);
+
+    handler.setMaxFormContentSize(-1);
+    EasyMock.expectLastCall().once();
+    replay(handler);
+
+    injector.getInstance(AmbariServer.class).configureRootHandler(handler);
+
+    EasyMock.verify(handler);
+  }
 
 }

Reply via email to