GigaSpaces Agent

A Processing Unit is deployed to the GigaSpaces 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 gs host run-agent command in the new CLI instead.

Usage

To start a service grid on a machine, launch the GigaSpaces Agent utility located in the $GS_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.

Help

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

./gs.sh host run-agent --help
gs.bat host run-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.sh host run-agent --auto
# Starts a local manager and 2 GSCs:
./gs.sh host run-agent --auto --gsc=2
# REM Starts a local manager:
gs.bat host run-agent --auto
# REM Starts a local manager and 2 GSCs:
gs.bat host run-agent --auto --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.sh host run-agent --manager
# Starts a manager and 2 GSCs:
./gs.sh host run-agent --manager --gsc=2
# REM Starts a manager:
gs.bat host run-agent --manager
# REM Starts a manager and 2 GSCs:
gs.bat host run-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.sh host run-agent --custom=lus=1 --custom=gsm=1
# Starts a LUS, GSM and 2 GSCs:
./gs.sh host run-agent --custom=lus=1 --custom=gsm=1 --custom=gcs=2
# REM Starts a LUS and GSM:
gs.bat host run-agent --custom=lus=1 --custom=gsm=1
# REM Starts a LUS, GSM and 2 GSCs:
gs.bat host run-agent --custom=lus=1 --custom=gsm=1 --custom=gcs=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.sh host run-agent --custom=global.lus=2 --custom=global.gsm=2 --custom=global.gsc=2
# REM Starts a LUS, GSM and 2 GSCs: 
gs.bat host run-agent --custom=global.lus=2 --custom=global.gsm=2 --custom=global.gsc=2

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

# Run the command below if you intend to use the agent to start other service grid components later:
./gs.sh host run-agent (no arguments) 
# Run the command below if you intend to use the agent to start other service grid components later:
gs.bat host run-agent (no arguments) 

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_MANAGER_OPTIONS=-Xmx1g

./gs.sh host run-agent --manager --gsc=4
set XAP_GSA_OPTIONS=-Xmx256m
set XAP_GSC_OPTIONS=-Xms2g -Xmx2g
set XAP_MANAGER_OPTIONS=-Xmx1g

call gs.bat host run-agent --manager --gsc=4

Customizing the GSA Components

The GSA manages different process types. Each process type is defined within the $GS_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:

Process Type Description File Name
manager Defines a GigaSpaces Manager manager.xml
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. The restart-on-exit flag has these types of values:
    • always - Always restart the process if it exits.
    • !0 - Restart the process only if the exit code is different than 0.

    • never - Never restart the process if it exits.
  • 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 GigaSpaces 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 $GS_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 GigaSpaces Agent, use the following command:

./gs.sh host run-agent --custom=gsc_small=2 --custom=gsc_large
gs.bat host run-agent --custom=gsc_small=2 --custom=gsc_large