From 54a86e64a2aa78cc442079c9071405ca5f0a5e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Aur=C3=A8le=20Brothier?= Date: Wed, 15 Nov 2017 06:37:20 +0100 Subject: [PATCH 01/10] Bump Jetty to 9.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4ec4d111a6fe..e6ab89eb4c07 100644 --- a/pom.xml +++ b/pom.xml @@ -123,7 +123,7 @@ 2.4.12 10.1 2.8.0 - 9.2.22.v20170606 + 9.4.7.v20170914 From 0f25cc0423f90957e98293e32d163c8d51ef7992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Aur=C3=A8le=20Brothier?= Date: Wed, 15 Nov 2017 06:37:35 +0100 Subject: [PATCH 02/10] Use new jetty gzip handler --- .../src/org/apache/cloudstack/ServerDaemon.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/client/src/org/apache/cloudstack/ServerDaemon.java b/client/src/org/apache/cloudstack/ServerDaemon.java index 65e9a907cfd5..c5a2438a9c0d 100644 --- a/client/src/org/apache/cloudstack/ServerDaemon.java +++ b/client/src/org/apache/cloudstack/ServerDaemon.java @@ -43,8 +43,10 @@ import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.RequestLogHandler; +import org.eclipse.jetty.server.handler.gzip.GzipHandler; import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlets.GzipFilter; +import org.eclipse.jetty.servlets.gzip.GzipHandler; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; @@ -222,12 +224,12 @@ private HandlerCollection createHandlers() { webApp.setContextPath(contextPath); webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false"); - final FilterHolder filter = webApp.addFilter(GzipFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); - final Map params = new HashMap<>(); - params.put("mimeTypes", "text/html,text/xml,text/css,text/plain,text/javascript,application/javascript,application/json,application/xml"); - params.put("methods", "GET,POST"); - params.put("deflateCompressionLevel", "9"); - filter.setInitParameters(params); + // Configure GZIP + final GzipHandler gzipHandler = new GzipHandler(); + gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml"); + gzipHandler.setIncludedMethods("GET", "POST"); + gzipHandler.setCompressionLevel(9); + gzipHandler.setHandler(webApp); if (Strings.isNullOrEmpty(webAppLocation)) { webApp.setWar(getShadedWarUrl()); @@ -240,7 +242,7 @@ private HandlerCollection createHandlers() { final HandlerCollection handlerCollection = new HandlerCollection(); handlerCollection.addHandler(log); - handlerCollection.addHandler(webApp); + handlerCollection.addHandler(gzipHandler); return handlerCollection; } From 8fb564cf7427b3033d3440dbaca913afe22afc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Aur=C3=A8le=20Brothier?= Date: Wed, 15 Nov 2017 08:33:20 +0100 Subject: [PATCH 03/10] Redirect / to context --- .../org/apache/cloudstack/ServerDaemon.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/client/src/org/apache/cloudstack/ServerDaemon.java b/client/src/org/apache/cloudstack/ServerDaemon.java index c5a2438a9c0d..2d0fa20dd6cf 100644 --- a/client/src/org/apache/cloudstack/ServerDaemon.java +++ b/client/src/org/apache/cloudstack/ServerDaemon.java @@ -22,13 +22,8 @@ import java.io.IOException; import java.lang.management.ManagementFactory; import java.net.URL; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; import java.util.Properties; -import javax.servlet.DispatcherType; - import org.apache.commons.daemon.Daemon; import org.apache.commons.daemon.DaemonContext; import org.eclipse.jetty.jmx.MBeanContainer; @@ -42,11 +37,9 @@ import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.MovedContextHandler; import org.eclipse.jetty.server.handler.RequestLogHandler; import org.eclipse.jetty.server.handler.gzip.GzipHandler; -import org.eclipse.jetty.servlet.FilterHolder; -import org.eclipse.jetty.servlets.GzipFilter; -import org.eclipse.jetty.servlets.gzip.GzipHandler; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; @@ -240,11 +233,13 @@ private HandlerCollection createHandlers() { final RequestLogHandler log = new RequestLogHandler(); log.setRequestLog(createRequestLog()); - final HandlerCollection handlerCollection = new HandlerCollection(); - handlerCollection.addHandler(log); - handlerCollection.addHandler(gzipHandler); + // Rewrite handler for root + MovedContextHandler rootRedirect = new MovedContextHandler(); + rootRedirect.setContextPath("/"); + rootRedirect.setNewContextURL(contextPath); + rootRedirect.setPermanent(true); - return handlerCollection; + return new HandlerCollection(log, gzipHandler, rootRedirect); } private RequestLog createRequestLog() { From f60a8430692dec6d935e41e0015aad3323a1e7c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Aur=C3=A8le=20Brothier?= Date: Wed, 15 Nov 2017 09:08:28 +0100 Subject: [PATCH 04/10] Update wiremock but still not working --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e6ab89eb4c07..566650b8f486 100644 --- a/pom.xml +++ b/pom.xml @@ -122,7 +122,7 @@ 3.2.0 2.4.12 10.1 - 2.8.0 + 2.11.0 9.4.7.v20170914 From 51f96093752eb34e7a63c57a5982bae273bb68df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Aur=C3=A8le=20Brothier?= Date: Thu, 16 Nov 2017 06:50:10 +0100 Subject: [PATCH 05/10] Add session timeout configuration --- client/conf/server.properties.in | 3 +++ .../src/org/apache/cloudstack/ServerDaemon.java | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/client/conf/server.properties.in b/client/conf/server.properties.in index 7140bd26e26e..07306708052e 100644 --- a/client/conf/server.properties.in +++ b/client/conf/server.properties.in @@ -24,6 +24,9 @@ context.path=/client # The HTTP port to be used by the management server http.port=8080 +# Max inactivity time in minutes for the session +session.timeout=10 + # Options to configure and enable HTTPS on management server # # For management server to pickup these configuration settings, the configured diff --git a/client/src/org/apache/cloudstack/ServerDaemon.java b/client/src/org/apache/cloudstack/ServerDaemon.java index 2d0fa20dd6cf..c424f2a6cee8 100644 --- a/client/src/org/apache/cloudstack/ServerDaemon.java +++ b/client/src/org/apache/cloudstack/ServerDaemon.java @@ -65,6 +65,7 @@ public class ServerDaemon implements Daemon { private static final String BIND_INTERFACE = "bind.interface"; private static final String CONTEXT_PATH = "context.path"; + private static final String SESSION_TIMEOUT = "session.timeout"; private static final String HTTP_PORT = "http.port"; private static final String HTTPS_ENABLE = "https.enable"; private static final String HTTPS_PORT = "https.port"; @@ -81,6 +82,7 @@ public class ServerDaemon implements Daemon { private int httpPort = 8080; private int httpsPort = 8443; + private int sessionTimeout = 10; private boolean httpsEnable = false; private String accessLogFile = "access.log"; private String bindInterface = ""; @@ -124,6 +126,7 @@ public void init(final DaemonContext context) { setKeystorePassword(properties.getProperty(KEYSTORE_PASSWORD)); setWebAppLocation(properties.getProperty(WEBAPP_DIR)); setAccessLogFile(properties.getProperty(ACCESS_LOG, "access.log")); + setSessionTimeout(Integer.valueOf(properties.getProperty(SESSION_TIMEOUT, "10"))); } catch (final IOException e) { LOG.warn("Failed to load configuration from server.properties file", e); } @@ -216,8 +219,9 @@ private HandlerCollection createHandlers() { final WebAppContext webApp = new WebAppContext(); webApp.setContextPath(contextPath); webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false"); + webApp.getSessionHandler().setMaxInactiveInterval(sessionTimeout * 60); - // Configure GZIP + // GZIP handler final GzipHandler gzipHandler = new GzipHandler(); gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml"); gzipHandler.setIncludedMethods("GET", "POST"); @@ -230,15 +234,17 @@ private HandlerCollection createHandlers() { webApp.setWar(webAppLocation); } + // Request log handler final RequestLogHandler log = new RequestLogHandler(); log.setRequestLog(createRequestLog()); - // Rewrite handler for root + // Redirect root context handler MovedContextHandler rootRedirect = new MovedContextHandler(); rootRedirect.setContextPath("/"); rootRedirect.setNewContextURL(contextPath); rootRedirect.setPermanent(true); + // Put rootRedirect at the end! return new HandlerCollection(log, gzipHandler, rootRedirect); } @@ -304,4 +310,8 @@ public void setAccessLogFile(String accessLogFile) { public void setWebAppLocation(String webAppLocation) { this.webAppLocation = webAppLocation; } -} + + public void setSessionTimeout(int sessionTimeout) { + this.sessionTimeout = sessionTimeout; + } +} \ No newline at end of file From d438049d135a9d6dd4874f7400680f4b07db04ff Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 16 Nov 2017 16:26:21 +0530 Subject: [PATCH 06/10] server.properties.in: Change default timeout to 30 (mins) --- client/conf/server.properties.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/conf/server.properties.in b/client/conf/server.properties.in index 07306708052e..f255128555c8 100644 --- a/client/conf/server.properties.in +++ b/client/conf/server.properties.in @@ -25,7 +25,7 @@ context.path=/client http.port=8080 # Max inactivity time in minutes for the session -session.timeout=10 +session.timeout=30 # Options to configure and enable HTTPS on management server # From 4c0f5ee09ce61a17b61f77be68699ca9a15643cf Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 16 Nov 2017 17:18:31 +0530 Subject: [PATCH 07/10] cloudian: fix unit test failures Signed-off-by: Rohit Yadav --- plugins/integrations/cloudian/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/integrations/cloudian/pom.xml b/plugins/integrations/cloudian/pom.xml index 3e2b63562fbc..3138bb668ff5 100644 --- a/plugins/integrations/cloudian/pom.xml +++ b/plugins/integrations/cloudian/pom.xml @@ -52,7 +52,7 @@ com.github.tomakehurst - wiremock + wiremock-standalone ${cs.wiremock.version} test From d41002470e6597dc1f72bb7154ee604f8dbbef09 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 16 Nov 2017 18:51:28 +0530 Subject: [PATCH 08/10] client: use older 9.2.x jetty-maven-plugin that works Signed-off-by: Rohit Yadav --- client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/pom.xml b/client/pom.xml index 1545bfa11f2f..ec47f0a7c88c 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -491,7 +491,7 @@ org.eclipse.jetty jetty-maven-plugin - ${cs.jetty.version} + 9.2.22.v20170606 From 0d4a3916626b36ade4ae3abecaff6125b63c7460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Aur=C3=A8le=20Brothier?= Date: Fri, 17 Nov 2017 12:09:56 +0100 Subject: [PATCH 09/10] Moving jetty mvn plugin version in properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-Aurèle Brothier --- client/pom.xml | 2 +- pom.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/client/pom.xml b/client/pom.xml index ec47f0a7c88c..63980b9a1f2d 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -491,7 +491,7 @@ org.eclipse.jetty jetty-maven-plugin - 9.2.22.v20170606 + ${cs.jetty-maven-plugin.version} diff --git a/pom.xml b/pom.xml index 566650b8f486..b496a1611aa8 100644 --- a/pom.xml +++ b/pom.xml @@ -124,6 +124,7 @@ 10.1 2.11.0 9.4.7.v20170914 + 9.2.22.v20170606 From 3d9d53accd3855db8f3e5e006796902035fa3700 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 17 Nov 2017 17:09:35 +0530 Subject: [PATCH 10/10] Set default session timeout to 30mins --- client/src/org/apache/cloudstack/ServerDaemon.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/org/apache/cloudstack/ServerDaemon.java b/client/src/org/apache/cloudstack/ServerDaemon.java index c424f2a6cee8..985b67b755ae 100644 --- a/client/src/org/apache/cloudstack/ServerDaemon.java +++ b/client/src/org/apache/cloudstack/ServerDaemon.java @@ -82,7 +82,7 @@ public class ServerDaemon implements Daemon { private int httpPort = 8080; private int httpsPort = 8443; - private int sessionTimeout = 10; + private int sessionTimeout = 30; private boolean httpsEnable = false; private String accessLogFile = "access.log"; private String bindInterface = ""; @@ -126,7 +126,7 @@ public void init(final DaemonContext context) { setKeystorePassword(properties.getProperty(KEYSTORE_PASSWORD)); setWebAppLocation(properties.getProperty(WEBAPP_DIR)); setAccessLogFile(properties.getProperty(ACCESS_LOG, "access.log")); - setSessionTimeout(Integer.valueOf(properties.getProperty(SESSION_TIMEOUT, "10"))); + setSessionTimeout(Integer.valueOf(properties.getProperty(SESSION_TIMEOUT, "30"))); } catch (final IOException e) { LOG.warn("Failed to load configuration from server.properties file", e); } @@ -314,4 +314,4 @@ public void setWebAppLocation(String webAppLocation) { public void setSessionTimeout(int sessionTimeout) { this.sessionTimeout = sessionTimeout; } -} \ No newline at end of file +}