Package org.wildfly.plugin.tools.server
Interface ServerManager
-
- All Known Implementing Classes:
DomainManager,StandaloneManager
public interface ServerManagerA simple manager for various interactions with a potentially running server.- Author:
- James R. Perkins
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classServerManager.BuilderA builder used to build aServerManager.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static ServerManager.Builderbuilder()Creates a builder to build a server manager.org.jboss.as.controller.client.ModelControllerClientclient()Returns the client associated with this server manager.ContainerDescriptioncontainerDescription()Returns the container description for the running server.DeploymentManagerdeploymentManager()Returns the deployment manager for the server.voidexecuteReload()Reloads the server and returns immediately.voidexecuteReload(org.jboss.dmr.ModelNode reloadOp)Reloads the server and returns immediately.static Optional<ProcessHandle>findProcess()Attempts to find the controlling process.booleanisRunning()Checks to see if a server is running.static booleanisRunning(org.jboss.as.controller.client.ModelControllerClient client)Checks if a server is running regardless if it is a standalone or domain server.static booleanisValidHomeDirectory(String path)Checks whether the directory is a valid home directory for a server.static booleanisValidHomeDirectory(Path path)Checks whether the directory is a valid home directory for a server.StringlaunchType()Determines the servers "launch-type".static Optional<String>launchType(org.jboss.as.controller.client.ModelControllerClient client)Returns the "launch-type" attribute of a server.voidreloadIfRequired()Checks if the container status is "reload-required" and if it's the case, executes reload and waits for completion with a 10 second timeout.voidreloadIfRequired(long timeout, TimeUnit unit)Checks if the container status is "reload-required" and if it's the case, executes reload and waits for completion.StringserverState()Gets the "server-state" for standalone servers or the "host-state" for domain servers.voidshutdown()Shuts down the server.voidshutdown(long timeout)Shuts down the server.StringtakeSnapshot()Takes a snapshot of the current servers configuration and returns the relative file name of the snapshot.default booleanwaitFor(long startupTimeout)Waits the given amount of time in seconds for a server to start.booleanwaitFor(long startupTimeout, TimeUnit unit)Waits the given amount of time for a server to start.
-
-
-
Method Detail
-
builder
static ServerManager.Builder builder()
Creates a builder to build a server manager.- Returns:
- a new builder
-
findProcess
static Optional<ProcessHandle> findProcess()
Attempts to find the controlling process. For a domain server this, returns the process handle for the process controller. For a standalone server, this returns the standalone process handle.Please note this method does not work on Windows. The
ProcessHandle.Info.arguments()is limited by the operating systems privileges.- Returns:
- the process handle if one was found running
-
isValidHomeDirectory
static boolean isValidHomeDirectory(Path path)
Checks whether the directory is a valid home directory for a server.This validates the path is not
null, exists, is a directory and contains ajboss-modules.jar.- Parameters:
path- the path to validate- Returns:
trueif the path is valid otherwisefalse
-
isValidHomeDirectory
static boolean isValidHomeDirectory(String path)
Checks whether the directory is a valid home directory for a server.This validates the path is not
null, exists, is a directory and contains ajboss-modules.jar.- Parameters:
path- the path to validate- Returns:
trueif the path is valid otherwisefalse
-
isRunning
static boolean isRunning(org.jboss.as.controller.client.ModelControllerClient client)
Checks if a server is running regardless if it is a standalone or domain server.- Parameters:
client- the client used to check the server state- Returns:
trueif a server is running, otherwisefalse
-
launchType
static Optional<String> launchType(org.jboss.as.controller.client.ModelControllerClient client)
Returns the "launch-type" attribute of a server.- Parameters:
client- the client used to check the launch-type attribute- Returns:
- the servers launch-type
-
client
org.jboss.as.controller.client.ModelControllerClient client()
Returns the client associated with this server manager.- Returns:
- a client to communicate with the server
-
serverState
String serverState()
Gets the "server-state" for standalone servers or the "host-state" for domain servers.- Returns:
- the server-state or "failed" if an error occurred
-
launchType
String launchType()
Determines the servers "launch-type".- Returns:
- the servers launch-type or "unknown" if it could not be determined
-
takeSnapshot
String takeSnapshot() throws IOException
Takes a snapshot of the current servers configuration and returns the relative file name of the snapshot.This simply executes the
take-snapshotoperation with no arguments.- Returns:
- the file name of the snapshot configuration file
- Throws:
IOException- if an error occurs executing the operation
-
containerDescription
ContainerDescription containerDescription() throws IOException
Returns the container description for the running server.- Returns:
- the container description for the running server
- Throws:
IOException- if an error occurs communicating with the server
-
deploymentManager
DeploymentManager deploymentManager()
Returns the deployment manager for the server.- Returns:
- the deployment manager
-
isRunning
boolean isRunning()
Checks to see if a server is running.- Returns:
trueif the server is running, otherwisefalse
-
waitFor
default boolean waitFor(long startupTimeout) throws InterruptedExceptionWaits the given amount of time in seconds for a server to start.If the
processis notnulland a timeout occurs the process will be destroyed.- Parameters:
startupTimeout- the time, in seconds, to wait for the server start- Returns:
trueif the server is up and running,falseif a timeout occurred waiting for the server to be in a running state- Throws:
InterruptedException- if interrupted while waiting for the server to start
-
waitFor
boolean waitFor(long startupTimeout, TimeUnit unit) throws InterruptedExceptionWaits the given amount of time for a server to start.If the
processis notnulland a timeout occurs the process will be destroyed.- Parameters:
startupTimeout- the time, to wait for the server startunit- the time unit for thestartupTimeoutargument- Returns:
trueif the server is up and running,falseif a timeout occurred waiting for the server to be in a running state- Throws:
InterruptedException- if interrupted while waiting for the server to start
-
shutdown
void shutdown() throws IOExceptionShuts down the server.- Throws:
IOException- if an error occurs communicating with the server
-
shutdown
void shutdown(long timeout) throws IOExceptionShuts down the server.- Parameters:
timeout- the graceful shutdown timeout, a value of-1will wait indefinitely and a value of0will not attempt a graceful shutdown- Throws:
IOException- if an error occurs communicating with the server
-
executeReload
void executeReload() throws IOExceptionReloads the server and returns immediately.- Throws:
IOException- if an error occurs communicating with the server
-
executeReload
void executeReload(org.jboss.dmr.ModelNode reloadOp) throws IOExceptionReloads the server and returns immediately.- Parameters:
reloadOp- the reload operation to execute- Throws:
IOException- if an error occurs communicating with the server
-
reloadIfRequired
void reloadIfRequired() throws IOExceptionChecks if the container status is "reload-required" and if it's the case, executes reload and waits for completion with a 10 second timeout.- Throws:
IOException- if an error occurs communicating with the server- See Also:
reloadIfRequired(long, TimeUnit)
-
reloadIfRequired
void reloadIfRequired(long timeout, TimeUnit unit) throws IOExceptionChecks if the container status is "reload-required" and if it's the case, executes reload and waits for completion.- Parameters:
timeout- the time to wait for the server to reloadunit- the time unit for thetimeoutargument- Throws:
IOException- if an error occurs communicating with the server
-
-