From e3c8dcadd62feb1ee6c428bcb42c4703116b14cc Mon Sep 17 00:00:00 2001 From: nebil ben mabrouk Date: Thu, 28 Feb 2019 13:07:30 +0100 Subject: [PATCH 1/2] Fix scheduler-node tests and enhance messages in SchedulerStarter and LoadPackages.groovy --- build.gradle | 1 + scheduler/scheduler-node/build.gradle | 14 ++++++++++++++ .../ForkedJvmTaskExecutionCommandCreatorTest.java | 12 ++++++++++++ .../scheduler/util/SchedulerStarter.java | 15 ++++++++++++++- tools/LoadPackages.groovy | 8 +++++--- 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 9ce7656739..98b47197b0 100644 --- a/build.gradle +++ b/build.gradle @@ -198,6 +198,7 @@ ext.schedulingFunctionalTestConfiguration = { include 'functionaltests/RegressionTestSuite*' } + systemProperties << ['proactive.home': rootDir.absolutePath] systemProperties << ['pa.rm.home': rootDir.absolutePath] systemProperties << ['pa.scheduler.home': rootDir.absolutePath] systemProperties << ['proactive.communication.protocol': 'pnp'] diff --git a/scheduler/scheduler-node/build.gradle b/scheduler/scheduler-node/build.gradle index e3bd6885c4..c900c0573b 100644 --- a/scheduler/scheduler-node/build.gradle +++ b/scheduler/scheduler-node/build.gradle @@ -45,6 +45,20 @@ task stub(type: StubTask) { } serialver.dependsOn stub +test { + exclude 'functionaltests/**' + exclude 'unittests/**' + exclude 'unitTests/**' + exclude 'performancetests/**' + + if(Boolean.valueOf(System.getProperty("java.awt.headless"))){ + exclude 'org/ow2/proactive_grid_cloud_portal/cli/**' + } + systemProperties << ['java.security.policy': file("$rootDir/config/security.java.policy-server").absolutePath] + systemProperties << ['file.encoding': 'UTF-8'] + systemProperties << ['proactive.home': rootDir.absolutePath] +} + task('functionalTest', type: Test).configure rootProject.schedulingFunctionalTestConfiguration ext.oneJarManifest = manifest { diff --git a/scheduler/scheduler-node/src/test/java/org/ow2/proactive/scheduler/task/executors/forked/env/ForkedJvmTaskExecutionCommandCreatorTest.java b/scheduler/scheduler-node/src/test/java/org/ow2/proactive/scheduler/task/executors/forked/env/ForkedJvmTaskExecutionCommandCreatorTest.java index 8f2da63fc8..12ad403fb4 100644 --- a/scheduler/scheduler-node/src/test/java/org/ow2/proactive/scheduler/task/executors/forked/env/ForkedJvmTaskExecutionCommandCreatorTest.java +++ b/scheduler/scheduler-node/src/test/java/org/ow2/proactive/scheduler/task/executors/forked/env/ForkedJvmTaskExecutionCommandCreatorTest.java @@ -38,6 +38,7 @@ import java.util.Map; import org.junit.Test; +import org.objectweb.proactive.core.config.CentralPAPropertyRepository; import org.objectweb.proactive.core.node.NodeException; import org.objectweb.proactive.extensions.pamr.PAMRConfig; import org.ow2.proactive.scheduler.common.job.JobVariable; @@ -105,9 +106,20 @@ public void testExecCommandUsesJavaHomeFromSystemProperties() throws Exception { @Test public void testExecCommandUsesClassPathSystemProperties() throws Exception { + // before test (clear 'proactive.home' system property) + String proactiveHomeProperty = CentralPAPropertyRepository.PA_HOME.getName(); + String proactiveHomeValue = System.getProperty(proactiveHomeProperty); + if (proactiveHomeValue != null) { + System.clearProperty(proactiveHomeProperty); + } + + // test javaCommandContainsOrNot(Arrays.asList(new String[] { "-cp", System.getProperty("java.class.path") }), createForkEnvironment(), true); + + // after test (reset 'proactive.home') + System.setProperty(proactiveHomeProperty, proactiveHomeValue); } @Test diff --git a/scheduler/scheduler-server/src/main/java/org/ow2/proactive/scheduler/util/SchedulerStarter.java b/scheduler/scheduler-server/src/main/java/org/ow2/proactive/scheduler/util/SchedulerStarter.java index 65617aa9cd..3d01ee34ad 100644 --- a/scheduler/scheduler-server/src/main/java/org/ow2/proactive/scheduler/util/SchedulerStarter.java +++ b/scheduler/scheduler-server/src/main/java/org/ow2/proactive/scheduler/util/SchedulerStarter.java @@ -178,12 +178,17 @@ protected static CommandLine getCommandLine(String[] args, Options options) thro } protected static void start(CommandLine commandLine) throws Exception { + + long startTime = System.nanoTime(); + ProActiveConfiguration.load(); // force properties loading to find out if PAMR router should be started if (!commandLine.hasOption(OPTION_NO_ROUTER)) { startRouter(); } + LOGGER.info("Activeeon ProActive version " + getSchedulerVersion()); + hsqldbServer = new SchedulerHsqldbStarter(); hsqldbServer.startIfNeeded(); @@ -205,12 +210,20 @@ protected static void start(CommandLine commandLine) throws Exception { } if (!commandLine.hasOption(OPTION_NO_REST)) { + long jettyStartTime = System.nanoTime(); startJetty(rmURL, schedulerURL); + long jettyEndTime = System.nanoTime(); + LOGGER.debug("Jetty started in " + + String.valueOf(((double) jettyEndTime - jettyStartTime) / 1_000_000_000) + " seconds"); } addShutdownMessageHook(); executeStartScripts(); + + long endTime = System.nanoTime(); + LOGGER.info("ProActive started in " + String.valueOf(((double) endTime - startTime) / 1_000_000_000) + + " seconds"); } public static void startJetty(String rmUrl, String scheduleUrl) { @@ -274,7 +287,7 @@ private static SchedulerAuthenticationInterface startScheduler(CommandLine comma throws URISyntaxException, InternalSchedulerException, ParseException, SocketException, UnknownHostException, IllegalArgumentException { String policyFullName = getPolicyFullName(commandLine); - LOGGER.info("Scheduler version is " + getSchedulerVersion()); + LOGGER.info("Starting the scheduler..."); SchedulerAuthenticationInterface sai = null; try { diff --git a/tools/LoadPackages.groovy b/tools/LoadPackages.groovy index ff1ad27748..f2531a0ca3 100644 --- a/tools/LoadPackages.groovy +++ b/tools/LoadPackages.groovy @@ -70,7 +70,6 @@ class LoadPackages { def run() { - println "Executing " + this.SCRIPT_NAME + " ..." writeToOutput(" Automatic deployment of proactive packages ...") writeToOutput(" Variables : ") @@ -84,6 +83,7 @@ class LoadPackages { if (examples_dir.exists()) { writeToOutput(this.EXAMPLES_DIR_PATH + " already exists, delete it to redeploy packages.") writeToOutput("Terminated.") + println "Workflow and utility packages already loaded" return } @@ -92,8 +92,10 @@ class LoadPackages { if (!examples_zip.exists()) { writeToOutput(this.EXAMPLES_ZIP_PATH + " not found!") return - } + + println "Loading workflow and utility packages..." + unzipFile(examples_zip, this.EXAMPLES_DIR_PATH) writeToOutput(this.EXAMPLES_ZIP_PATH + " extracted!") @@ -112,7 +114,7 @@ class LoadPackages { writeToOutput(" ... proactive packages deployed!") writeToOutput(" Terminated.") - println "... " + this.SCRIPT_NAME + " done" + println "Packages successfully loaded" } } instance = null; From afd38c3a1490841a1058472c33d8ead75dc53f01 Mon Sep 17 00:00:00 2001 From: nebil ben mabrouk Date: Fri, 1 Mar 2019 09:34:44 +0100 Subject: [PATCH 2/2] Enhance Jetty perf by using QuickstartWebApp and Configure Atmosphere Framework in rest api --- .../src/main/webapp/WEB-INF/web.xml | 27 +++++++ scheduler/scheduler-server/build.gradle | 4 +- .../org/ow2/proactive/utils/JettyStarter.java | 76 +++++++++++-------- 3 files changed, 74 insertions(+), 33 deletions(-) diff --git a/rest/rest-server/src/main/webapp/WEB-INF/web.xml b/rest/rest-server/src/main/webapp/WEB-INF/web.xml index d682fce4ba..ce45cd7cd0 100644 --- a/rest/rest-server/src/main/webapp/WEB-INF/web.xml +++ b/rest/rest-server/src/main/webapp/WEB-INF/web.xml @@ -65,6 +65,33 @@ org.atmosphere.cache.UUIDBroadcasterCache + + + org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults + true + + + org.atmosphere.cpr.AtmosphereInterceptor.disable + true + + + org.atmosphere.cpr.AtmosphereInitializer.disabled + true + + + org.atmosphere.cpr.scanClassPath + false + + + org.atmosphere.disableOnStateEvent + true + + + org.atmosphere.interceptor.JavaScriptProtocol.enforceAtmosphereProtocol + true + + + 0 true diff --git a/scheduler/scheduler-server/build.gradle b/scheduler/scheduler-server/build.gradle index 34afb20249..654e7f6b7f 100644 --- a/scheduler/scheduler-server/build.gradle +++ b/scheduler/scheduler-server/build.gradle @@ -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') @@ -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}" diff --git a/scheduler/scheduler-server/src/main/java/org/ow2/proactive/utils/JettyStarter.java b/scheduler/scheduler-server/src/main/java/org/ow2/proactive/utils/JettyStarter.java index 3ab4a5b786..553de33b15 100644 --- a/scheduler/scheduler-server/src/main/java/org/ow2/proactive/utils/JettyStarter.java +++ b/scheduler/scheduler-server/src/main/java/org/ow2/proactive/utils/JettyStarter.java @@ -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; @@ -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; @@ -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"; @@ -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()); @@ -277,7 +280,7 @@ private List 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(); } @@ -287,11 +290,11 @@ private List printDeployedApplications(Server server, String schedulerHo ArrayList 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())) { @@ -330,7 +333,7 @@ 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); @@ -338,13 +341,12 @@ private void addWarFile(HandlerList handlerList, File file, String[] virtualHost 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); @@ -352,7 +354,7 @@ private void addExplodedWebApp(HandlerList handlerList, File file, String[] virt 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); @@ -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.");