Summary: Allows you to run a Processing Unit in standalone mode, meaning that the Processing Unit is run under its own constructed classloader, based on the Processing Unit structure.

Overview

The standalone Processing Unit container allows you to run a Processing Unit (using the Processing Unit structure) in standalone mode. Standalone mode means that the Processing Unit is run under its own constructed classloader, based on the structure of the Processing Unit.

The standalone Processing Unit container is built around the Spring ApplicationContext with several extensions, such as ClusterInfo and bean-level properties.

The standalone Processing Unit container is run using the main() method, and is created using a ProcessingUnitContainerProvider.

StandaloneProcessingUnitContainerProvider

Here is an example of using a ProcessingUnitContainerProvider in order to create one:

StandaloneProcessingUnitContainerProvider provider = new StandaloneProcessingUnitContainerProvider("data-processor");
// provide cluster information for the specific PU instance
ClusterInfo clusterInfo = new ClusterInfo();
clusterInfo.setSchema("partitioned");
clusterInfo.setNumberOfInstances(2);
clusterInfo.setInstnaceId(1);
provider.setClusterInfo(clusterInfo);

// set the config location (override the default one - classpath:/META-INF/spring/pu.xml)
provider.addConfigLocation("classpath:/test/my-pu.xml");

// Build the Spring application context and "start" it
StandaloneProcessingUnitContainer container = provider.createContainer();

// ...

container.close();

The StandaloneProcessingUnitContainerProvider is constructed with a file-system path to the Processing Unit directory. It uses the processing unit structure in order to construct a new classloader and add to it the jar and class files, based on the structure.

Executable StandaloneProcessingUnitContainer

The StandaloneProcessingUnitContainer provides an executable main() method that allows it to be run directly. The main() method uses the StandaloneProcessingUnitContainerProvider and command-line conventions in order to create the StandaloneProcessingUnitContainer. A required parameter is the Processing Unit location, pointing to the file-system location of the Processing Unit directory. The following is a list of all the possible command-line parameters available:

Option Description
-config [configLocation] Allows you to set or add a Spring application context XML. Follows the Spring Resource Loader including ant style patterns. This parameter can be specified multiple times. Default is classpath*:/META-INF/spring/pu.xml.
-cluster [cluster options] Allows you to control the ClusterInfo injected into the container (see ClusterInfo). The following options are available (they are used automatically by any embedded space included in the Processing Unit):
  • schema – the cluster schema used by the Processing Unit.
  • total_members – has the format of numberOfInstances[,numberOfBackups].
  • id – the instance ID.
  • backup_id – the backup ID.
-properties [bean name] location Allows you to control bean-level properties.

puInstance

OpenSpaces comes with the puInstance script, which uses the StandaloneProcessingUnitContainer in order to run a Processing Unit.

Here are some examples of using the puInstance script in order to run a processing unit:

Unix
puInstance.sh -cluster schema=partitioned total_members=2 id=1 data-processor

Windows
puInstance.bat -cluster schema=partitioned total_members=2 id=1 data-processor

The above example starts a Processing Unit (which includes an embedded Space) in a partitioned cluster schema, with two members and id=1. In order to run the full cluster, another puInstance has to be started with id=2.

Unix
puInstance.sh -cluster schema=primary_backup total_members=1,1 id=1 backup_id=1 
-properties context.properties data-processor

Windows
puInstance.bat -cluster schema=primary_backup total_members=1,1 id=1 backup_id=1 
-properties context.properties data-processor

The above example starts a Processing Unit instance (with an embedded space) in a primary-backup cluster schema, with one primary and one backup. It also uses context-level properties that can be used by all the beans within the application context.

GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence