GS-Agent

A Processing Unit is deployed to the XAP runtime environment, which is called the service grid. The service grid is responsible for materializing the Processing Unit's configuration, provisioning its instances to the runtime infrastructure and making sure they continue to run properly over time.

The gs-agent script is deprecated as of version 14.0, as noted in the Release Notes. Use the xap host run-agent or insightedge host run-agent command in the new CLI instead.

Usage

To start a service grid on a machine, launch the gs-agent utility located in the $XAP_HOME/bin folder. This will start the Grid Service Agent, which is responsible for starting and managing the other service grid components (GSC, GSM, etc.). Command line arguments are used to specify which service grid components should be started and managed. In general, --process_type=n will start n instances of the specified process_type. Use the global keyword (e.g. --global.process_type=n) to specify that the agent should coordinate the hosting and management of that service with other running agents.

Help

Run the --help or -h command to see all available options:

./gs-agent.sh --help
gs-agent --help

Starting the Data Grid with a Manager

Use the following command to start a single Manager on your local machine (useful for development and testing):

# Starts a local manager:
./gs-agent.sh --manager-local
# Starts a local manager and 2 GSCs:
./gs-agent.sh --manager-local --gsc=2
REM Starts a local manager:
gs-agent --manager-local
REM Starts a local manager and 2 GSCs:
gs-agent --manager-local --gsc=2

To start a highly available cluster of Managers on several hosts, run the following command on each designated host:

# Starts a manager:
./gs-agent.sh --manager
# Starts a manager and 2 GSCs:
./gs-agent.sh --manager --gsc=2
REM Starts a manager:
gs-agent --manager
REM Starts a manager and 2 GSCs:
gs-agent --manager --gsc=2

You also need to configure the XAP_MANAGER_SERVERS environment variable in the list of designated Manager servers.

Starting a Data Grid Without a Manager

If you can't start the Manager for some reason, but you still want high availability, you can select specific host machines as management servers, and start a LUS and GSM on each one:

# Starts a LUS and GSM:
./gs-agent.sh --lus --gsm
# Starts a LUS, GSM and 2 GSCs:
./gs-agent.sh --lus --gsm --gsc=2
REM Starts a LUS and GSM:
gs-agent --lus --gsm
REM Starts a LUS, GSM and 2 GSCs:
gs-agent --lus --gsm --gsc=2

Alternatively, if your environment supports multicast and you prefer a more dynamic approach, you can use the global prefix to indicate that GSMs and LUSs will be automatically started and managed by the collective of gs-agents, instead of explicitly on a specific hosts. For example, to start two global GSM and LUS components across a set of hosts, as well as 2 GSCs on each host, you can use the following command:

# Starts a LUS, GSM and 2 GSCs:
./gs-agent.sh --global.lus=2 --global.gsm=2 --gsc=2
REM Starts a LUS, GSM and 2 GSCs:
gs-agent --global.lus=2 --global.gsm=2 --gsc=2

This configuration is convenient for new users, so it is also the default - running gs-agent without any arguments creates the same environment. If you want to disable the default configuration and start a data grid without any components, run the gs-agent with --zero-defaults or -z. This can be useful if you're planning to use the REST Manager API from another host to add or remove containers.

./gs-agent.sh -z
gs-agent -z

Configuring the Service Grid

Service grid configuration is often comprised of two layers, namely the system-wide configuration and component-specific configuration.

The system-wide configuration specifies the settings that all components share, such as discovery (unicast/multicast), security, zones, etc. These are set using the XAP_OPTIONS_EXT environment variable.

The component-specific configuration specifies settings per component type, for example that the GSC memory limit should be greater than the GSM and LUS limits. These are set using one or more of the following environment variables: XAP_GSA_OPTIONS, XAP_GSC_OPTIONS, XAP_GSM_OPTIONS, XAP_LUS_OPTIONS.

The component-specific configuration overrides the system-wide configuration where there is overlap.

For example:

export XAP_GSA_OPTIONS=-Xmx256m
export XAP_GSC_OPTIONS=-Xms2g -Xmx2g
export XAP_GSM_OPTIONS=-Xmx1g
export XAP_LUS_OPTIONS=-Xmx1g

./gs-agent.sh
set XAP_GSA_OPTIONS=-Xmx256m
set XAP_GSC_OPTIONS=-Xms2g -Xmx2g
set XAP_GSM_OPTIONS=-Xmx1g
set XAP_LUS_OPTIONS=-Xmx1g

call gs-agent.bat

Customizing the GSA Components

The GSA manages different process types. Each process type is defined within the $XAP_HOME/config/gsa directory in an XML file that identifies the process type by name.

You can change the default location of the GSA configuration files using the com.gigaspaces.grid.gsa.config-directory system property.

The following process types have default configurations:

Processes Type Description XML config file name
gsc Defines a Grid Service Container .gsc.xml
gsm Defines a Grid Service Manager gsm.xml
lus Defines a Lookup Service lus.xml
gsm_lus Defines a Grid Service Manager and Lookup Service within the same JVM gsm_lus.xml
esm Defines an Elastic Service Manager, which is required for deploying an Elastic Processing Unit esm.xml

Here is an example of the gsc.xml configuration file:

<process initial-instances="script" shutdown-class="com.gigaspaces.grid.gsa.GigaSpacesShutdownProcessHandler" restart-on-exit="always">
    <script enable="true" work-dir="${com.gs.home}/bin"
            windows="${com.gs.home}/bin/gs.bat" unix="${com.gs.home}/bin/gs.sh">
        <argument>start</argument>
        <argument>"GSC"</argument>
    </script>
    <vm enable="true" work-dir="${com.gs.home}/bin" main-class="com.gigaspaces.start.SystemBoot">
        <input-argument></input-argument>
        <argument>com.gigaspaces.start.services="GSC"</argument>
    </vm>
    <restart-regex>.*java\.lang\.OutOfMemoryError.*</restart-regex>
</process>

The GSA can spawn either a script-based process, or a pure JVM (with its arguments) process. The GSC, for example, allows both types of process spawning.

  • The initial-instances parameter controls what type of spawning will be performed when the GSA spawns processes by itself (and not on demand by the Admin API).
  • The shutdown-class, followed by the restart-on-exit flag, controls whether the process will be restarted upon termination. There are three types of values:
    • always - Always restarts the process if it exits.
    • never - Never restarts the process if it exits.
    • !0 - Restart the process only if the exit code is different than 0.

  • The shutdown-class is an implementation of com.gigaspaces.grid.gsa.ShutdownProcessHandler interface and provides the default shutdown hooks before and after shutdown of a process, to make sure it is shut down properly. The shutdown-class can be omitted.
  • The restart-regex (there can be more than one element) is applied to each console output line of the managed process, and if there is a match, the GSA will automatically restart the process. By default, the GSC will be restarted if there is an OutOfMemoryError.

In addition, within the script tag, you can add the following tags:

  • argument - adds a command ling argument which will be passed to the script. In the gsc.xml example above, there are two command line arguments.
  • environment -adds an environment variable. For example, <environment name="XAP_GSC_OPTIONS">-Xmx1024m</environment> can be used to override the memory for the GSC.

Advanced Configuration

In some scenarios you may need several "flavors' of components (e.g. multiple zones, or different sizes of GSCs, etc.). You can create a custom gs-agent script to manage each of those, or you can do this all within a single agent.

For example, you may want your GS agent to load 2 "small' GSCs (512MB each) in a zone called Small, and 1 "large' GSC (1024MB) in a zone called Large. To achieve this, duplicate the default gsc.xml (which resides in $XAP_HOME/config/gsa) into gsc_small.xml and gsc_large.xml, and modify them to include an environment tag that defines the XAP_GSC_OPTIONSenvironment variable with the required settings:

<process initial-instances="script" shutdown-class="com.gigaspaces.grid.gsa.GigaSpacesShutdownProcessHandler" restart-on-exit="always">
    <script enable="true" work-dir="${com.gs.home}/bin"
            windows="${com.gs.home}\bin\gs.bat" unix="${com.gs.home}/bin/gs.sh">
        <argument>services=GSC</argument>
        <environment name="XAP_COMPONENT_OPTIONS">-Xms512m -Xmx512m -Dcom.gs.zones=Small</environment>
    </script>
    <vm enable="true" work-dir="${com.gs.home}/bin" main-class="com.gigaspaces.start.SystemBoot">
        <input-argument></input-argument>
        <argument>services=GSC</argument>
    </vm>
    <restart-regex>.*java\.lang\.OutOfMemoryError.*</restart-regex>
</process>
<process initial-instances="script" shutdown-class="com.gigaspaces.grid.gsa.GigaSpacesShutdownProcessHandler" restart-on-exit="always">
    <script enable="true" work-dir="${com.gs.home}/bin"
            windows="${com.gs.home}\bin\gs.bat" unix="${com.gs.home}/bin/gs.sh">
        <argument>services=GSC</argument>
        <environment name="XAP_COMPONENT_OPTIONS">-Xms1024m -Xmx1024m -Dcom.gs.zones=Large</environment>
    </script>
    <vm enable="true" work-dir="${com.gs.home}/bin" main-class="com.gigaspaces.start.SystemBoot">
        <input-argument></input-argument>
        <argument>services=GSC</argument>
    </vm>
    <restart-regex>.*java\.lang\.OutOfMemoryError.*</restart-regex>
</process>

Now to start the GS agent, use the following command:

gs-agent --gsc_small=2 --gsc_large