Class ServerReload

java.lang.Object
org.jboss.resteasy.utils.ServerReload

public class ServerReload extends Object
Utilities for handling server reloads.
Author:
Stuart Douglas, James R. Perkins
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default time, in ms, to wait for reload to complete.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    executeReload(org.jboss.as.controller.client.ModelControllerClient client)
    Reloads the server and returns immediately.
    static void
    executeReload(org.jboss.as.controller.client.ModelControllerClient client, org.jboss.dmr.ModelNode reloadOp)
    Reloads the server and returns immediately.
    static void
    executeReloadAndWaitForCompletion(org.jboss.as.controller.client.ModelControllerClient client)
    Executes a reload operation and waits the default timeout for the reload to complete.
    static void
    executeReloadAndWaitForCompletion(org.jboss.as.controller.client.ModelControllerClient client, int timeout)
    Executes a reload operation and waits a configurable maximum time for the reload to complete.
    static void
    executeReloadAndWaitForCompletion(org.jboss.as.controller.client.ModelControllerClient client, String serverConfig)
    Executes a reload operation and waits a configurable maximum time for the reload to complete.
    static void
    executeReloadAndWaitForCompletion(org.jboss.as.controller.client.ModelControllerClient client, org.jboss.dmr.ModelNode reloadOp)
    Executes a reload operation and waits the default timeout for the reload to complete.
    static void
    executeReloadAndWaitForCompletion(org.jboss.as.controller.client.ModelControllerClient client, org.jboss.dmr.ModelNode reloadOp, int timeout)
    Executes a reload operation and waits a configurable maximum time for the reload to complete.
    static String
    getContainerRunningState(org.jboss.as.controller.client.ModelControllerClient client)
    Returns the current running state, server-state, of the server.
    static void
    reloadIfRequired(org.jboss.as.controller.client.ModelControllerClient client)
    Checks if the container status is "reload-required" and if it's the case executes reload and waits for completion.
    takeSnapshot(int port)
    Takes a snapshot of the current state of the server.
    takeSnapshot(org.jboss.as.controller.client.ModelControllerClient client)
    Takes a snapshot of the current state of the server.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TIMEOUT

      public static final int TIMEOUT
      Default time, in ms, to wait for reload to complete.
      See Also:
  • Constructor Details

    • ServerReload

      public ServerReload()
  • Method Details

    • executeReload

      public static void executeReload(org.jboss.as.controller.client.ModelControllerClient client)
      Reloads the server and returns immediately.
      Parameters:
      client - the client used to execute the reload operation
    • executeReload

      public static void executeReload(org.jboss.as.controller.client.ModelControllerClient client, org.jboss.dmr.ModelNode reloadOp)
      Reloads the server and returns immediately.
      Parameters:
      client - the client used to execute the reload operation
      reloadOp - the reload operation to execute
    • executeReloadAndWaitForCompletion

      public static void executeReloadAndWaitForCompletion(org.jboss.as.controller.client.ModelControllerClient client)
      Executes a reload operation and waits the default timeout for the reload to complete.
      Parameters:
      client - the client to use for the request. Cannot be null
      Throws:
      AssertionError - if the reload does not complete within the timeout
    • executeReloadAndWaitForCompletion

      public static void executeReloadAndWaitForCompletion(org.jboss.as.controller.client.ModelControllerClient client, org.jboss.dmr.ModelNode reloadOp)
      Executes a reload operation and waits the default timeout for the reload to complete.
      Parameters:
      client - the client to use for the request. Cannot be null
      reloadOp - the operation used for the reload
      Throws:
      AssertionError - if the reload does not complete within the timeout
    • executeReloadAndWaitForCompletion

      public static void executeReloadAndWaitForCompletion(org.jboss.as.controller.client.ModelControllerClient client, int timeout)
      Executes a reload operation and waits a configurable maximum time for the reload to complete.
      Parameters:
      client - the client to use for the request. Cannot be null
      timeout - maximum time to wait for the reload to complete, in milliseconds
      Throws:
      AssertionError - if the reload does not complete within the specified timeout
    • executeReloadAndWaitForCompletion

      public static void executeReloadAndWaitForCompletion(org.jboss.as.controller.client.ModelControllerClient client, org.jboss.dmr.ModelNode reloadOp, int timeout)
      Executes a reload operation and waits a configurable maximum time for the reload to complete.
      Parameters:
      client - the client to use for the request. Cannot be null
      reloadOp - the operation used for the reload
      timeout - maximum time to wait for the reload to complete, in milliseconds
      Throws:
      AssertionError - if the reload does not complete within the specified timeout
    • executeReloadAndWaitForCompletion

      public static void executeReloadAndWaitForCompletion(org.jboss.as.controller.client.ModelControllerClient client, String serverConfig)
      Executes a reload operation and waits a configurable maximum time for the reload to complete.
      Parameters:
      client - the client to use for the request. Cannot be null
      serverConfig - the server configuration file
      Throws:
      AssertionError - if the reload does not complete within the specified timeout
    • getContainerRunningState

      public static String getContainerRunningState(org.jboss.as.controller.client.ModelControllerClient client) throws IOException
      Returns the current running state, server-state, of the server.
      Parameters:
      client - the client used to execute the operation
      Returns:
      the running state or "failed" if the operation was unsuccessful
      Throws:
      IOException - if a communication error occurs
    • reloadIfRequired

      public static void reloadIfRequired(org.jboss.as.controller.client.ModelControllerClient client) throws Exception
      Checks if the container status is "reload-required" and if it's the case executes reload and waits for completion.
      Parameters:
      client - the client used to execute the operation
      Throws:
      IOException - if a communication error occurs
      Exception
    • takeSnapshot

      public static AutoCloseable takeSnapshot(int port)
      Takes a snapshot of the current state of the server.

      Returns a AutoCloseable that can be used to restore the server state

      Parameters:
      port - the port to create the client for
      Returns:
      A closeable that can be used to restore the server
    • takeSnapshot

      public static AutoCloseable takeSnapshot(org.jboss.as.controller.client.ModelControllerClient client)
      Takes a snapshot of the current state of the server.

      Returns a AutoCloseable that can be used to restore the server state

      Parameters:
      client - The client
      Returns:
      A closeable that can be used to restore the server