Package org.wildfly.plugin.tools.server
Class DomainManager
java.lang.Object
org.wildfly.plugin.tools.server.DomainManager
- All Implemented Interfaces:
AutoCloseable
,ServerManager
A utility for executing management operations on domain servers.
- Author:
- James R. Perkins
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.wildfly.plugin.tools.server.ServerManager
ServerManager.Builder
-
Field Summary
FieldsFields inherited from interface org.wildfly.plugin.tools.server.ServerManager
TIMEOUT
-
Method Summary
Modifier and TypeMethodDescriptionorg.jboss.as.controller.client.ModelControllerClient
client()
Returns the client associated with this server manager.void
close()
Returns the container description for the running server.Returns the deployment manager for the server.org.jboss.dmr.ModelNode
Determines the address for the host being used.void
Reloads the server and returns immediately.void
executeReload
(org.jboss.dmr.ModelNode reloadOp) Reloads the server and returns immediately.boolean
isClosed()
Checks if this server manager has been closed.boolean
Checks to see if the domain is running.kill()
Determines the servers "launch-type".void
reloadIfRequired
(long timeout, TimeUnit unit) Checks if the container status is "reload-required" and if it's the case, executes reload and waits for completion.Gets the "server-state" for standalone servers or the "host-state" for domain servers.void
shutdown
(long timeout) Shuts down the server and wait for the servers to be shutdown.shutdownAsync
(long timeout) Shuts down the server.Takes a snapshot of the current servers configuration and returns the relative file name of the snapshot.boolean
Waits the given amount of time for a server to start.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.wildfly.plugin.tools.server.ServerManager
asManaged, executeOperation, executeOperation, reloadIfRequired, shutdown, shutdownAsync, waitFor
-
Field Details
-
process
-
-
Method Details
-
serverState
Description copied from interface:ServerManager
Gets the "server-state" for standalone servers or the "host-state" for domain servers.- Returns:
- the server-state or "failed" if an error occurred
-
determineHostAddress
public org.jboss.dmr.ModelNode determineHostAddress() throws OperationExecutionException, IOExceptionDetermines the address for the host being used.- Returns:
- the address of the host
- Throws:
IOException
- if an error occurs communicating with the serverOperationExecutionException
- if the operation used to determine the host name fails
-
isRunning
public boolean isRunning()Checks to see if the domain is running. If the server is not in admin only mode each servers running state is checked. If any server is not in a started state the domain is not considered to be running.- Returns:
true
if the server is in a running state, otherwisefalse
-
executeReload
Description copied from interface:ServerManager
Reloads the server and returns immediately.- Throws:
IOException
- if an error occurs communicating with the serverOperationExecutionException
-
reloadIfRequired
Description copied from interface:ServerManager
Checks 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 thetimeout
argument- Throws:
IOException
- if an error occurs communicating with the server
-
client
public org.jboss.as.controller.client.ModelControllerClient client()Description copied from interface:ServerManager
Returns the client associated with this server manager.- Specified by:
client
in interfaceServerManager
- Returns:
- a client to communicate with the server
-
containerDescription
Description copied from interface:ServerManager
Returns the container description for the running server.- Specified by:
containerDescription
in interfaceServerManager
- Returns:
- the container description for the running server
- Throws:
IOException
- if an error occurs communicating with the server
-
deploymentManager
Description copied from interface:ServerManager
Returns the deployment manager for the server.- Specified by:
deploymentManager
in interfaceServerManager
- Returns:
- the deployment manager
-
launchType
Determines the servers "launch-type".- Specified by:
launchType
in interfaceServerManager
- Returns:
- the servers launch-type or "unknown" if it could not be determined
-
kill
Description copied from interface:ServerManager
If 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
ServerManager
is the same instance of this server manager. You can use theCompletableFuture.get()
to wait until the process, if available, to exit.- Specified by:
kill
in interfaceServerManager
- Returns:
- a completable future that on a
CompletableFuture.get()
will wait for the process, if available, exits
-
waitFor
Description copied from interface:ServerManager
Waits the given amount of time for a server to start.If the
process
is notnull
and a timeout occurs the process will be destroyed.- Specified by:
waitFor
in interfaceServerManager
- Parameters:
startupTimeout
- the time, to wait for the server startunit
- the time unit for thestartupTimeout
argument- Returns:
true
if the server is up and running,false
if a timeout occurred waiting for the server to be in a running state- Throws:
InterruptedException
- if interrupted while waiting for the server to start
-
takeSnapshot
Takes a snapshot of the current servers configuration and returns the relative file name of the snapshot.This simply executes the
take-snapshot
operation with no arguments.- Specified by:
takeSnapshot
in 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:
executeReload
in interfaceServerManager
- Parameters:
reloadOp
- the reload operation to execute- Throws:
OperationExecutionException
- if the reload operation failsIOException
- if an error occurs communicating with the server
-
shutdown
Description copied from interface:ServerManager
Shuts down the server and wait for the servers to be shutdown.- Specified by:
shutdown
in interfaceServerManager
- Parameters:
timeout
- the graceful shutdown timeout, a value of-1
will wait indefinitely and a value of0
will not attempt a graceful shutdown- Throws:
IOException
- if an error occurs communicating with the server
-
shutdownAsync
Description copied from interface:ServerManager
Shuts down the server.The returned
ServerManager
is 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
TimeoutException
on aCompletableFuture.get()
stops the shutdown from continuing to run in the background.- Specified by:
shutdownAsync
in interfaceServerManager
- Parameters:
timeout
- the graceful shutdown timeout, a value of-1
will wait indefinitely and a value of0
will 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:ServerManager
Checks if this server manager has been closed. The server manager may be closed if the underlying client was closed.- Specified by:
isClosed
in interfaceServerManager
- Returns:
true
if the server manager was closed, otherwisefalse
-
close
public void close()Description copied from interface:ServerManager
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceServerManager
-