Class StandaloneManager
- All Implemented Interfaces:
AutoCloseable, ServerManager
- Author:
- James R. Perkins
-
Nested Class Summary
Nested classes/interfaces inherited from interface ServerManager
ServerManager.Builder -
Field Summary
Fields inherited from interface ServerManager
TIMEOUT -
Method Summary
Modifier and TypeMethodDescriptionAdds aServerManagerListenerto be notified of server manager events.org.jboss.as.controller.client.ModelControllerClientclient()Returns the client associated with this server manager.voidclose()Returns the container description for the running server.deploy(Deployment deployment) Deploys content to the server.Returns the deployment manager for the server.voidReloads the server and returns immediately.voidexecuteReload(org.jboss.dmr.ModelNode reloadOp) Reloads the server and returns immediately.booleanisClosed()Checks if this server manager has been closed.booleanChecks to see if a server is running.kill()Determines the servers "launch-type".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.booleanRemoves a previously addedServerManagerListenerfrom this server manager.Gets the "server-state" for standalone servers or the "host-state" for domain servers.voidshutdown(long timeout) Shuts down the server and wait for the servers to be shutdown.shutdownAsync(long timeout) Shuts down the server.Starts a server and waits for it to reach a running state.startAsync(long timeout, TimeUnit unit) Asynchronously starts a server and waits the amount of time defined by the timeout and the time unit.Takes a snapshot of the current servers configuration and returns the relative file name of the snapshot.undeploy(DeploymentDescription deployment) Undeploys content from the server.booleanWaits the given amount of time for a server to start.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ServerManager
asManaged, executeOperation, executeOperation, reloadIfRequired, shutdown, shutdownAsync, start, startAsync, waitFor
-
Method Details
-
serverState
Description copied from interface:ServerManagerGets the "server-state" for standalone servers or the "host-state" for domain servers.- Returns:
- the server-state or "failed" if an error occurred
-
executeReload
Description copied from interface:ServerManagerReloads the server and returns immediately.- Throws:
IOException- if an error occurs communicating with the server
-
reloadIfRequired
Description copied from interface:ServerManagerChecks 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
-
isRunning
public boolean isRunning()Description copied from interface:ServerManagerChecks to see if a server is running.- Returns:
trueif the server is running, otherwisefalse
-
client
public org.jboss.as.controller.client.ModelControllerClient client()Description copied from interface:ServerManagerReturns the client associated with this server manager.- Specified by:
clientin interfaceServerManager- Returns:
- a client to communicate with the server
-
containerDescription
Description copied from interface:ServerManagerReturns the container description for the running server.- Specified by:
containerDescriptionin interfaceServerManager- Returns:
- the container description for the running server
- Throws:
IOException- if an error occurs communicating with the server
-
deploymentManager
Description copied from interface:ServerManagerReturns the deployment manager for the server.- Specified by:
deploymentManagerin interfaceServerManager- Returns:
- the deployment manager
-
launchType
Determines the servers "launch-type".- Specified by:
launchTypein interfaceServerManager- Returns:
- the servers launch-type or "unknown" if it could not be determined
-
kill
Description copied from interface:ServerManagerIf a process is available and alive, the process is attempted to be killed. Note in cases where the process is not associated with this server manager, this method does nothing.The returned
ServerManageris the same instance of this server manager. You can use theCompletableFuture.get()to wait until the process, if available, to exit.- Specified by:
killin interfaceServerManager- Returns:
- a completable future that on a
CompletableFuture.get()will wait for the process, if available, exits
-
waitFor
Description copied from interface:ServerManagerWaits the given amount of time for a server to start.If the
processis notnulland a timeout occurs the process will be destroyed.- Specified by:
waitForin interfaceServerManager- 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
-
addServerManagerListener
Description copied from interface:ServerManagerAdds aServerManagerListenerto be notified of server manager events.Listeners are invoked in the order they are added (FIFO) for all events except
beforeShutdown, which uses reverse order (LIFO) to allow proper cleanup of resources.Event Ordering:
ServerManagerListener.afterStart(ServerManager)- after successful server startServerManagerListener.beforeShutdown(ServerManager)- before server shutdown (LIFO order)ServerManagerListener.beforeDeploy(ServerManager, Deployment)- before deploymentServerManagerListener.afterDeploy(ServerManager, Deployment)- after successful deploymentServerManagerListener.deployFailed(ServerManager, Deployment, Throwable)- on deployment failureServerManagerListener.beforeUndeploy(ServerManager, DeploymentDescription)- before undeploymentServerManagerListener.afterUndeploy(ServerManager, DeploymentDescription)- after successful undeploymentServerManagerListener.undeployFailed(ServerManager, DeploymentDescription, Throwable)- on undeployment failure
Thread Safety: This method is thread-safe. Listeners are stored in a concurrent collection and can be added at any time, even while the server is running.
- Specified by:
addServerManagerListenerin interfaceServerManager- Parameters:
listener- the listener to add (must not benull)- Returns:
- this server manager instance for method chaining
-
removeServerManagerListener
Description copied from interface:ServerManagerRemoves a previously addedServerManagerListenerfrom this server manager.Once removed, the listener will no longer receive notifications for any subsequent server manager events. If the listener is currently being invoked when this method is called, it will complete its current invocation but will not be called for future events.
Thread Safety: This method is thread-safe and can be called at any time, even while the server is running or events are being processed.
- Specified by:
removeServerManagerListenerin interfaceServerManager- Parameters:
listener- the listener to remove- Returns:
trueif the listener was found and removed,falseif the listener was not registered
-
takeSnapshot
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.- Specified by:
takeSnapshotin interfaceServerManager- Returns:
- the file name of the snapshot configuration file
- Throws:
IOException- if an error occurs executing the operationOperationExecutionException- if the take-snapshot operation fails
-
executeReload
public void executeReload(org.jboss.dmr.ModelNode reloadOp) throws IOException, OperationExecutionException Reloads the server and returns immediately.- Specified by:
executeReloadin interfaceServerManager- Parameters:
reloadOp- the reload operation to execute- Throws:
OperationExecutionException- if the reload operation failsIOException- if an error occurs communicating with the server
-
start
Description copied from interface:ServerManagerStarts a server and waits for it to reach a running state.This method can be used to start a server that was created using
ServerManager.of(Configuration)or to restart a server that was previously shutdown.Thread Safety: This method is thread-safe and uses internal locking to ensure only one server instance can be started at a time. If multiple threads attempt to start the server concurrently, only one will succeed and the others will receive a
ServerManagerException.Lifecycle:
- If the server is already running, throws a
ServerManagerException - On successful start, the server manager becomes operational and ready for use
- On failure or timeout, the server process is cleaned up and the error state is restored
Relationship with other methods:
ServerManager.shutdown()must be called before callingstart()again to restart a serverServerManager.close()may shutdown the server if configured withshutdownOnClose
- Specified by:
startin interfaceServerManager- Parameters:
timeout- the maximum time to wait for the server to startunit- the time unit for the timeout parameter- Returns:
- this server manager instance
- If the server is already running, throws a
-
startAsync
Description copied from interface:ServerManagerAsynchronously starts a server and waits the amount of time defined by the timeout and the time unit.- Specified by:
startAsyncin interfaceServerManager- Parameters:
timeout- the timeoutunit- the unit for the timeout- Returns:
- a completion stage with the started server if the server starts within timeout constraints
- See Also:
-
shutdown
Description copied from interface:ServerManagerShuts down the server and wait for the servers to be shutdown.- Specified by:
shutdownin interfaceServerManager- 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
-
shutdownAsync
Description copied from interface:ServerManagerShuts down the server.The returned
ServerManageris the same instance of this server manager. You can use theCompletableFuture.get()to wait until the process, if available, to exit.Note for implementations. The default method should likely not be used. Care must be taken to ensure a
TimeoutExceptionon aCompletableFuture.get()stops the shutdown from continuing to run in the background.- Specified by:
shutdownAsyncin interfaceServerManager- Parameters:
timeout- the graceful shutdown timeout, a value of-1will wait indefinitely and a value of0will not attempt a graceful shutdown- Returns:
- a completable future that on a
CompletableFuture.get()will wait for the process, if available, exits
-
isClosed
public boolean isClosed()Description copied from interface:ServerManagerChecks if this server manager has been closed. The server manager may be closed if the underlying client was closed.- Specified by:
isClosedin interfaceServerManager- Returns:
trueif the server manager was closed, otherwisefalse
-
close
public void close()Description copied from interface:ServerManager- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceServerManager
-
deploy
Description copied from interface:ServerManagerDeploys content to the server. This will fireServerManagerListener.beforeDeploy(ServerManager, Deployment)before the deployment andServerManagerListener.afterDeploy(ServerManager, Deployment)after a successful deployment. If the deployment fails,ServerManagerListener.deployFailed(ServerManager, Deployment, Throwable)will be invoked to allow listeners to clean up any resources.- Specified by:
deployin interfaceServerManager- Parameters:
deployment- the deployment to deploy to the server- Returns:
- this server manager
-
undeploy
Description copied from interface:ServerManagerUndeploys content from the server. This will fireServerManagerListener.beforeUndeploy(ServerManager, DeploymentDescription)before undeploying andServerManagerListener.afterUndeploy(ServerManager, DeploymentDescription)after a successful undeployment. If the undeployment fails,ServerManagerListener.undeployFailed(ServerManager, DeploymentDescription, Throwable)will be invoked.- Specified by:
undeployin interfaceServerManager- Parameters:
deployment- the deployment description for the deployment to undeploy- Returns:
- this server manager
-