This page describes an older version of the product. The latest stable version is 14.5.

XAP in 5 Minutes

This tutorial explains how to deploy and use a XAP Data Grid from a Java client application.

Starting a Service Grid

A Data Grid requires a Service Grid to host it. A service grid is composed of one or more machines (service grid nodes) running a Service Grid Agent (or GSA), and provides a framework to deploy and monitor applications on those machines, in our case the Data Grid.

In this tutorial you’ll launch a single node service grid on your machine. To start the service grid, simply run the gs-agent script from the product’s bin folder.

./gs-agent.sh

gs-agent.bat

The Web Console

XAP provides a web-based tool for monitoring and management. From the bin folder start the gs-webui script, then browse to localhost:8099. Click the ‘Login’ button and take a look at the Hosts tab - you’ll see the service grid components created on your machine.

Deploying the Data Grid

The Data grid can be deployed from command line, from the web management tool or via an Administration API. In this tutorial we’ll use the command line.

Start a command line, navigate to the product’s bin folder and run the following command:

./gs.sh deploy-space -cluster total_members=2,1 myGrid

gs.bat deploy-space -cluster total_members=2,1 myGrid

This command deploys a Data Grid (aka space) called myGrid with 2 partitions and 1 backup per partition (hence the 2,1 syntax).

If you’re using the web console mentioned above to see what’s going on, you’ll see the data grid has been deployed.

Interacting with the Data Grid

Connecting to the Grid

Since the Data grid is not located in our client process, we need some sort of address to find it. Data grids are searched using a SpaceProxyConfigurer("spaceName"). This roughly translates to: find a remote Space called spaceName.

The result is a GigaSpace instance, which is a proxy to the myGrid data grid.

See also:

For more information on the SpaceProxyConfigurer and GigaSpaceConfigurer see SpaceURL

Implementing a POJO

We now have a GigaSpace instance connected to our grid, which we can use to store and retrieve entries. But what shall we write? Actually, any POJO can be stored in the space, so long as it has a default constructor and an ID property. For this tutorial let’s define a Person class with the following properties: