Your First Data Grid

This topic helps you get started with the GigaSpaces data grid. You will learn how to create a project that includes a client and a Space. The client connects to the Space, or data grid, with the ability to write and read data. You will also learn how to connect your client to a different Space in order to write and read data.

Installing the GigaSpaces Product

If you haven’t done so yet, download and unzip the software package in your preferred location, and apply the license key.

For more detailed instructions, see the Downloading and Installing and Product License topics in this section.

Interactive Shell

GigaSpaces products are packaged with an interactive shell that lists the available commands when it is launched.

To start the interactive shell:

  • Open a command window from the <GS_HOME>/bin folder and type gs.{sh/bat} to launch the script.

After you launch the script, run the version command to try out the shell. This command prints version information, which you can use to verify that you are running the correct version.

Project Blueprints

GigaSpaces products come packaged with a set of blueprints that can be used to create projects. These blueprints can be generated via the interactive shell. To see information about available blueprints and related commands, type the following:

  • blueprint list - displays a list of available blueprints.
  • blueprint - displays a list of available blueprint commands.

Creating a Project

When you create a project, the blueprint leads you through an interactive work flow where you define a number of options as you create your configuration. Using only the default options in the work flow creates a client application that is configured to use the Space that is generated with it.

When you first begin to generate a blueprint-based project, you can give the project a name. We skip this in the example.

To create a project:

  1. Type blueprint generate. This begins the configuration work flow.

  2. A list of available blueprints is displayed. Press Enter to select the default value (1=client).
  3. The next step is configuring the target path (folder name and location) for the client application files. Press Enter to select the default value (my-client in the product package bin folder).
  4. The client blueprint supports customizing several additional properties, but for now you should use the default values. Press Enter to skip the additional configuration.
  5. The project is created, and the target path is displayed. You are prompted to open the project in your default file explorer.

    Generated project from client at D:\InsightEdge\gigaspaces-insightedge-enterprise-16.2.1\bin\my-client1
    Would you like to open it in file explorer? [y]:

    Press Enter to view the project files.

Project Structure

The project that is created by the client blueprint has the following structure:


  • pom.xml - a standard Maven project descriptor that contains a single Maven dependency on xap-openspace.
  • - a simple Java program with a main method that demonstrates how to connect to an existing Space or how to create an embedded Space.
  • employees.csv - a test resource file with sample data.
  • - a POJO file that contains the employee data model.
  • - a unit test that loads employee data from the resource file, writes the data to the Space, and performs various Space operations.

For more information about using Maven with GigaSpaces products, see Maven Artifacts.

Building and Running the Project

From the Command Line

To build the project:

  1. Open a shell from the my-client folder.

  2. Run the following command to build the project and run the test (as shown in the shell output). The test demonstrates how to write data to the grid, and how to read from the data grid.

    mvn package

In Your Development Environment

You can open any standard Java IDE (for example, Eclipse or IntelliJ IDEA) and import the project using the pom.xml file. After the project is imported, you can run or debug it, and experiment with changing the test to become more familiar with the Space API.

Connecting Your Application to an Existing Space

Starting a Service Grid

A data grid in a local environment is hosted on a service grid. The service grid is comprised of one or more machines (service grid nodes) running a Grid Service Agent (or GSA), and provides a framework to deploy and monitor applications on the data grid.

To start the service grid:

  • To start a service grid with 4 containers, navigate to <GS_HOME>/bin and run the following command:

    <GS_HOME>/bin/ host run-agent --auto --gsc=4
    <GS_HOME>\bin\gs host run-agent --auto --gsc=4

Deploying the Data Grid

After you launch a service grid, you can deploy a data grid and begin to use it.

To deploy the data grid:

  • Open a command window, navigate to <GS_HOME>/bin, and run the following command:

    <GS_HOME>/bin/ space deploy --partitions=2 --ha myGrid
    <GS_HOME>\bin\gs space deploy --partitions=2 --ha myGrid

    This command deploys a data grid (aka Space) called myGrid with 2 partitions and 1 backup per partition.

Interacting with the Data Grid

After the data grid has been deployed, you can run your project again. To connect to the existing Space, change the default Space name to the name of the Space you just created.

To run the project again:

  • Navigate to my-client and type the following in the command line:
 ./ myGrid
 .\run myGrid