Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance jetty performance #3487

Open
wants to merge 3 commits into
base: enhance-PA-startup-time
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions rest/rest-server/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,33 @@
<param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
</init-param>

<!-- ************************** Enhance Atmosphere Framework performance ************-->
<init-param>
<param-name>org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.AtmosphereInterceptor.disable</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.AtmosphereInitializer.disabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.scanClassPath</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.disableOnStateEvent</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.interceptor.JavaScriptProtocol.enforceAtmosphereProtocol</param-name>
<param-value>true</param-value>
</init-param>
<!-- *********************************************************************************-->

<load-on-startup>0</load-on-startup>
<async-supported>true</async-supported>
</servlet>
Expand Down
4 changes: 2 additions & 2 deletions scheduler/scheduler-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ dependencies {
compile "org.ow2.proactive:emailnotification-addons:${schedulingVersion}"

compile 'org.eclipse.jetty:jetty-webapp:9.2.24.v20180105'
compile 'org.eclipse.jetty:jetty-quickstart:9.2.24.v20180105'

compile "org.objectweb.proactive:programming-core:${programmingVersion}"

compile project(':common:common-api')
Expand All @@ -33,8 +35,6 @@ dependencies {
compile project(':rest:rest-server')




testCompile "com.google.jimfs:jimfs:1.1"
testCompile "org.objectweb.proactive:programming-extension-pnp:${programmingVersion}"
testCompile "org.objectweb.proactive:programming-extension-pnpssl:${programmingVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
package org.ow2.proactive.utils;

import java.io.File;
import java.io.FilenameFilter;
import java.net.BindException;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -35,6 +34,7 @@
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.quickstart.QuickStartWebApp;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
Expand All @@ -60,7 +60,7 @@

public class JettyStarter {

protected static final String FOLDER_TO_DEPLOY = "/dist/war/";
private static final String FOLDER_TO_DEPLOY = "/dist/war/";

public static final String HTTP_CONNECTOR_NAME = "http";

Expand Down Expand Up @@ -207,26 +207,29 @@ public Server createHttpServer(int httpPort, int httpsPort, boolean httpsEnabled
secureHttpConfiguration.setSendServerVersion(false);

// Connector to listen for HTTPS requests
ServerConnector httpsConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory,
HttpVersion.HTTP_1_1.toString()),
new HttpConnectionFactory(secureHttpConfiguration));
httpsConnector.setName(HTTPS_CONNECTOR_NAME);
httpsConnector.setPort(httpsPort);
httpsConnector.setIdleTimeout(WebProperties.WEB_IDLE_TIMEOUT.getValueAsLong());

if (redirectHttpToHttps) {
// The next two settings allow !403 errors to be redirected to HTTPS
httpConfiguration.setSecureScheme("https");
httpConfiguration.setSecurePort(httpsPort);

// Connector to listen for HTTP requests that are redirected to HTTPS
ServerConnector httpConnector = createHttpConnector(server, httpConfiguration, httpPort);

connectors = new Connector[] { httpConnector, httpsConnector };
} else {
connectors = new Connector[] { httpsConnector };
try (ServerConnector httpsConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory,
HttpVersion.HTTP_1_1.toString()),
new HttpConnectionFactory(secureHttpConfiguration))) {

httpsConnector.setName(HTTPS_CONNECTOR_NAME);
httpsConnector.setPort(httpsPort);
httpsConnector.setIdleTimeout(WebProperties.WEB_IDLE_TIMEOUT.getValueAsLong());

if (redirectHttpToHttps) {
// The next two settings allow !403 errors to be redirected to HTTPS
httpConfiguration.setSecureScheme("https");
httpConfiguration.setSecurePort(httpsPort);

// Connector to listen for HTTP requests that are redirected to HTTPS
ServerConnector httpConnector = createHttpConnector(server, httpConfiguration, httpPort);

connectors = new Connector[] { httpConnector, httpsConnector };
} else {
connectors = new Connector[] { httpsConnector };
}
}

} else {
ServerConnector httpConnector = createHttpConnector(server, httpConfiguration, httpPort);
httpConnector.setIdleTimeout(WebProperties.WEB_IDLE_TIMEOUT.getValueAsLong());
Expand Down Expand Up @@ -277,7 +280,7 @@ private List<String> startServer(Server server, String schedulerHost, int restPo
}

private String getApplicationUrl(String httpProtocol, String schedulerHost, int restPort,
WebAppContext webAppContext) {
QuickStartWebApp webAppContext) {
return httpProtocol + "://" + schedulerHost + ":" + restPort + webAppContext.getContextPath();
}

Expand All @@ -287,11 +290,11 @@ private List<String> printDeployedApplications(Server server, String schedulerHo
ArrayList<String> applicationsUrls = new ArrayList<>();
if (handlerList.getHandlers() != null) {
for (Handler handler : handlerList.getHandlers()) {
if (!(handler instanceof WebAppContext)) {
if (!(handler instanceof QuickStartWebApp)) {
continue;
}

WebAppContext webAppContext = (WebAppContext) handler;
QuickStartWebApp webAppContext = (QuickStartWebApp) handler;
Throwable startException = webAppContext.getUnavailableException();
if (startException == null) {
if (!"/".equals(webAppContext.getContextPath())) {
Expand Down Expand Up @@ -330,29 +333,28 @@ private void addWarsToHandlerList(HandlerList handlerList, String[] virtualHost)

private void addWarFile(HandlerList handlerList, File file, String[] virtualHost) {
String contextPath = "/" + FilenameUtils.getBaseName(file.getName());
WebAppContext webApp = createWebAppContext(contextPath, virtualHost);
WebAppContext webApp = createWebAppContext(contextPath, virtualHost, true);
webApp.setWar(file.getAbsolutePath());
handlerList.addHandler(webApp);
logger.debug("Deploying " + contextPath + " using war file " + file);
}

private void addExplodedWebApp(HandlerList handlerList, File file, String[] virtualHost) {
String contextPath = "/" + file.getName();
WebAppContext webApp = createWebAppContext(contextPath, virtualHost);
WebAppContext webApp = createWebAppContext(contextPath, virtualHost, true);

// Don't scan classes for annotations. Saves 1 second at startup.
webApp.setAttribute("org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern", "^$");
webApp.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", "^$");

webApp.setDescriptor(new File(file, "/WEB-INF/web.xml").getAbsolutePath());
webApp.setResourceBase(file.getAbsolutePath());
handlerList.addHandler(webApp);
logger.debug("Deploying " + contextPath + " using exploded war " + file);
}

private void addStaticFolder(HandlerList handlerList, File file, String[] virtualHost) {
String contextPath = "/" + file.getName();
WebAppContext webApp = createWebAppContext(contextPath, virtualHost);
WebAppContext webApp = createWebAppContext(contextPath, virtualHost, false);
webApp.setWar(file.getAbsolutePath());
handlerList.addHandler(webApp);
logger.debug("Deploying " + contextPath + " using folder " + file);
Expand All @@ -361,14 +363,26 @@ private void addStaticFolder(HandlerList handlerList, File file, String[] virtua
private void addGetStartedApplication(HandlerList handlerList, File file, String[] virtualHost) {
if (file.exists()) {
String contextPath = "/";
WebAppContext webApp = createWebAppContext(contextPath, virtualHost);
WebAppContext webApp = createWebAppContext(contextPath, virtualHost, false);
webApp.setWar(file.getAbsolutePath());
handlerList.addHandler(webApp);
}
}

private WebAppContext createWebAppContext(String contextPath, String[] virtualHost) {
WebAppContext webApp = new WebAppContext();
private WebAppContext createWebAppContext(String contextPath, String[] virtualHost, boolean quickstart) {

WebAppContext webApp;
if (quickstart) {
webApp = new QuickStartWebApp();

// Parameters that may optimize webapp deployment
((QuickStartWebApp) webApp).setAutoPreconfigure(true);
webApp.setInitParameter("org.eclipse.jetty.jsp.precompiled", "true");

} else {
webApp = new WebAppContext();
}

webApp.setParentLoaderPriority(true);
// The following setting allows to avoid conflicts between server jackson jars and individual war jackson versions.
webApp.addServerClass("com.fasterxml.jackson.");
Expand Down