ServerContainer (Apache Geode 1.8.0)
Date: 2018-11-29

org.apache.geode.session.tests

## Class ServerContainer

- java.lang.Object
- - org.apache.geode.session.tests.ServerContainer

- Direct Known Subclasses:
    TomcatContainer

      public abstract class ServerContainer
      extends java.lang.Object

  Base class for handling the setup and configuration of cargo containers This class contains common logic for setting up and configuring cargo containers for J2EE container installations. Also includes some common methods for applying geode session replication configuration to those containers. Subclasses provide setup and configuration of specific containers.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `java.util.HashMap<java.lang.String,java.lang.String>` | `cacheProperties`
    `java.io.File` | `cacheXMLFile`
    `java.lang.String` | `DEFAULT_CONF_DIR`
    `static java.lang.String` | `DEFAULT_CONFIG_DIR`
    `static java.lang.String` | `DEFAULT_LOG_DIR`
    `static java.lang.String` | `DEFAULT_LOGGING_LEVEL`
    `java.lang.String` | `description`
    `java.io.File` | `gemfireLogFile`
    `java.io.File` | `logDir`
    `static org.apache.logging.log4j.Logger` | `logger`
    `java.lang.String` | `loggingLevel`
    `java.util.HashMap<java.lang.String,java.lang.String>` | `systemProperties`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServerContainer(ContainerInstall install, java.io.File containerConfigHome, java.lang.String containerDescriptors)` Sets up the container using the given installation Sets up a bunch of logging files, default locations, and container properties.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cleanUp()` Copies the container configuration (found through `getConfiguration()`) to the logging directory specified by `logDir`
    `void` | `deployWar()` Deploys the `warFile` to the cargo container (`container`).
    `void` | `dumpLogs()`
    `java.lang.String` | `generateUniqueContainerDescription(java.lang.String extraIdentifiers)` Generates a unique, mostly human readable, description string of the container using the installation's description, extraIdentifiers, and the current system nano time
    `java.lang.String` | `getCacheProperty(java.lang.String name)`
    `org.codehaus.cargo.container.configuration.LocalConfiguration` | `getConfiguration()`
    `org.codehaus.cargo.container.InstalledLocalContainer` | `getContainer()`
    `ContainerInstall` | `getInstall()`
    `java.lang.String` | `getLoggingLevel()`
    `java.lang.String` | `getPort()` Get the basic port for the container Calls `getPort()` with the `ServletPropertySet.PORT` option.
    `java.lang.String` | `getPort(java.lang.String portType)` The container's port for the specified port type
    `java.lang.String` | `getRMIPort()` Get the RMI port for the container Calls `getPort()` with the `GeneralPropertySet.RMI_PORT` option.
    `org.codehaus.cargo.container.State` | `getState()`
    `java.lang.String` | `getSystemProperty(java.lang.String name)`
    `java.io.File` | `getWarFile()`
    `java.lang.String` | `setCacheProperty(java.lang.String name, java.lang.String value)` Set a geode session replication property
    `void` | `setCacheXMLFile(java.io.File cacheXMLFile)` Sets the container's cache XML file
    `void` | `setLocator(java.lang.String address, int port)` Sets the container's locator Sets the two variables `locatorAddress` and `locatorPort`.
    `void` | `setLoggingLevel(java.lang.String loggingLevel)` set the container's logging level
    `java.lang.String` | `setSystemProperty(java.lang.String name, java.lang.String value)` Set geode distributed system property
    `void` | `setWarFile(java.io.File warFile)` Sets the war file for this container to deploy and use
    `void` | `start()` Starts this cargo container by picking the container's ports (RMI, AJP, and regular) and calling the cargo container's start function
    `void` | `stop()` Stops this cargo container
    `java.lang.String` | `toString()` Human readable description of the container
    `abstract void` | `writeSettings()` Called before each container startup This is mainly used to write properties to whatever format they need to be in for a given container before the container is started.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### description

          public java.lang.String description

    - #### gemfireLogFile

          public java.io.File gemfireLogFile

    - #### cacheXMLFile

          public java.io.File cacheXMLFile

    - #### logDir

          public java.io.File logDir

    - #### loggingLevel

          public java.lang.String loggingLevel

    - #### cacheProperties

          public java.util.HashMap<java.lang.String,java.lang.String> cacheProperties

    - #### systemProperties

          public java.util.HashMap<java.lang.String,java.lang.String> systemProperties

    - #### DEFAULT_CONF_DIR

          public final java.lang.String DEFAULT_CONF_DIR

    - #### DEFAULT_LOGGING_LEVEL

          public static final java.lang.String DEFAULT_LOGGING_LEVEL

    - #### DEFAULT_LOG_DIR

          public static final java.lang.String DEFAULT_LOG_DIR

      See Also:
        Constant Field Values

    - #### DEFAULT_CONFIG_DIR

          public static final java.lang.String DEFAULT_CONFIG_DIR

    - #### logger

          public static final org.apache.logging.log4j.Logger logger

  - ### Constructor Detail

    - #### ServerContainer

          public ServerContainer(ContainerInstall install,
                                 java.io.File containerConfigHome,
                                 java.lang.String containerDescriptors)
                          throws java.io.IOException

      Sets up the container using the given installation Sets up a bunch of logging files, default locations, and container properties. Creates a whole new cargo configuration and cargo container for the `container` variable.
      Parameters:
        `containerConfigHome` - The folder that the container configuration folder should be setup in
        `containerDescriptors` - A string of extra descriptors for the container used in the containers `description`
      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### generateUniqueContainerDescription

          public java.lang.String generateUniqueContainerDescription(java.lang.String extraIdentifiers)

      Generates a unique, mostly human readable, description string of the container using the installation's description, extraIdentifiers, and the current system nano time

    - #### deployWar

          public void deployWar()

      Deploys the `warFile` to the cargo container (`container`).

    - #### start

          public void start()

      Starts this cargo container by picking the container's ports (RMI, AJP, and regular) and calling the cargo container's start function

    - #### stop

          public void stop()

      Stops this cargo container

    - #### dumpLogs

          public void dumpLogs()
                        throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### cleanUp

          public void cleanUp()
                       throws java.io.IOException

      Copies the container configuration (found through `getConfiguration()`) to the logging directory specified by `logDir`
      Throws:
        `java.io.IOException`

    - #### setLocator

          public void setLocator(java.lang.String address,
                                 int port)
                          throws java.io.IOException

      Sets the container's locator Sets the two variables `locatorAddress` and `locatorPort`. Also calls the `updateLocator()` function to write the updated locator properties to the file.
      Throws:
        `java.io.IOException`

    - #### setCacheXMLFile

          public void setCacheXMLFile(java.io.File cacheXMLFile)
                               throws java.io.IOException

      Sets the container's cache XML file
      Throws:
        `java.io.IOException`

    - #### setCacheProperty

          public java.lang.String setCacheProperty(java.lang.String name,
                                                   java.lang.String value)
                                            throws java.io.IOException

      Set a geode session replication property
      Throws:
        `java.io.IOException`

    - #### setSystemProperty

          public java.lang.String setSystemProperty(java.lang.String name,
                                                    java.lang.String value)
                                             throws java.io.IOException

      Set geode distributed system property
      Throws:
        `java.io.IOException`

    - #### setWarFile

          public void setWarFile(java.io.File warFile)

      Sets the war file for this container to deploy and use

    - #### setLoggingLevel

          public void setLoggingLevel(java.lang.String loggingLevel)

      set the container's logging level

    - #### getContainer

          public org.codehaus.cargo.container.InstalledLocalContainer getContainer()

    - #### getInstall

          public ContainerInstall getInstall()

    - #### getWarFile

          public java.io.File getWarFile()

    - #### getLoggingLevel

          public java.lang.String getLoggingLevel()

    - #### getConfiguration

          public org.codehaus.cargo.container.configuration.LocalConfiguration getConfiguration()

    - #### getState

          public org.codehaus.cargo.container.State getState()

    - #### getCacheProperty

          public java.lang.String getCacheProperty(java.lang.String name)

    - #### getSystemProperty

          public java.lang.String getSystemProperty(java.lang.String name)

    - #### getRMIPort

          public java.lang.String getRMIPort()

      Get the RMI port for the container Calls `getPort()` with the `GeneralPropertySet.RMI_PORT` option.

    - #### getPort

          public java.lang.String getPort()

      Get the basic port for the container Calls `getPort()` with the `ServletPropertySet.PORT` option.

    - #### getPort

          public java.lang.String getPort(java.lang.String portType)

      The container's port for the specified port type

    - #### writeSettings

          public abstract void writeSettings()
                                      throws java.lang.Exception

      Called before each container startup This is mainly used to write properties to whatever format they need to be in for a given container before the container is started. The reason for doing this is to make sure that expensive property updates (such as writing to an XML file or building WAR files from the command line) only happen as often as they are needed. These kinds of updates usually only need to happen on container startup.
      Throws:
        `java.lang.Exception`

    - #### toString

          public java.lang.String toString()

      Human readable description of the container
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        The `description` variable along with the state of this `container`