Summary: Installing the OpenSpaces Maven plugin, creating and running a Processing Unit project.
OverviewMaven is a tool used to automate and simplify the development cycle of any Java-based project. The OpenSpaces plugin for Maven utilizes Maven to simplify the development cycle of OpenSpaces-based applications. You can use this plugin to easily create, compile, package, run unit tests, execute and deploy Processing Units. You don't need to be an experienced Maven user to start working with this plugin. This section provides you with everything you need to know in order to start developing Processing Units with the Maven plugin. Experienced Maven users can use the Maven plugin to embed Processing Unit development with their existing development environment.
Prior to InstallationIn order to use the OpenSpaces Maven plugin, Maven needs to be installed on the machine. If a Maven installation already exists on the machine, it can be used. If not, GigaSpaces comes with a ready-to-use distribution of Maven 2.0.9, located under: <JSHOMEDIR>/tools/maven/apache-maven-2.0.9. All you need to do is add the Maven bin directory to the system PATH variable, and you are ready to go. To test whether the Maven command is accessible, open a command line window, type mvn -version, and press Enter. >mvn -version Maven version: 2.0.9 Java version: 1.5.0_15 OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
InstallationTo install the OpenSpaces Maven plugin: Run the installmavenrep script from the <GigaSpaces Root>\tools\maven directory: D:\gigaspaces-xap-6.5\tools\maven>installmavenrep.bat This installs the GigaSpaces libraries and the OpenSpaces Maven plugin into the local Maven repository. Once the installation is finished, the Maven plugin is ready to be used.
Location of Libraries and Local RepositoryLibrary Location:
Local Repository Location: Querying the Available Project TemplatesIt is possible to view the list of the project templates available for use and their description. In order to view the template list, use the following command-line: mvn os:create The result is a list of available template names and descriptions: 2. basic-async-persistency - Creates a basic SBA application with three processing units. The Feeder processing unit sends Data objects through the Space to a Processor. The Space and the Processor are collocated in the same processing unit.The Processor is connected to a Mirror and provides a reliable async replication and persistency to the Database using Hibernate. 3. basic-xml - Creates a basic SBA application with two processing units. The Feeder processing unit sends Data objects through the Space to a Processor. The Space and the Processor are collocated in the same processing unit. 4. basic-async-persistency-xml - Creates a basic SBA application with three processing units. The Feeder processing unit sends Data objects through the Space to a Processor. The Space and the Processor are collocated in the same processing unit. The Processor is connected to a Mirror and provides a reliable asynchronous replication and persistency to the Database using Hibernate. 5. mule - Creates a SBA application with two processing units that use mule as an ESB. The Feeder processing unit writes Data objects to the Space. The Processor processing unit uses the extended SEDA model to defines 3 services. A Verifier service that verifies unprocessed Data objects, an Approver service that approves verified Data objects and a Processor service that processes approved Data objects. The Space and the Processor are collocated in the same processing unit. Use the -Dtemplate=<template> argument to specify a project template. Example: mvn os:create -Dtemplate=basic-async-persistency Creating Processing Unit ProjectThe OpenSpaces Maven plugin can create Processing Unit projects. It generates the resources and the appropriate directory structure, making it easy to immediately start working on the Processing Units. Projects can be created in any directory. Before creating the project change to the directory where the project should be created. To create a Processing Unit project, use the following command-line: mvn os:create -DgroupId=<group-id> -DartifactId=<artifact-id> -Dtemplate=<project-template>
The project is generated in the current directory (my-app directory).
Processing Unit Project StructureBasically, a Processing Unit project structure is what Maven users call a multi-module project. It consists of a main (top-level) project that contains sub-projects called modules. A Processing Unit is implemented as a module of the main project, thus a main project might consist of many Processing Units. The project, created by the default template, consists of a main project and three modules (sub-projects):
The main project and each of the modules contain a project-descriptor file called pom.xml; which contains information about the project's properties, dependencies, build configuration, and so on. A module is considered a Processing Unit module if its pom.xml file contains the property gsType=PU. In this case, only the feeder and the processor are considered Processing Unit modules. For a full overview of the OpenSpaces Maven plugin project templates, refer to: link will be added soon. Compiling the Processing Unit ProjectIn order to compile the Processing Unit project, use the following command line from the main project's directory. mvn compile This compiles each module and puts the output files under the modules' target directory. Running Processing Unit ModulesSometimes, during development, the developer might want to run the Processing Unit module to check its functionality. The OpenSpaces Maven plugin allows you to run Processing Unit modules without the need to package them as Processing Unit distributables first. This feature saves time, while evading build phases that are not required for this task.
Make sure you are in the directory of the project. mvn os:run -Dcluster=<"cluster-properties"> -Dgroups=<groups> -Dlocators=<locators> -Dproperties=<"context-level-properties-location"> -Dmodule=<module-name>
Example: mvn compile os:run -Dcluster="schema=partitioned total_members=1,1 id=1" -Dproperties="embed://prop1=value1" -Dmodule=feeder Determining Module Execution
Overriding Space/Cluster ConfigurationIf you need to override the configuration of the space or cluster when running the processing units through the OpenSpaces plugin and you want to do it by replacing the original configuration files, you can do it by placing the required file in the project's root directory. Examples: To change the security permissions place the new policy.all file in the policy directory (you may need to create this directory) under the project's root directory. Packaging Processing UnitsIn order to deploy Processing Units, you need to package them in a distributable form. The OpenSpaces Maven plugin allows you to package two types of distributables supported by GigaSpaces: a single JAR archive and an open directory structure. Make sure you are in the directory of the project. mvn package
The Processing Units' distributable bundles are generated for each module, under the directory target. For example, the distributables of a module named feeder are generated under <proj-dir>\feeder\target. The single JAR distributable is feeder.jar; the open directory structure distributable is created under the directory feeder. Suppressing Unit Test Execution While PackagingIf not specified explicitly, unit tests are executed when packaging the Processing Units. To suppress the execution of unit tests, add one of the following arguments to the command line: skipTests or maven.test.skip:
For example: >mvn package -DskipTests .. or .. >mvn package -Dmaven.test.skip Running Processing UnitsAfter packaging the Processing Units, you might want to test the validity of the assemblies. The OpenSpaces Maven plugin makes it possible to run the Processing Units as standalone modules. The Maven plugin includes all the assembly dependencies in the execution classpath, making sure that the Processing Unit finds all the required resources. Managing to run the Processing Unit as a module while failing to run it as a standalone module might imply that a problem exists with the assembly definitions. Make sure you are in the directory of the project. mvn os:run-standalone -Dcluster=<"cluster-properties"> -Dgroups=<groups> -Dlocators=<locators> -Dproperties=<"context-level-properties-location"> -Dmodule=<module-name>
Example: mvn os:run-standalone -Dcluster="schema=partitioned total_members=1,1 id=1" -Dproperties="embed://prop1=value1" -Dmodule=feeder Determining Processing Unit Execution
Overriding Space/Cluster ConfigurationOverriding the space and cluster configuration is explained in Running Processing Unit Modules. Deploying Processing UnitsProcessing Units usually run in the Service Grid. In order to deploy a Processing Unit, you first need to package it (see Packaging Processing Units). GigaSpaces supports two forms of Processing Unit distributables: A single JAR archive and an open directory structure. The OpenSpaces Maven plugin allows you to deploy Processing Units simply – packaged as JAR archives – into the Service Grid.
Make sure you are in the directory of the project. mvn os:deploy
-Dsla=<sla>
-Dcluster=<cluster>
-Dgroups=<groups>
-Dlocators=<locators>
-Dtimeout=<timeout>
-Dproperties=<"prop1=val1 prop2=val2...">
-Doverride-name=<override-name>
-Dmax-instances-per-vm=<max-instances-per-vm>
-Dmax-instances-per-machine=<max-instances-per-machine>
-Dmodule=<module-name>
If the current directory is a Processing Unit module's base directory, only this processing unit is deployed. If the current directory is the main project directory and the pu-name argument is not set, Maven deploys the Processing Unit in the order described below. If the current directory is the main project directory and the pu-name argument is set, only the specified Processing Unit is deployed. Undeploying Processing UnitsThe OpenSpaces Maven plugin makes it simple to undeploy Processing Units from the Service Grid. Make sure you are in the directory of the project. To undeploy a Processing Unit from the Service Grid, use the following command-line: mvn os:undeploy -Dgroups=<groups> -Dlocators=<locators> -Dtimeout=<timeout> -Dmodule=<module-name>
Controlling Order of Deployment/UndeploymentDeploymentA Processing Unit might have a dependency on another Processing Unit (this dependency is defined in the Processing Unit pom.xml file). It is important to deploy these Processing Units in the right order to prevent errors.
UndeploymentUndeployment of Processing Units takes place in a reverse order: the dependent Processing Unit is undeployed first and the independent second. Adding Dependencies to ModulesA dependency is a library (usually a JAR archive containing class libraries) required by the Processing Unit for compilation, execution, etc. <project> ... <dependencies> ... <!--The added snippet--> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version> <scope>compile</scope> </dependency> ... </dependencies> ... </project> Private DependenciesPrivate dependencies are Processing Unit dependencies that are not shared with other Processing Units. Shared DependenciesShared dependencies are Processing Unit dependencies that are shared with other Processing Units. To add shared dependencies, add the dependencies to the common module pom.xml file. For example, to add the commons-logging version 1.1.1 as a shared dependency of the processor and the feeder Processing Units, add the XML snippet above to the common module's pom.xml file. When the Processing Units are packaged, the commons-logging archive is located under the lib directory of the processor and the feeder distributables. Importing Processing Unit Projects to Eclipse IDEIt is possible to import a Processing Unit project into the Eclipse environment. Imported projects have built-in launch targets, allowing you to run the processor and the feeder using Eclipse run (or debug) targets. 1. Generate Eclipse ProjectExecute the following command from the project root directory: mvn eclipse:eclipse This generates a .project file under each module's base directory. 2. Import Generated Projects to Eclipse Environment
This imports the three modules to Eclipse, each as a separate project. 3. Define M2_REPO VariableImported projects use a variable called M2_REPO to point to the location of Maven's local repository. If this is a fresh Eclipse installation, the M2_REPO variable needs to be defined:
Viewing Persistent DataWhen running a Processing Unit that uses persistency, e.g when using the basic-async-persistency template, one would like to view the persisted data. OpenSpaces Maven Plugin makes it easy to start the HSQLDB viewer to immediately view persisted data.
To start the HSQLDB viewer use the following command-line: mvn os:hsql-ui -Ddriver=<driver-class> -Durl=<url> -Duser=<user> -Dpassword=<password> -Dhelp
|
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |