Package org.wildfly.plugin.tools.server

## Class DomainManager

- java.lang.Object
- - org.wildfly.plugin.tools.server.DomainManager

- All Implemented Interfaces:
    `ServerManager`

      public class DomainManager
      extends Object

  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

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected ProcessHandle` | `process` |

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `DomainManager​(ProcessHandle process, org.jboss.as.controller.client.helpers.domain.DomainClient client)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `org.jboss.as.controller.client.ModelControllerClient` | `client()` | Returns the client associated with this server manager.
    `ContainerDescription` | `containerDescription()` | Returns the container description for the running server.
    `DeploymentManager` | `deploymentManager()` | Returns the deployment manager for the server.
    `org.jboss.dmr.ModelNode` | `determineHostAddress()` | Determines the address for the host being used.
    `void` | `executeReload()` | Reloads the server and returns immediately.
    `void` | `executeReload​(org.jboss.dmr.ModelNode reloadOp)` | Reloads the server and returns immediately.
    `boolean` | `isRunning()` | Checks to see if the domain is running.
    `String` | `launchType()` | Determines the servers "launch-type".
    `void` | `reloadIfRequired()` | 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.
    `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.
    `String` | `serverState()` | Gets the "server-state" for standalone servers or the "host-state" for domain servers.
    `void` | `shutdown()` | Shuts down the server.
    `void` | `shutdown​(long timeout)` | Shuts down the server.
    `String` | `takeSnapshot()` | Takes a snapshot of the current servers configuration and returns the relative file name of the snapshot.
    `boolean` | `waitFor​(long startupTimeout, TimeUnit unit)` | 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

      `waitFor`

- - ### Field Detail

    - #### process

          protected final ProcessHandle process

  - ### Constructor Detail

    - #### DomainManager

          protected DomainManager​(ProcessHandle process,
                                  org.jboss.as.controller.client.helpers.domain.DomainClient client)

  - ### Method Detail

    - #### client

          public org.jboss.as.controller.client.ModelControllerClient client()

      Description copied from interface: `ServerManager`
      Returns the client associated with this server manager.
      Returns:
        a client to communicate with the server

    - #### serverState

          public String 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,
                                                              IOException

      Determines the address for the host being used.
      Returns:
        the address of the host
      Throws:
        `IOException` - if an error occurs communicating with the server
        `OperationExecutionException` - 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, otherwise `false`

    - #### shutdown

          public void shutdown()
                        throws IOException,
                               OperationExecutionException

      Description copied from interface: `ServerManager`
      Shuts down the server.
      Throws:
        `IOException` - if an error occurs communicating with the server
        `OperationExecutionException`

    - #### shutdown

          public void shutdown​(long timeout)
                        throws IOException

      Description copied from interface: `ServerManager`
      Shuts down the server.
      Parameters:
        `timeout` - the graceful shutdown timeout, a value of `-1` will wait indefinitely and a value of `0` will not attempt a graceful shutdown
      Throws:
        `IOException` - if an error occurs communicating with the server

    - #### executeReload

          public void executeReload()

      Description copied from interface: `ServerManager`
      Reloads the server and returns immediately.

    - #### reloadIfRequired

          public void reloadIfRequired()
                                throws IOException

      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 with a 10 second timeout.
      Throws:
        `IOException` - if an error occurs communicating with the server
      See Also:
        `ServerManager.reloadIfRequired(long, TimeUnit)`

    - #### reloadIfRequired

          public void reloadIfRequired​(long timeout,
                                       TimeUnit unit)
                                throws IOException

      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 reload
        `unit` - the time unit for the `timeout` argument
      Throws:
        `IOException` - if an error occurs communicating with the server

    - #### containerDescription

          public ContainerDescription containerDescription()
                                                    throws IOException

      Description copied from interface: `ServerManager`
      Returns the container description for the running server.
      Specified by:
        `containerDescription` in interface `ServerManager`
      Returns:
        the container description for the running server
      Throws:
        `IOException` - if an error occurs communicating with the server

    - #### deploymentManager

          public DeploymentManager deploymentManager()

      Description copied from interface: `ServerManager`
      Returns the deployment manager for the server.
      Specified by:
        `deploymentManager` in interface `ServerManager`
      Returns:
        the deployment manager

    - #### launchType

          public String launchType()

      Determines the servers "launch-type".
      Specified by:
        `launchType` in interface `ServerManager`
      Returns:
        the servers launch-type or "unknown" if it could not be determined

    - #### waitFor

          public boolean waitFor​(long startupTimeout,
                                 TimeUnit unit)
                          throws InterruptedException

      Description copied from interface: `ServerManager`
      Waits the given amount of time for a server to start.

      If the `process` is not `null` and a timeout occurs the process will be destroyed.

      Specified by:
        `waitFor` in interface `ServerManager`
      Parameters:
        `startupTimeout` - the time, to wait for the server start
        `unit` - the time unit for the `startupTimeout` 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

          public 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-snapshot` operation with no arguments.

      Specified by:
        `takeSnapshot` in interface `ServerManager`
      Returns:
        the file name of the snapshot configuration file
      Throws:
        `IOException` - if an error occurs executing the operation

    - #### executeReload

          public void executeReload​(org.jboss.dmr.ModelNode reloadOp)

      Reloads the server and returns immediately.
      Specified by:
        `executeReload` in interface `ServerManager`
      Parameters:
        `reloadOp` - the reload operation to execute