Summary: Getting started with some deployment setup examples
The Elastic Middleware Services functionality is provided as a technology preview in XAP 7.1. As such, it is subject to API and behavior changes in the next XAP releases without going through the usual deprecation process of the XAP API.

Single laptop environment

To setup a deployment that would run on a single laptop, the defaults of the elastic data-grid deployment need to be modified.

Using the gs-agent script, launch a Grid Service Agent (GSA) that will startup:

  • 1 globally managed lookup service (LUS)    default,
  • 1 Grid Service Manager (GSM)    default,
  • 1 globally managed Elastic Service Manager (ESM),
  • and 0 Grid Service Containers (GSCs).
<GigaSpaces root>/bin/gs-agent gsa.global.esm 1 gsa.gsc 0

Using the code snippet, deploy an elastic partitioned cluster of 8,0 on a dedicated set of GSCs:

public static void main(String[] args) {
	Admin admin = new AdminFactory().createAdmin();
	ElasticServiceManager esm = admin.getElasticServiceManagers().waitForAtLeastOne();
	ProcessingUnit pu = esm.deploy( new ElasticDataGridDeployment("mygrid")
						  .capacity("1G", "2G")
						  .highlyAvailable(false)
						  .maximumJavaHeapSize("250m"));

        //start working with the service
	//Wait for data grid deployment completion
	Space space = pu.waitForSpace();
	space.waitFor(space.getTotalNumberOfInstances());

	GigaSpace gigaSpace = space.getGigaSpace();

	//work with the gigaSpace instance ...
}
  • The capacity was changed to correspond to a typical laptop that has ~4G of RAM. Lets assume we would like to scale from 1G to 2G.
  • The highAvailability parameter is disabled to allow a partitioned cluster to run on a single laptop - otherwise, it will require a different machine to account for the highly-available backup instances.
  • The maximumJavaHeapSize of each GSC was set to 250m (instead of the default 512m).

Multi-tenancy environment

Multi-tenancy controls the isolation of a deployment. By default, a dedicated isolation level is enforced. This means that no two deployments can run on the same machine!

Dedicated Deployment Isolation Level

In the code snippet above, we assumed that only one data-grid can be deployed on the same machine. For another data-grid, we will need to dedicate another machine. This is the most restrictive level.

Public Deployment Isolation Level

When setting up a public deployment isolation level, we agree that there can be multiple data-grid instances deployed on the same machine. This is the least restrictive level.

Using the same code snippet above, but with publicDeploymentIsolation() set, we will be able to deploy two data-grid instances on our single laptop.

public static void main(String[] args) {
	Admin admin = new AdminFactory().createAdmin();
	ElasticServiceManager esm = admin.getElasticServiceManagers().waitForAtLeastOne();
	ProcessingUnit puA = esm.deploy( new ElasticDataGridDeployment("mygrid-A")
						  .capacity("1G", "2G")
						  .highlyAvailable(false)
						  .maximumJavaHeapSize("250m")
						  .publicDeploymentIsolation());

	ProcessingUnit puB = esm.deploy( new ElasticDataGridDeployment("mygrid-B")
						  .capacity("1G", "2G")
						  .highlyAvailable(false)
						  .maximumJavaHeapSize("250m")
						  .publicDeploymentIsolation());

Shared Deployment Isolation Level

With a shared deployment isolation, we agree that there can be multiple data-grid instances, belonging to a single tenant, deployed on the same machine.
This means that different tenants will each need their own set of 'dedicated' machines.

The sharedDeploymentIsolation(tenant) is parametrized with a tenant name, for which we will be able to deploy two data-grid instances on our single laptop.

public static void main(String[] args) {
	Admin admin = new AdminFactory().createAdmin();
	ElasticServiceManager esm = admin.getElasticServiceManagers().waitForAtLeastOne();
	ProcessingUnit puA = esm.deploy( new ElasticDataGridDeployment("mygrid-A")
						  .capacity("1G", "2G")
						  .highlyAvailable(false)
						  .maximumJavaHeapSize("250m")
						  .sharedDeploymentIsolation("myTenant"));

	ProcessingUnit puB = esm.deploy( new ElasticDataGridDeployment("mygrid-B")
						  .capacity("1G", "2G")
						  .highlyAvailable(false)
						  .maximumJavaHeapSize("250m")
						  .sharedDeploymentIsolation("myTenant"));

Production environment

In production, we will probably want a highly-available cluster, which will require us to have more than one machine to hold the backup instances. Note the capacity planning and memory settings of each container.

Choosing between the deployment isolation levels is specific to your needs:

  • a dedicated isolation if in need for a non-sharing policy,
  • a shared isolation for data-grids belonging to the same department,
  • or a public isolation for data-grids which just run nightly "jobs".

Here is a ESM Deploy command you may use:

package com.gigaspaces.util.deploy;
import java.util.concurrent.TimeUnit;
import org.openspaces.admin.Admin;
import org.openspaces.admin.AdminFactory;
import org.openspaces.admin.esm.ElasticServiceManager;
import org.openspaces.admin.esm.deployment.DeploymentIsolationLevel;
import org.openspaces.admin.esm.deployment.ElasticDataGridDeployment;
import org.openspaces.admin.esm.deployment.MemorySla;
import org.openspaces.admin.pu.ProcessingUnit;
import org.openspaces.admin.pu.ProcessingUnits;
import org.openspaces.admin.space.Space;
import org.openspaces.core.GigaSpace;
import org.openspaces.grid.esm.ElasticScaleHandlerConfig;

public class ESMDeploy {

	public static void main(String[] args) throws InterruptedException {
		System.out.println("      Welcome to GigaSpaces ESM Deploy Command!");
		System.out.println("   ----------------------------------------------");
		String command ="deploy";
		
		if (args.length>0)
			command = args[0];

		//Discover the Admin and ESM
		String LOOKUPLOCATORS = System.getProperty("LOOKUPLOCATORS");
		Admin admin = new AdminFactory().addLocator(LOOKUPLOCATORS).createAdmin();
		System.out.println("Locating ElasticServiceManager on "+LOOKUPLOCATORS);
		ElasticServiceManager esm = admin.getElasticServiceManagers().waitForAtLeastOne(10, TimeUnit.SECONDS);
		if (esm ==null)
		{
			System.err.println("Can't find Elastic Service Manager! - have you started the gs-agant using:\ngs-agent gsa.global.esm 1 gsa.gsc 0");
			System.exit(0);
		}
		
		System.out.println("Found ElasticServiceManager on "+esm.getMachine().getHostName() + 
				" [" +esm .getMachine().getHostAddress()+"] PID:" + esm.getVirtualMachine().getDetails().getPid());
		
		String minMemory = System.getProperty("minMemory" , "6g"); 
		String maxMemory = System.getProperty("maxMemory" , "20g"); 
		String maximumJavaHeapSize=System.getProperty("maximumJavaHeapSize" , "2g");
		String initialJavaHeapSize=System.getProperty("initialJavaHeapSize" , "2g");
		String dataGridName=System.getProperty("dataGridName" , "mySpace");
		String partitions=System.getProperty("partitions" , "10");
		boolean backup = Boolean.parseBoolean(System.getProperty("backup" , "true"));

		if (command.equals("deploy"))
		{
			System.out.println("Deploying:\n" +
					"minMemory:" +minMemory+
					"\nmaxMemory:" +maxMemory+
					"\nmaximumJavaHeapSize:" +maximumJavaHeapSize+
					"\ninitialJavaHeapSize:" +initialJavaHeapSize+
					"\npartitions:" +partitions+					
					"\ndataGridName:" +dataGridName+
					"\nbackup:" +backup);
	
			//Deploy dataGridName
			ProcessingUnit pu = esm.deploy(new ElasticDataGridDeployment(dataGridName).
					capacity(minMemory, maxMemory).
					setPartitions(Integer.valueOf(partitions).intValue()).
					maximumJavaHeapSize(maximumJavaHeapSize).
					dedicatedDeploymentIsolation().
					highlyAvailable(backup).
					addSla(new MemorySla("60%")).
					// perform GC without stopping the world
					vmInputArgument("-XX:+UseConcMarkSweepGC").
					// activate concurrent GC before reaching 80% in which the high threshold triggers stop-the-world GC
					// also more likely to invoke garbage collection after a PU has been relocated to another JVM. which
					// would give the ESM a more accurate memory indication during scale-in scenarios.
					vmInputArgument("-XX:CMSInitiatingOccupancyFraction=25").
					// evict young generation in parallel
					vmInputArgument("-XX:+UseParNewGC").
					vmInputArgument("-verbose:gc").
					initialJavaHeapSize(initialJavaHeapSize));
			
			//Wait for deployment
			pu.waitForSpace(30, TimeUnit.SECONDS);
			Space space = pu.getSpace();
			space.waitFor(pu.getSpace().getTotalNumberOfInstances() );
			GigaSpace gigaSpace = space.getGigaSpace();
			System.out.println("Done Deploying:"+"\ndataGridName:" +dataGridName + " Space have:" +gigaSpace.count(new Object() + " objects"));
		}
		
		if (command.equals("undeploy"))
		{
			System.out.println("Un-Deploying:"+dataGridName);
			ProcessingUnits pus =  admin.getProcessingUnits();
			pus.waitFor(dataGridName,10,TimeUnit.SECONDS);
			ProcessingUnit pu = pus.getProcessingUnit(dataGridName);
			if (pu!=null)
			{
				System.out.println("Found :" +dataGridName);
				pu.undeploy();
				System.out.println();
				System.out.println("Done Un-Deploying:"+"\ndataGridName:" +dataGridName);
			}
			else
				System.out.println("Can't Find:" +dataGridName + " - UnDeloy unsucessful!");
		}

		System.exit(0);
	}

}

To deploy run the following:

java -DLOOKUPLOCATORS=host1,host2 -cp ${GS_JARS}:. com.gigaspaces.util.deploy.ESMDeploy deploy

To un-deploy run the following:

java -DLOOKUPLOCATORS=host1,host2 -cp ${GS_JARS}:. com.gigaspaces.util.deploy.ESMDeploy undeploy
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence