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

Step Three - Deploying onto the Service Grid


Tutorial ssummary: In this tutorial you learn how to deploy the Hello World application onto the GigaSpaces Service Grid to achieve fail-over, scaling and self-healing capabilities for your application. Approx 10 min

Overview

Example Folder - \examples\helloworld

Note

Features Introduced - Service Grid, Grid Service Manager (GSM), Grid Service Container (GSC), Failover, Self-Healing, Deployment.

Before you Begin

We recommend that you go through the following steps before starting this tutorial:

  1. Download GigaSpaces and set up your development environment - this is needed to run the tutorial sample application.
  2. Step One - Using Processing Units For Scaling - a short introduction to how processing units are used for scaling your application - Recommended.
  3. Step Two - Creating the Hello World Application - Create and run your first Processing Unit.

Goals

Start the Service Grid components, deploy and run the Hello World application on them, with and without backups. Test failover and SLA capabilities, and monitor the application at runtime.

Steps

  1. Deployment process
  2. Failover to a backup instance
  3. Starting the service grid components - Grid Service Manager (GSM) and Grid Service Containers (GSCs)
  4. Deploying the Hello World application onto the Service Grid.
  5. Running the feeder application
  6. Undeploying the single instance deployment
  7. Deploying the Hello World application with Primary-Backup mode to enable automatic failover

Jump ahead and deploy the sample application, in case you want to see the final result of the tutorial before we begin.

Application Components

The Processing Unit that we deploy onto the Service Grid is our Hello World Processor from the previous step. Reminder - the Feeder application writes each Message object to the processor Processing Unit, which in turn processes them.

Application Components.jpg Figure 1. The Hello World Feeder and Processor Processing Unit

Infrastructure (Service Grid) Components

The Service Grid is a set of containers (Grid Service Containers - GSCs) managed by one or more managers (Grid Service Managers - GSMs). Each Grid Service Container runs inside its own JVM. The containers themselves host Processing Units. The Grid Service Manager manages the deployment of processing units and their provisioning to the the Grid Service Containers. In production scenarios you may want to have more than one manager, so it does not become a single point of failure. The GigaSpaces Management Center is the graphical user interface for administrating and monitoring the Service Grid and the deployed applications.

Infra Components.jpg Figure 2. A Service Grid consisting of a Grid Service Manager and two Grid Service Containers

Deployment Overview

In this tutorial we deploy the Hello World Processor onto the service Grid, first as a single instance (Figure 3), then with an additional backup instance to support failover (Figure 4).

Application With Infra.jpg Figure 3. The Hello World Processor deployed onto the Service Grid as a single instance

Sync2Backup With Infra.jpg Figure 4. The Hello World Processor deployed onto the Service Grid with one primary instance and one backup instance

Deployment Process

After the Hello World Processor application is built and put into a JAR file, we start the Service Grid Components. We use the Management Center GUI to deploy the Hello World Processor to the Service Grid, first as a single instance, and then with a backup instance as well, to demonstrate failover.

What happens during the deployment process Deploying a Processing Unit is done by selecting its JAR file for deployment from the Management Center user interface. The JAR is then passed to the Grid Service Manager, which analyzes its deployment requirements (These requirements are expressed in a file called the Deployment Descriptor) The Grid Manager then provisions the Processing Unit instances into the Grid Service Containers, which in turn load the processing unit binaries from the Grid Service Manager and start the Processing Unit instance - see Figure 5 below.

Deploying.jpg Figure 5. Deploying the Processor Processing Unit onto the Service Grid

Failover to a Backup Instance

To achieve failover capabilities and avoid a single point of failure, the Processing Unit is deployed with two instances - a primary and a backup. All objects written to the space of the primary instance are synchronously replicated to the backup instance, thus enabling quick failover to the backup instance in case the primary instance fails. In addition, after the failover, the Grid Service Manager provisions a new backup to another Grid Service Container (if it exists), to maintain high availability for the Processing Unit. This is the self-healing part of the GigaSpaces deployment mechanism.

Failover.jpg Figure 6. Failover to the backup instance after failure of the primary Processing Unit

Feeder View of the Failover Process

Since the feeder interacts with (writes objects to) the space, using a space proxy, which hides the actual deployment topology and runtime status from it, the whole failover process is completely transparent to it. The only noticeable effect may be a slight delay in the space response time to the feeder calls.

Feeder Proxy.jpg Figure 7. The Feeder is using a proxy that automatically connects to the primary Processing Unit

Starting the Service Grid Components and Deploying the Application

Steps to deploy the application:

Install GigaSpaces

After going through the previous tutorial Step Two - Creating the Hello World Application, you should have GigaSpaces installed and the Hello World sample application environment set. If not, please download GigaSpaces and set up your development environment to work with GigaSpaces - this is needed to run the tutorial sample application.

Starting the Service Grid Components

  1. Start GigaSpaces Management Center (GS-UI) by running <GigaSpaces Root>/bin/gs-ui.bat(.sh).
  2. Start a GigaSpaces Agent (GSA) by running <GigaSpaces Root>/bin/gs-agent.(sh/bat). The GSA, by default, will start 2 local Grid Service Containers, and manage a global Grid Service Manager and a global Lookup Service.

The GigaSpaces Agent

The GigaSpaces Agent (GSA) acts as a process manager that can spawn and manage Service Grid processes (Operating System level processes) such as the Grid Service Manager (aka The GigaSpaces Manager), the Grid Service Container (aka The GigaSpaces Container), and Lookup Service.

A new Grid Service Manager starts on your local machine, and its output can be viewed by clicking its name gsm-1 inside the Hosts tab. A new Grid Service Containers start on your local machine, and its output can be viewed by clicking their names gsc-1/gsc-2 inside the Hosts tab. The Grid Service Manger automatically detects the Grid Service Containers. Now we have a Service Grid with one manager and two containers up and running!

(The Service Grid Components started here are local services, all running on your own machine. Naturally, in a production environment, they are started on separate machines, using the startup scripts that the product provides.)

Deploying the Application with No Backup Instances

Prepare the Processor Processing Unit for deployment with No Backups

  1. Build the processor Processing Unit by running <Hello World Example Root>/build.bat(.sh) dist. This compiles the Processor source files and creates the processing unit JAR file, ready for deployment under <Hello World Example Root>/processor/pu/hello-processor.jar.

Deploying the Hello World Processor with No Backup

  1. Click the Deploy Processing Unit Button deploy_processing_unit_button.jpg to open the Deployment Wizard dialog.
  2. Click the Processing Unit field button, to browse for the processing unit JAR file.
  3. Browse to the hello-processor.jar JAR file, located at <Hello World Example Root>/processor/pu folder, and select it.
  4. Click the Deploy button, to deploy and wait for the processing unit to be provisioned to the running Grid Service Container.

Running the Feeder

  1. Start the feeder by running <Hello World Example root>/build.bat(.sh) run-feeder.

Before deploying the application with a backup, we first undeploy the current single instance deployment:

Undeploying the Single Instance Deployment

  1. In the Deployed Processing Units tab, under the Processing Units tree, right click the hello-processor* deployment and click *Undeploy.
  2. Click Yes to approve.

Deploying as a Single Instance with Backup

For Community Edition Users

If you are a community edition user, please note that you will not be able to perform this step since the community edition limits the number of space instances to one

Prepare the Processor Processing Unit for deployment as a single instance with backup

  1. Edit the processor’s pu.xml configuration file located under <GigaSpaces root>/examples/helloworld/processor/src/META-INF/spring folder.
  2. Uncomment (Remove the surrounding ), or add the following SLA bean definition, which contains the deployment configuration, to the pu.xml file:
<os-sla:sla
    cluster-schema="partitioned-sync2backup"
    number-of-instances="1"
    number-of-backups="1"
    max-instances-per-vm="1">
</os-sla:sla>
  1. Build the processor Processing Unit by running <Hello World Example Root>/build.bat(.sh) dist. This compiles the processor into a JAR file, ready for deployment, located under <Hello World Example Root>/processor/pu/hello-processor.jar.

Deploying the Hello World Processor as a Single Instance with Backup

  1. Click the Deploy Processing Unit Button* deploy_processing_unit_button.jpg to open the *Deployment Wizard dialog.
  2. Click the Processing Unit field button, to browse for the processing unit JAR file.
  3. Browse to the hello-processor.jar JAR file, located at <Hello World Example Root>/processor/pu folder, and select it.
  4. Click the Deploy button, to deploy and wait for the processing unit instances to be provisioned to the running Grid Service Containers.

Running the Feeder

  1. Start the feeder by running <Hello World Example root>/build.bat(.sh) run-feeder

What’s Next?

Step Four - Scaling the Hello World Application

Or return to the Quick Start Guide.