Repository: ambari Updated Branches: refs/heads/trunk 7c8d4f6dc -> 9000f4379
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/9000f437 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9000f437 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9000f437 Branch: refs/heads/trunk Commit: 9000f43791bc476417dca20ad3b3c09c22893989 Parents: 7c8d4f6 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:52 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/9000f437/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 c40e5cd..4a064a2 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 @@ -242,28 +242,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, @@ -503,6 +488,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/9000f437/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); + } }
