Summary: Explains how to run your processing unit in standalone mode, which means that the processing unit is run under its own self-constructed classloader, based on the processing unit's directory structure.
OverviewThe standalone processing unit container allows you to run a processing unit in standalone mode, which means that the processing unit constructs its own dedicated classloader, and automatically includes it its classpath all of the jar files located under the processing unit's lib directory. The standalone processing unit container is built around Spring's ApplicationContext with several extensions relevant to GigaSpaces, such as ClusterInfo. It should be used when you would like to run your processing unit in a non-managed environment (outside of the service grid) or from within your own code, and still benefit from the automatic classpath creation as with the managed mode. Executable StandaloneProcessingUnitContainerThe 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: The StandaloneProcessingUnitContainer class provides an executable main() method, allowing you to run it directly via a shell script for example. The main() method uses the StandaloneProcessingUnitContainerProvider class and program arguments in order to create the StandaloneProcessingUnitContainer. The following is a list of all the possible program arguments that can be specified to the StandaloneProcessingUnitContainer:
Starting the Standalone Processing Unit Container via the puInstance Shell ScriptGigaSpaces comes with the puInstance shell script, which uses the StandaloneProcessingUnitContainer in order to run a processing unit directly from the command line. 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.jar Windows puInstance.bat -cluster schema=partitioned total_members=2 id=1 data-processor.jar 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=partitioned-sync2backup total_members=1,1 id=1 backup_id=1 -properties runtime.properties data-processor.jar Windows puInstance.bat -cluster schema=partitioned-sync2backup total_members=1,1 id=1 backup_id=1 -properties runtime.properties data-processor.jar The above example starts a processing unit instance (with an embedded space) in a partitioned-sync2backup cluster schema, with one primary and one backup. It also uses an external properties file to inject property values at startup time. Starting a StandaloneProcessingUnitContainer ProgrammaticallyHere is an example of using a ProcessingUnitContainerProvider in order to create a standalone processing unit container programmatically: StandaloneProcessingUnitContainerProvider provider = new StandaloneProcessingUnitContainerProvider("/usr/gigaspaces/data-processor.jar"); // provide cluster information for the specific PU instance ClusterInfo clusterInfo = new ClusterInfo(); clusterInfo.setSchema("partitioned-sync2backup"); clusterInfo.setNumberOfInstances(2); clusterInfo.setNumberOfBackups(1); clusterInfo.setInstanceId(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 ProcessingUnitContainer container = provider.createContainer(); // ... container.close(); The StandaloneProcessingUnitContainerProvider is constructed with a file-system path to the processing unit jar file. It constructs a new classloader and adds all the jar files in the processing unit's lib directory to it automatically. |
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |