public final class AppServerLauncher
extends java.lang.Object
auto_start=true
in their
configuration; this will start up to initial_agents
.AppServer.launch(java.lang.String)
to
launch the specified appserver. If the appserver is already started, it will attempt to
start an agent.Modifier and Type | Class and Description |
---|---|
private static class |
AppServerLauncher.Launcher
Container for a Agent launching information.
|
Modifier and Type | Field and Description |
---|---|
private static int |
LAUNCH_TIMEOUT
The maximum amount of time to wait for an Agent to start.
|
private static java.util.Map<java.lang.String,AppServerLauncher.Launcher> |
launchers
Map of launchers, per appserver name.
|
private static java.util.logging.Logger |
LOG
Logger
|
private static int |
MAX_FAILURES
The maximum number of continous failures to start an Agent, before giving up.
|
Constructor and Description |
---|
AppServerLauncher() |
Modifier and Type | Method and Description |
---|---|
static boolean |
launch(java.lang.String appServer)
Launch the specified appserver.
|
private static boolean |
launch(java.lang.String account,
java.lang.String appServer)
Launch an agent for the specified appserver.
|
private static boolean |
launchWorker(java.lang.String appServer,
AppServerLauncher.Launcher launcher,
java.util.Map<java.lang.String,java.lang.String> appserverEnvMap)
Worker for Agent launching.
|
(package private) static void |
notifyLaunch(java.lang.String appServer,
boolean success)
When the appserver Agent is actually about to start listening for commands, it will notify
its launcher that it was started.
|
static void |
terminate(java.lang.String appServer)
Terminate the given appserver.
|
(package private) static void |
terminated(java.lang.String appServer)
Notify that the given appserver has been terminated (there are no more agents for it and
the pool is shutting down).
|
static void |
trimAgents(java.lang.String appServer)
Trim the agents for the specific appserver down to a
min_agents count. |
private static final java.util.logging.Logger LOG
private static final int MAX_FAILURES
private static final int LAUNCH_TIMEOUT
private static final java.util.Map<java.lang.String,AppServerLauncher.Launcher> launchers
public static boolean launch(java.lang.String appServer)
appServer
- The appserver name to launch.true
if the appserver was launched.static void notifyLaunch(java.lang.String appServer, boolean success)
Note that when an appserver is configured with auto_start=false
and the agent
is started manually, no AppServerLauncher.Launcher
will be available. Launchers are used only the
appserver is started automatically or when the server receives the "-p appserver" argument.
appServer
- The name of the appserver with which the Agent is associated.success
- true
if the Agent was started.private static boolean launch(java.lang.String account, java.lang.String appServer)
If no agent is alive for this appserver, it will initialize the appserver by starting an
initial_agents
Agents. An Agent startup will fail if it takes more than
120000 seconds. Also, the Agent startup will not continue if it failed
more than MAX_FAILURES
times in a row.
If first call and at least one agent has been started, it will start a thread responsible of sending the
account
- The account used to authenticate the Agent.appServer
- The appserver name.true
if the appserver or agent was started successfully.public static void terminate(java.lang.String appServer)
appServer
- The name of the appserver to terminate.public static void trimAgents(java.lang.String appServer)
min_agents
count.appServer
- The appserver name.static void terminated(java.lang.String appServer)
appServer
- The name of the appserver being terminated.private static boolean launchWorker(java.lang.String appServer, AppServerLauncher.Launcher launcher, java.util.Map<java.lang.String,java.lang.String> appserverEnvMap)
AppServerLauncher.Launcher.getSpawner()
,
it will wait for LAUNCH_TIMEOUT
seconds for the Agent to call notifyLaunch(java.lang.String, boolean)
.
After the timeout or when it receives the launch notification, it will check the
AppServerLauncher.Launcher.success
flag, for the status of the launch. Note that the AppServerLauncher.Launcher
is shared among processes trying to launch Agents; thus, the launch notification may come
from a different Agent than the one currently starting. This is not a problem, the party
starting the Agent doesn't care which agent started, it will only need to know if an Agent
was started; other parties waiting for Agent startup will eventually pick up the launch
notification, if the Agent was started.
appServer
- The name of the appserver to be launched.launcher
- The launcher used to start the agent.appserverEnvMap
- Appserver specific environment settings. May be null
.true
if the Agent was started successfully.