From 2561ba751078e44658398e175167bbc707825edc Mon Sep 17 00:00:00 2001 From: Alfonso Altamirano Date: Wed, 11 Oct 2023 20:30:04 -0600 Subject: [PATCH 1/5] FISH-7158: adding warmup option to stop server after bootstrap --- .../admin/launcher/GFLauncherInfo.java | 22 ++++++++++++++++++- .../servermgmt/cli/StartDomainCommand.java | 9 ++++++++ .../v3/server/AppServerStartup.java | 7 ++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java index c8f08547284..2bc678de172 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2016-2018] [Payara Foundation] +// Portions Copyright [2016-2023] [Payara Foundation] package com.sun.enterprise.admin.launcher; @@ -149,6 +149,12 @@ public void setUpgrade(boolean b) { upgrade = b; } + /** + * Starts the server and after bootstrapping immediately stop + * @param b + */ + public void setWarmup(boolean b) { warmup = b; } + public void setDomainRootDir(File f) { domainRootDir = f; } @@ -205,6 +211,12 @@ public boolean isUpgrade() { return upgrade; } + /** + * + * @return true if the warmup is on. + */ + public boolean isWarmup() { return warmup; } + /** * * @return The domain name @@ -337,6 +349,7 @@ else if(isInstance()) { map.put("-debug", Boolean.toString(debug)); map.put("-instancename", instanceName); map.put("-upgrade", Boolean.toString(upgrade)); + map.put("-warmup", Boolean.toString(warmup)); map.put("-read-stdin", "true"); //always make the server read the stdin for master password, at least. if(respawnInfo != null) { @@ -458,6 +471,12 @@ else if(tsb.isFalse()) upgrade = true; else if(tsb.isFalse()) upgrade = false; + + tsb = getBoolean("warmup"); + if(tsb.isTrue()) + warmup = true; + else if(tsb.isFalse()) + warmup = false; } private void finalSetup() throws GFLauncherException { @@ -607,6 +626,7 @@ private String getValueIgnoreCommandDelimiter(String key) { private boolean watchdog = false; private boolean debug = false; private boolean upgrade = false; + private boolean warmup = false; File installDir; private File domainParentDir; private File domainRootDir; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java index 061a894c614..6c7588a09c8 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java @@ -101,6 +101,9 @@ public class StartDomainCommand extends LocalDomainCommand implements StartServe @Param(defaultValue = "600", optional = true) protected int timeout; + @Param(optional = true, defaultValue = "false") + private boolean warmup; + @Inject ServerEnvironment senv; @@ -181,6 +184,10 @@ protected int executeCommand() throws CommandException { doAdminPasswordCheck(); + if(warmup) { + info.setWarmup(true); + } + // launch returns very quickly if verbose is not set // if verbose is set then it returns after the domain dies launcher.launch(); @@ -247,6 +254,7 @@ public void createLauncher() info.setDebug(debug); info.setUpgrade(upgrade); info.setWatchdog(watchdog); + info.setWarmup(warmup); info.setDropInterruptedCommands(drop_interrupted_commands); info.setPrebootCommandsFile(preBootCommand); info.setpostbootCommandsFile(postBootCommand); @@ -270,6 +278,7 @@ private String[] respawnArgs() { args.add("--verbose=" + verbose); args.add("--watchdog=" + watchdog); args.add("--debug=" + debug); + args.add("--warmup=" + warmup); args.add("--domaindir"); args.add(getDomainsDir().toString()); if (ok(getDomainName())) diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java index 60684412d7d..a66e2ed57e6 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java @@ -377,6 +377,13 @@ public boolean run() { logger.log(level, "PostStartup level done in " + (postStartupFinishTime - startupFinishTime) + " ms"); } + if(context.getArguments().containsKey("-warmup") && + context.getArguments().getProperty("-warmup").equals("true")){ + logger.info(String.format("Doing warmup stop of server, " + + "please check configurations to be reused on another server instances")); + stop(); + return false; + } return true; } From 515d113afd9c9c9209eb7d063f553d8a4de5b9eb Mon Sep 17 00:00:00 2001 From: Alfonso Altamirano Date: Fri, 13 Oct 2023 17:42:32 -0600 Subject: [PATCH 2/5] FISH-7158: upgrading place to stop server --- .../admin/servermgmt/cli/LocalStrings.properties | 1 + .../admin/servermgmt/cli/StartDomainCommand.java | 3 ++- .../admin/servermgmt/cli/StartServerHelper.java | 13 +++++++++++++ .../enterprise/glassfish/bootstrap/LogFacade.java | 5 +++++ .../bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java | 5 +++++ .../sun/enterprise/v3/server/AppServerStartup.java | 14 +++----------- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties index 3346bbcef91..81e0cc86c55 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties @@ -194,6 +194,7 @@ ServerStart.SuccessMessage=Successfully started the {0}: {1}\n{0} Location: {2}\ ServerStart.DebuggerMessage=Debugging is enabled. The debugging port is: {0} ServerStart.DebuggerSuspendedMessage=Debugging is enabled and the server is suspended. \ Please attach to the debugging port at: {0} +ServerStart.SuccessWithWarmupEnabled=The server stops because warmup option was set to true. \nYou can reuse configuration because Server finishes after bootstrapping. DomainLocation=Started domain: {0}\nDomain location: {1}\nLog file: {2} DomainAdminPort=Admin port for the domain: {0} DomainDebugPort=Debug port for the domain: {0} diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java index 6c7588a09c8..3b2c4a1b156 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java @@ -185,7 +185,8 @@ protected int executeCommand() throws CommandException { doAdminPasswordCheck(); if(warmup) { - info.setWarmup(true); + info.setWarmup(warmup); + helper.setWarmup(warmup); } // launch returns very quickly if verbose is not set diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java index 04539aea8f2..5cc9a178ff9 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java @@ -94,6 +94,8 @@ public class StartServerHelper { private final int debugPort; private final boolean isDebugSuspend; // only set when actively trouble-shooting or investigating... + + private boolean isWarmup = false; private static final boolean DEBUG_MESSAGES_ON = false; private static final LocalStringsImpl STRINGS = new LocalStringsImpl(StartServerHelper.class); @@ -273,6 +275,9 @@ public void report() { if (debugPort >= 0) { logger.info(STRINGS.get("ServerStart.DebuggerMessage", "" + debugPort)); } + if (isWarmup) { + logger.info(STRINGS.get("ServerStart.SuccessWithWarmupEnabled")); + } } /** @@ -424,6 +429,14 @@ private static void debugMessage(String s) { CLIUtil.writeCommandToDebugLog("restart-debug", env, new String[]{"DEBUG MESSAGE FROM RESTART JVM", s}, 99999); } } + + public void setWarmup(boolean warmup) { + this.isWarmup = warmup; + } + + public boolean getWarmup() { + return isWarmup; + } /** * bnevins diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java index 43530f33d25..27a5c524cd5 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java @@ -265,6 +265,11 @@ public static void log(Logger logger, Level level, String messageId, message = "Got an unexpected exception.", level = "WARNING") public static final String CAUGHT_EXCEPTION = "NCLS-BOOTSTRAP-00039"; + + @LogMessageInfo( + message = "The option warmup was set to true, stopping the server.", + level = "WARNING") + public static final String WARMUP_OPTION_AS_TRUE = "NCLS-BOOTSTRAP-00040"; } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java index dda545eab5b..1c46f0a7b59 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java @@ -74,6 +74,11 @@ public EmbeddedOSGiGlassFishImpl(GlassFish decoratedGf, BundleContext bundleCont public void start() throws GlassFishException { super.start(); registerService(); + if(bundleContext.getProperty("-warmup") != null && bundleContext.getProperty("-warmup").equals("true")){ + logger.log(Level.WARNING, LogFacade.WARMUP_OPTION_AS_TRUE); + stop(); + System.exit(0); + } } @Override diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java index a66e2ed57e6..ce5f55efe58 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java @@ -50,6 +50,9 @@ import com.sun.enterprise.module.bootstrap.ModuleStartup; import com.sun.enterprise.module.bootstrap.StartupContext; import com.sun.enterprise.util.Result; +import jakarta.inject.Inject; +import jakarta.inject.Provider; +import jakarta.inject.Singleton; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; @@ -61,12 +64,8 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Level; import java.util.logging.Logger; -import jakarta.inject.Inject; -import jakarta.inject.Provider; -import jakarta.inject.Singleton; import org.glassfish.api.FutureProvider; import org.glassfish.api.StartupRunLevel; -import org.glassfish.api.admin.CommandRunner; import org.glassfish.api.admin.ProcessEnvironment; import org.glassfish.api.admin.ServerEnvironment; import org.glassfish.api.event.EventListener.Event; @@ -377,13 +376,6 @@ public boolean run() { logger.log(level, "PostStartup level done in " + (postStartupFinishTime - startupFinishTime) + " ms"); } - if(context.getArguments().containsKey("-warmup") && - context.getArguments().getProperty("-warmup").equals("true")){ - logger.info(String.format("Doing warmup stop of server, " + - "please check configurations to be reused on another server instances")); - stop(); - return false; - } return true; } From ae97835f436e33df84dced0003031865d65ffa2c Mon Sep 17 00:00:00 2001 From: Alfonso Altamirano Date: Fri, 13 Oct 2023 19:10:38 -0600 Subject: [PATCH 3/5] FISH-7158: fixing format and updating copyrights --- .../com/sun/enterprise/admin/launcher/GFLauncherInfo.java | 4 ++-- .../admin/servermgmt/cli/LocalStrings.properties | 2 +- .../admin/servermgmt/cli/StartDomainCommand.java | 2 +- .../com/sun/enterprise/glassfish/bootstrap/LogFacade.java | 2 +- .../bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java | 4 ++-- .../com/sun/enterprise/v3/server/AppServerStartup.java | 7 ++++--- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java index 2bc678de172..26a0789179f 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java @@ -473,9 +473,9 @@ else if(tsb.isFalse()) upgrade = false; tsb = getBoolean("warmup"); - if(tsb.isTrue()) + if (tsb.isTrue()) warmup = true; - else if(tsb.isFalse()) + else if (tsb.isFalse()) warmup = false; } diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties index 81e0cc86c55..b09de76d88d 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties @@ -37,7 +37,7 @@ # only if the new code is made subject to such option by the copyright # holder. # -# Portions Copyright [2016-2021] [Payara Foundation and/or its affiliates] +# Portions Copyright [2016-2023] [Payara Foundation and/or its affiliates] ## list-domains ## domain1 running diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java index 3b2c4a1b156..c984bb8574b 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java @@ -184,7 +184,7 @@ protected int executeCommand() throws CommandException { doAdminPasswordCheck(); - if(warmup) { + if (warmup) { info.setWarmup(warmup); helper.setWarmup(warmup); } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java index 27a5c524cd5..2a9687785b7 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2021] [Payara Foundation and/or its affiliates] +// Portions Copyright [2021-2023] [Payara Foundation and/or its affiliates] package com.sun.enterprise.glassfish.bootstrap; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java index 1c46f0a7b59..0009f617332 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2018] Payara Foundation and/or affiliates +// Portions Copyright [2018-2023] Payara Foundation and/or affiliates package com.sun.enterprise.glassfish.bootstrap.osgi; @@ -74,7 +74,7 @@ public EmbeddedOSGiGlassFishImpl(GlassFish decoratedGf, BundleContext bundleCont public void start() throws GlassFishException { super.start(); registerService(); - if(bundleContext.getProperty("-warmup") != null && bundleContext.getProperty("-warmup").equals("true")){ + if (bundleContext.getProperty("-warmup") != null && bundleContext.getProperty("-warmup").equals("true")) { logger.log(Level.WARNING, LogFacade.WARMUP_OPTION_AS_TRUE); stop(); System.exit(0); diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java index ce5f55efe58..60684412d7d 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java @@ -50,9 +50,6 @@ import com.sun.enterprise.module.bootstrap.ModuleStartup; import com.sun.enterprise.module.bootstrap.StartupContext; import com.sun.enterprise.util.Result; -import jakarta.inject.Inject; -import jakarta.inject.Provider; -import jakarta.inject.Singleton; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; @@ -64,8 +61,12 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Level; import java.util.logging.Logger; +import jakarta.inject.Inject; +import jakarta.inject.Provider; +import jakarta.inject.Singleton; import org.glassfish.api.FutureProvider; import org.glassfish.api.StartupRunLevel; +import org.glassfish.api.admin.CommandRunner; import org.glassfish.api.admin.ProcessEnvironment; import org.glassfish.api.admin.ServerEnvironment; import org.glassfish.api.event.EventListener.Event; From 24ef5e136bdeb5a17b29ac538b4f94e24219aa7f Mon Sep 17 00:00:00 2001 From: Alfonso Altamirano Date: Mon, 16 Oct 2023 16:36:06 -0600 Subject: [PATCH 4/5] FISH-7158: upgrading manpage for start-domain with warmup option description --- .../com/sun/enterprise/admin/servermgmt/cli/start-domain.1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nucleus/admin/server-mgmt/src/main/manpages/com/sun/enterprise/admin/servermgmt/cli/start-domain.1 b/nucleus/admin/server-mgmt/src/main/manpages/com/sun/enterprise/admin/servermgmt/cli/start-domain.1 index d4b7283dabc..78d9919b2be 100644 --- a/nucleus/admin/server-mgmt/src/main/manpages/com/sun/enterprise/admin/servermgmt/cli/start-domain.1 +++ b/nucleus/admin/server-mgmt/src/main/manpages/com/sun/enterprise/admin/servermgmt/cli/start-domain.1 @@ -8,7 +8,7 @@ SYNOPSIS [--debug={true|false}] [--domaindir domain-dir] [--dry-run={true|false}] [--upgrade={true|false}] [--verbose={true|false}] [--watchdog={true|false}] - [--timeout timeout] [domain-name] + [--timeout timeout] [--warmup={true|false}] [domain-name] DESCRIPTION The start-domain subcommand starts the domain administration server @@ -152,6 +152,9 @@ OPTIONS Specifies the amount of time in seconds the command will run for before timing out. Default is 600 seconds. + --warmup + Exit the server immediately after configuration is done. By default this is set as false. + OPERANDS domain-name The unique name of the domain you want to start. From 67c393c9a3a0ba336acac0702579037544749750 Mon Sep 17 00:00:00 2001 From: Alfonso Altamirano Date: Tue, 17 Oct 2023 09:27:48 -0600 Subject: [PATCH 5/5] FISH-7158: solving formatting from PR comments --- .../sun/enterprise/admin/launcher/GFLauncherInfo.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java index 26a0789179f..e06fad739eb 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java @@ -215,7 +215,9 @@ public boolean isUpgrade() { * * @return true if the warmup is on. */ - public boolean isWarmup() { return warmup; } + public boolean isWarmup() { + return warmup; + } /** * @@ -471,12 +473,13 @@ else if(tsb.isFalse()) upgrade = true; else if(tsb.isFalse()) upgrade = false; - + tsb = getBoolean("warmup"); - if (tsb.isTrue()) + if (tsb.isTrue()) { warmup = true; - else if (tsb.isFalse()) + } else if (tsb.isFalse()) { warmup = false; + } } private void finalSetup() throws GFLauncherException {