- java.lang.Object
-
- org.wildfly.plugin.core.ServerHelper
-
public class ServerHelper extends Object
- Author:
- James R. Perkins
-
-
Constructor Summary
Constructors Constructor Description ServerHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.jboss.dmr.ModelNodedetermineHostAddress(org.jboss.as.controller.client.ModelControllerClient client)Determines the address for the host being used.static ContainerDescriptiongetContainerDescription(org.jboss.as.controller.client.ModelControllerClient client)Returns the description of the running container.static booleanisDomainRunning(org.jboss.as.controller.client.ModelControllerClient client)Checks to see if the domain is running.static booleanisStandaloneRunning(org.jboss.as.controller.client.ModelControllerClient client)Checks to see if a standalone server is running.static booleanisValidHomeDirectory(String path)Checks whether or not the directory is a valid home directory for a server.static booleanisValidHomeDirectory(Path path)Checks whether or not the directory is a valid home directory for a server.static voidshutdownDomain(org.jboss.as.controller.client.ModelControllerClient client)Shuts down a managed domain container.static voidshutdownDomain(org.jboss.as.controller.client.ModelControllerClient client, int timeout)Shuts down a managed domain container.static voidshutdownStandalone(org.jboss.as.controller.client.ModelControllerClient client)Shuts down a standalone server.static voidshutdownStandalone(org.jboss.as.controller.client.ModelControllerClient client, int timeout)Shuts down a standalone server.static voidwaitForDomain(Process process, org.jboss.as.controller.client.ModelControllerClient client, long startupTimeout)Waits the given amount of time in seconds for a managed domain to start.static voidwaitForDomain(org.jboss.as.controller.client.ModelControllerClient client, long startupTimeout)Waits the given amount of time in seconds for a managed domain to start.static voidwaitForStandalone(Process process, org.jboss.as.controller.client.ModelControllerClient client, long startupTimeout)Waits the given amount of time in seconds for a standalone server to start.static voidwaitForStandalone(org.jboss.as.controller.client.ModelControllerClient client, long startupTimeout)Waits the given amount of time in seconds for a standalone server to start.
-
-
-
Method Detail
-
isValidHomeDirectory
public static boolean isValidHomeDirectory(Path path)
Checks whether or not 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
public static boolean isValidHomeDirectory(String path)
Checks whether or not 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
-
getContainerDescription
public static ContainerDescription getContainerDescription(org.jboss.as.controller.client.ModelControllerClient client) throws IOException, OperationExecutionException
Returns the description of the running container.- Parameters:
client- the client used to query the server- Returns:
- the description of the running container
- Throws:
IOException- if an error occurs communicating with the serverOperationExecutionException- if the operation used to query the container fails
-
waitForDomain
public static void waitForDomain(org.jboss.as.controller.client.ModelControllerClient client, long startupTimeout) throws InterruptedException, RuntimeException, TimeoutExceptionWaits the given amount of time in seconds for a managed domain to start. A domain is considered started when each of the servers in the domain are started unless the server is disabled.- Parameters:
client- the client used to communicate with the serverstartupTimeout- the time, in seconds, to wait for the server start- Throws:
InterruptedException- if interrupted while waiting for the server to startRuntimeException- if the process has diedTimeoutException- if the timeout has been reached and the server is still not started
-
waitForDomain
public static void waitForDomain(Process process, org.jboss.as.controller.client.ModelControllerClient client, long startupTimeout) throws InterruptedException, RuntimeException, TimeoutException
Waits the given amount of time in seconds for a managed domain to start. A domain is considered started when each of the servers in the domain are started unless the server is disabled.If the
processis notnulland a timeout occurs the process will be destroyed.- Parameters:
process- the Java process can benullif no process is availableclient- the client used to communicate with the serverstartupTimeout- the time, in seconds, to wait for the server start- Throws:
InterruptedException- if interrupted while waiting for the server to startRuntimeException- if the process has diedTimeoutException- if the timeout has been reached and the server is still not started
-
isDomainRunning
public static boolean isDomainRunning(org.jboss.as.controller.client.ModelControllerClient client)
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.- Parameters:
client- the client used to communicate with the server- Returns:
trueif the server is in a running state, otherwisefalse
-
shutdownDomain
public static void shutdownDomain(org.jboss.as.controller.client.ModelControllerClient client) throws IOException, OperationExecutionExceptionShuts down a managed domain container. The servers are first stopped, then the host controller is shutdown.- Parameters:
client- the client used to communicate with the server- Throws:
IOException- if an error occurs communicating with the serverOperationExecutionException- if the operation used to shutdown the managed domain failed
-
shutdownDomain
public static void shutdownDomain(org.jboss.as.controller.client.ModelControllerClient client, int timeout) throws IOException, OperationExecutionExceptionShuts down a managed domain container. The servers are first stopped, then the host controller is shutdown.- Parameters:
client- the client used to communicate with the servertimeout- 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 serverOperationExecutionException- if the operation used to shutdown the managed domain failed
-
determineHostAddress
public static org.jboss.dmr.ModelNode determineHostAddress(org.jboss.as.controller.client.ModelControllerClient client) throws IOException, OperationExecutionExceptionDetermines the address for the host being used.- Parameters:
client- the client used to communicate with the server- 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
-
waitForStandalone
public static void waitForStandalone(org.jboss.as.controller.client.ModelControllerClient client, long startupTimeout) throws InterruptedException, RuntimeException, TimeoutExceptionWaits the given amount of time in seconds for a standalone server to start.- Parameters:
client- the client used to communicate with the serverstartupTimeout- the time, in seconds, to wait for the server start- Throws:
InterruptedException- if interrupted while waiting for the server to startRuntimeException- if the process has diedTimeoutException- if the timeout has been reached and the server is still not started
-
waitForStandalone
public static void waitForStandalone(Process process, org.jboss.as.controller.client.ModelControllerClient client, long startupTimeout) throws InterruptedException, RuntimeException, TimeoutException
Waits the given amount of time in seconds for a standalone server to start.If the
processis notnulland a timeout occurs the process will be destroyed.- Parameters:
process- the Java process can benullif no process is availableclient- the client used to communicate with the serverstartupTimeout- the time, in seconds, to wait for the server start- Throws:
InterruptedException- if interrupted while waiting for the server to startRuntimeException- if the process has diedTimeoutException- if the timeout has been reached and the server is still not started
-
isStandaloneRunning
public static boolean isStandaloneRunning(org.jboss.as.controller.client.ModelControllerClient client)
Checks to see if a standalone server is running.- Parameters:
client- the client used to communicate with the server- Returns:
trueif the server is running, otherwisefalse
-
shutdownStandalone
public static void shutdownStandalone(org.jboss.as.controller.client.ModelControllerClient client) throws IOExceptionShuts down a standalone server.- Parameters:
client- the client used to communicate with the server- Throws:
IOException- if an error occurs communicating with the server
-
shutdownStandalone
public static void shutdownStandalone(org.jboss.as.controller.client.ModelControllerClient client, int timeout) throws IOExceptionShuts down a standalone server.- Parameters:
client- the client used to communicate with the servertimeout- 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
-
-