JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF

The open source
grid computing
solution

 Home   About   Features   Download   Documentation   On Github   Forums 

GigaSpaces XAP Connector

From JPPF 3.3 Documentation

Jump to: navigation, search

Contents

Main Page > GigaSpaces XAP Connector

1 About GigaSPaces and JPPF

GigaSpaces is a full-fledged, non-J2EE application server that can handle, among other features, large distributed datasets. Integrating JPPF within GigaSpaces XAP adds the ability to perform intensive computations on those data, seamlessly and without impacting the performance of the applications running within GigaSpaces. It also provides JPPF applications with capabilities that were so far missing form its desing: clustering, replication, transaction management, data access, etc ...

2 Installation

2.1 Prerequisites

Before installing, please make sure you have the following already installed in your environment:

  • Java Runtime Environment (JRE) version 1.5 or later
  • Apache Ant version 1.6.2 or later
  • GigaSpaces XAP version 6.6 or later

2.2 Installing

To install the JPPF / GigaSpaces integration package, perform the following steps:

  • download the JPPF-2.x-GigaSpaces-.zip file from the JPPF download page
  • Unzip this file in a location of your choice, this will create a new folder named "JPPF-GigaSpaces"
  • Edit the file "JPPF-GigaSpaces/build.properties" in a text editor and set the appropriate path for the GigaSpaces XAP install root folder
  • you are now ready to use the JPPF / GigaSpaces integration

3 Deploying the JPPF processing unit

  • In the GigaSpaces Management Center, start a Grid Service Manager (GSM):

CH-8-GS-1.gif

  • Next, start a Grid Service Container (GSC):

CH-8-GS-2.gif

  • Next we will deploy a JPPF client as a Processing Unit. To start, open the deployment wizard, as in the screenshot below:

CH-8-GS-3.gif

  • On the next screen, select the Processing Unit jar file to deploy, located at

<JPPF-GigaSpaces>/JPPF-GigaSpaces-ProcessingUnit/pu/JPPF-GigaSpaces-ProcessingUnit.jar:

CH-8-GS-4.gif

  • After selecting the jar file, click "finish" and wait until the processing unit is deployed:

CH-8-GS-5.gif

4 Deploying the sample web application

We will now deploy a sample web application packaged as a war file

1. First ensure that the JPPF processing unit has been deployed

2. Open the deployment wizard and select the war file to deploy, located at:

<JPPF-GigaSpaces>/JPPF-GigaSpaces-Client/build/jppftest.war

CH-8-GS-6.gif

3. After selecting the war file, click "finish" and wait until the web application is deployed, the UI should now show both processing unit and web app deployed under the GSM:

CH-8-GS-7.gif

4. The web application is now ready to be used at this URL: http://localhost:8080/jppftest

5 Considerations for deploying JPPF-enabled applications

5.1 Available APIs

The JPPF processing unit publishes all its libraries in its shared-lib folder, which makes the required JPPF APIs available to other applications deployed within GigaSpaces:

  • the job and tasks APIs: JPPFTask, JPPFJob, DataProvider, ExecutionPolicy
  • the service API used to submit jobs to the JPPF service: JPPFService

5.2 Spring descriptor

Access to the JPPF service is realized by declaring it as a remoted Spring bean in your application. This is done as follows:

 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:os-core="http://www.openspaces.org/schema/core"
        xmlns:os-events="http://www.openspaces.org/schema/events"
        xmlns:os-remoting="http://www.openspaces.org/schema/remoting"
        xmlns:os-sla="http://www.openspaces.org/schema/sla"
        xmlns:os-jms="http://www.openspaces.org/schema/jms"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.openspaces.org/schema/core
        http://www.openspaces.org/schema/core/openspaces-core.xsd
        http://www.openspaces.org/schema/events
        http://www.openspaces.org/schema/events/openspaces-events.xsd
        http://www.openspaces.org/schema/remoting
        http://www.openspaces.org/schema/remoting/openspaces-remoting.xsd
        http://www.openspaces.org/schema/jms
        http://www.openspaces.org/schema/jms/openspaces-jms.xsd
        http://www.openspaces.org/schema/sla
        http://www.openspaces.org/schema/sla/openspaces-sla.xsd">
 
     <!-- Declaration of the JPPF space. -->
     <os-core:space id="space" url="jini://*/*/JPPFSpace" />
     <os-core:giga-space id="gigaSpace" space="space"/>
 
     <!-- The JPPF service proxy. -->
     <os-remoting:sync-proxy
      id="jppfService" giga-space="gigaSpace"
      interface="org.jppf.gigaspaces.JPPFService"/>        
 
     <!--
       The GSClient bean, uses the proxied service
       without any knowledge of the remoting invocation.
     -->
     <bean id="gsclient" class="org.jppf.gigaspaces.test.GSClient">
         <property name="jppfService" ref="jppfService"/>
     </bean>
 </beans>

This descriptor can be found in the distribution as:

<JPPF-GigaSpaces>/JPPF-GigaSpaces-Client/src/client.xml

5.3 Usage in application code

Obtaining a reference to the JPPF service is done via the Spring application context:

 // Parse the application context and instantiate the bean
 ClassPathXmlApplicationContext context =
   new ClassPathXmlApplicationContext("classpath:client.xml");
 context.start();
 // Get a reference to the created bean
 GSClient gsc = (GSClient) context.getBean("gsclient");

The call to context.start() causes the Sprint bean's afterPropertiesSet() method to be invoked:

 /**
  * Called after the Spring bean init and submits a JPPF job to the JPPF space.
  * @throws Exception if any error occurs.
  * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
  */
 public void afterPropertiesSet() throws Exception {
   // Create a new job and add a task
   JPPFJob newJob = new JPPFJob();
   newJob.addTask(new HelloTask());
   // invoke the JPPF service proxy to submit the job
   this.job = jppfService.submitJob(newJob);
 }

Putting it all together, here is the code used in our sample web application:

 package org.jppf.gigaspaces.test;
 
 import org.jppf.client.JPPFJob;
 import org.jppf.gigaspaces.*;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
  * Client class used to invoke a JPPF job submission service
  * deployed as a processing unit.
  */
 public class GSClient implements InitializingBean {
   private JPPFService jppfService = null;
   private JPPFJob job = null;
 
   // Entry point for execution of this client as a standalone application.
   public static void main(String[] args) {
     execute();
   }
 
   /**
    * Initialize the Spring context, invoke the appropriate bean method,
    * and store the results of the JPPF execution.
    * @return the results as a <code>JPPFJob</code> instance.
    */
   public static JPPFJob execute() {
     ClassPathXmlApplicationContext context =
       new ClassPathXmlApplicationContext("classpath:client.xml");
     context.start();
     GSClient gsc = (GSClient) context.getBean("gsclient");
     return gsc.getJob();
   }
 
   // Called after the Spring bean init and submits a JPPF job to the JPPF space.
   public void afterPropertiesSet() throws Exception {
     JPPFJob newJob = new JPPFJob();
     newJob.addTask(new HelloTask());
     this.job = jppfService.submitJob(newJob);
   }
 
   // Get a proxy to the service deployed in a GS space.
   public JPPFService getJppfService() {
     return jppfService;
   }
 
   // Set a proxy to the service deployed in a GS space.
   public void setJppfService(JPPFService service) {
     this.jppfService = service;
   }
 
   // Get the resulting JPPF job instance.
   public JPPFJob getJob() {
     return job;
   }
 }
Main Page > GigaSpaces XAP Connector

JPPF Copyright © 2005-2020 JPPF.org Powered by MediaWiki