ContainerInstall (Apache Geode 1.7.0)
Date: 2018-09-27

org.apache.geode.session.tests

## Class ContainerInstall

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

- Direct Known Subclasses:
    TomcatInstall

      public abstract class ContainerInstall
      extends java.lang.Object

  Base class for handling downloading and configuring J2EE containers. This class contains common logic for downloading and configuring J2EE containers with cargo, and some common methods for applying geode session replication configuration to those containers. Subclasses provide installation of specific containers.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ContainerInstall.ConnectionType` Represents the type of connection used in this installation Supports either PEER_TO_PEER or CLIENT_SERVER.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DEFAULT_INSTALL_DIR`
    `static java.lang.String` | `DEFAULT_MODULE_EXTRACTION_DIR`
    `protected static java.lang.String` | `DEFAULT_MODULE_LOCATION`
    `static java.lang.String` | `GEODE_BUILD_HOME`
    `static org.apache.logging.log4j.Logger` | `logger`
    `static java.lang.String` | `TMP_DIR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ContainerInstall(java.lang.String installDir, java.lang.String downloadURL, ContainerInstall.ConnectionType connType, java.lang.String moduleName)`
    `ContainerInstall(java.lang.String installDir, java.lang.String downloadURL, ContainerInstall.ConnectionType connType, java.lang.String moduleName, java.lang.String geodeModuleLocation)` Base class for handling downloading and configuring J2EE installations This class contains common logic for downloading and configuring J2EE installations with cargo, and some common methods for applying geode session replication configuration to those installations.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearPreviousInstall(java.lang.String installDir)` Cleans up the installation by deleting the extracted module and downloaded installation folders
    `protected static void` | `editPropertyFile(java.lang.String filePath, java.lang.String propertyName, java.lang.String propertyValue, boolean append)` Edits the specified property within the given property file
    `protected static void` | `editXMLFile(java.lang.String XMLPath, java.lang.String tagName, java.lang.String parentTagName, java.util.HashMap<java.lang.String,java.lang.String> attributes)`
    `protected static void` | `editXMLFile(java.lang.String XMLPath, java.lang.String tagName, java.lang.String parentTagName, java.util.HashMap<java.lang.String,java.lang.String> attributes, boolean writeOnSimilarAttributeNames)`
    `protected static void` | `editXMLFile(java.lang.String XMLPath, java.lang.String tagId, java.lang.String tagName, java.lang.String parentTagName, java.util.HashMap<java.lang.String,java.lang.String> attributes)`
    `protected static void` | `editXMLFile(java.lang.String XMLPath, java.lang.String tagName, java.lang.String replacementTagName, java.lang.String parentTagName, java.util.HashMap<java.lang.String,java.lang.String> attributes, boolean writeOnSimilarAttributeNames)`
    `protected static void` | `editXMLFile(java.lang.String XMLPath, java.lang.String tagId, java.lang.String tagName, java.lang.String replacementTagName, java.lang.String parentTagName, java.util.HashMap<java.lang.String,java.lang.String> attributes, boolean writeOnSimilarAttributeNames)` Edit the given xml file Uses `findNodeWithAttribute(Document, String, String, String)`, `rewriteNodeAttributes(Node, HashMap)`, `nodeHasExactAttributes(Node, HashMap, boolean)` to edit the required parts of the XML file.
    `protected static java.lang.String` | `findAndExtractModule(java.lang.String geodeModuleLocation, java.lang.String moduleName)` Finds and extracts the geode module associated with the specified module.
    `protected static java.lang.String` | `findSessionTestingWar()` Get the path to the session testing war by walking up directories to the correct folder.
    `ServerContainer` | `generateContainer(java.io.File containerConfigHome)`
    `abstract ServerContainer` | `generateContainer(java.io.File containerConfigHome, java.lang.String containerDescriptors)` Generates a `ServerContainer` from the given `ContainerInstall`
    `ServerContainer` | `generateContainer(java.lang.String containerDescriptors)`
    `java.io.File` | `getCacheXMLFile()` Gets the cache XML file to use by default for this installation
    `ContainerInstall.ConnectionType` | `getConnectionType()`
    `abstract java.lang.String` | `getContextSessionManagerClass()` Get the session manager class to use
    `java.lang.String` | `getDefaultLocatorAddress()` Gets the `defaultLocatorAddress` This is the address that a container uses by default.
    `int` | `getDefaultLocatorPort()` Gets the `defaultLocatorPort` This is the port that a container uses by default.
    `java.lang.String` | `getHome()` Where the installation is located
    `abstract java.lang.String` | `getInstallDescription()` A human readable description of the installation
    `abstract java.lang.String` | `getInstallId()` Cargo specific string to identify the container with
    `java.lang.String` | `getModulePath()` Where the module is located The module contains jars needed for geode session setup as well as default templates for some needed XML files.
    `java.lang.String` | `getWarFilePath()` The path to the session testing WAR file
    `boolean` | `isClientServer()` Whether the installation is client server Since an installation can only be client server or peer to peer there is no need for a function which checks for a peer to peer installation (just check if not client server).
    `void` | `setDefaultLocator(java.lang.String address, int port)` Sets the default locator address and port

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

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

- - ### Field Detail

    - #### logger

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

    - #### TMP_DIR

          public static final java.lang.String TMP_DIR

    - #### GEODE_BUILD_HOME

          public static final java.lang.String GEODE_BUILD_HOME

    - #### DEFAULT_INSTALL_DIR

          public static final java.lang.String DEFAULT_INSTALL_DIR

    - #### DEFAULT_MODULE_LOCATION

          protected static final java.lang.String DEFAULT_MODULE_LOCATION

    - #### DEFAULT_MODULE_EXTRACTION_DIR

          public static final java.lang.String DEFAULT_MODULE_EXTRACTION_DIR

  - ### Constructor Detail

    - #### ContainerInstall

          public ContainerInstall(java.lang.String installDir,
                                  java.lang.String downloadURL,
                                  ContainerInstall.ConnectionType connType,
                                  java.lang.String moduleName)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### ContainerInstall

          public ContainerInstall(java.lang.String installDir,
                                  java.lang.String downloadURL,
                                  ContainerInstall.ConnectionType connType,
                                  java.lang.String moduleName,
                                  java.lang.String geodeModuleLocation)
                           throws java.io.IOException

      Base class for handling downloading and configuring J2EE installations This class contains common logic for downloading and configuring J2EE installations with cargo, and some common methods for applying geode session replication configuration to those installations. Subclasses provide installation of specific containers.
      Parameters:
        `connType` - Enum representing the connection type of this installation (either client server or peer to peer)
        `moduleName` - The module name of the installation being setup (i.e. tomcat, appserver, etc.)
      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### generateContainer

          public ServerContainer generateContainer(java.io.File containerConfigHome)
                                            throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### generateContainer

          public ServerContainer generateContainer(java.lang.String containerDescriptors)
                                            throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### clearPreviousInstall

          public void clearPreviousInstall(java.lang.String installDir)
                                    throws java.io.IOException

      Cleans up the installation by deleting the extracted module and downloaded installation folders
      Throws:
        `java.io.IOException`

    - #### setDefaultLocator

          public void setDefaultLocator(java.lang.String address,
                                        int port)

      Sets the default locator address and port

    - #### isClientServer

          public boolean isClientServer()

      Whether the installation is client server Since an installation can only be client server or peer to peer there is no need for a function which checks for a peer to peer installation (just check if not client server).

    - #### getHome

          public java.lang.String getHome()

      Where the installation is located

    - #### getModulePath

          public java.lang.String getModulePath()

      Where the module is located The module contains jars needed for geode session setup as well as default templates for some needed XML files.

    - #### getWarFilePath

          public java.lang.String getWarFilePath()

      The path to the session testing WAR file

    - #### getConnectionType

          public ContainerInstall.ConnectionType getConnectionType()

      Returns:
        The enum `connType` which represents the type of connection for this installation

    - #### getDefaultLocatorAddress

          public java.lang.String getDefaultLocatorAddress()

      Gets the `defaultLocatorAddress` This is the address that a container uses by default. Containers themselves can have their own personal locator address, but will default to this address unless specifically set.

    - #### getDefaultLocatorPort

          public int getDefaultLocatorPort()

      Gets the `defaultLocatorPort` This is the port that a container uses by default. Containers themselves can have their own personal locator port, but will default to this port unless specifically set.

    - #### getCacheXMLFile

          public java.io.File getCacheXMLFile()

      Gets the cache XML file to use by default for this installation

    - #### getInstallId

          public abstract java.lang.String getInstallId()

      Cargo specific string to identify the container with

    - #### getInstallDescription

          public abstract java.lang.String getInstallDescription()

      A human readable description of the installation

    - #### getContextSessionManagerClass

          public abstract java.lang.String getContextSessionManagerClass()

      Get the session manager class to use

    - #### generateContainer

          public abstract ServerContainer generateContainer(java.io.File containerConfigHome,
                                                            java.lang.String containerDescriptors)
                                                     throws java.io.IOException

      Generates a `ServerContainer` from the given `ContainerInstall`
      Parameters:
        `containerDescriptors` - Additional descriptors used to identify a container
      Throws:
        `java.io.IOException`

    - #### findSessionTestingWar

          protected static java.lang.String findSessionTestingWar()

      Get the path to the session testing war by walking up directories to the correct folder. NOTE::This walks into the extensions folder and then uses a hardcoded path from there making it very unreliable if things are moved.

    - #### findAndExtractModule

          protected static java.lang.String findAndExtractModule(java.lang.String geodeModuleLocation,
                                                                 java.lang.String moduleName)
                                                          throws java.io.IOException

      Finds and extracts the geode module associated with the specified module.
      Parameters:
        `moduleName` - The module name (i.e. tomcat, appserver, etc.) of the module that should be extract. Used as a search parameter to find the module archive.
      Returns:
        The path to the non-archive (extracted) version of the module files
      Throws:
        `java.io.IOException`

    - #### editPropertyFile

          protected static void editPropertyFile(java.lang.String filePath,
                                                 java.lang.String propertyName,
                                                 java.lang.String propertyValue,
                                                 boolean append)
                                          throws java.lang.Exception

      Edits the specified property within the given property file
      Parameters:
        `filePath` - path to the property file
        `propertyName` - property name to edit
        `propertyValue` - new property value
        `append` - whether or not to append the given property value. If true appends the given property value the current value. If false, replaces the current property value with the given property value
      Throws:
        `java.lang.Exception`

    - #### editXMLFile

          protected static void editXMLFile(java.lang.String XMLPath,
                                            java.lang.String tagId,
                                            java.lang.String tagName,
                                            java.lang.String parentTagName,
                                            java.util.HashMap<java.lang.String,java.lang.String> attributes)

    - #### editXMLFile

          protected static void editXMLFile(java.lang.String XMLPath,
                                            java.lang.String tagName,
                                            java.lang.String parentTagName,
                                            java.util.HashMap<java.lang.String,java.lang.String> attributes)

    - #### editXMLFile

          protected static void editXMLFile(java.lang.String XMLPath,
                                            java.lang.String tagName,
                                            java.lang.String parentTagName,
                                            java.util.HashMap<java.lang.String,java.lang.String> attributes,
                                            boolean writeOnSimilarAttributeNames)

    - #### editXMLFile

          protected static void editXMLFile(java.lang.String XMLPath,
                                            java.lang.String tagName,
                                            java.lang.String replacementTagName,
                                            java.lang.String parentTagName,
                                            java.util.HashMap<java.lang.String,java.lang.String> attributes,
                                            boolean writeOnSimilarAttributeNames)

    - #### editXMLFile

          protected static void editXMLFile(java.lang.String XMLPath,
                                            java.lang.String tagId,
                                            java.lang.String tagName,
                                            java.lang.String replacementTagName,
                                            java.lang.String parentTagName,
                                            java.util.HashMap<java.lang.String,java.lang.String> attributes,
                                            boolean writeOnSimilarAttributeNames)

      Edit the given xml file Uses `findNodeWithAttribute(Document, String, String, String)`, `rewriteNodeAttributes(Node, HashMap)`, `nodeHasExactAttributes(Node, HashMap, boolean)` to edit the required parts of the XML file.
      Parameters:
        `XMLPath` - The path to the xml file to edit
        `tagId` - The id of tag to edit. If null, then this method will add a new xml element, unless writeOnSimilarAttributeNames is set to true.
        `tagName` - The name of the xml element to edit
        `replacementTagName` - The new name of the XML attribute that is being edited
        `parentTagName` - The parent element of the element we should edit
        `attributes` - the xml attributes for the element to edit
        `writeOnSimilarAttributeNames` - If true, find an existing element with the same set of attributes as the attributes parameter, and modifies the attributes of that element, rather than adding a new element. If false, create a new XML element (unless tagId is not null).