GridGain Plugin

  • Tags : other frameworks, grid
  • Latest : 0.2.2
  • Last Updated: 18 May 2009
  • Grails version : 1.1.1 > *
  • Authors : Mingfai Ma
1 vote
Dependency :
compile ":gridgain:0.2.2"

Documentation

Summary

Description

GridGain is a Java-based open source grid computing infrastructure.

Note: v0.2 is upgraded to support Grails 1.1 beta 3, and the plugin name is renamed from GridGain to gridgain.

Features

  • Bundle GridGain main jar, dependency jars, and default configuration files
  • Create a singleton GridSpringBean named 'grid' for injection
  • A Groovy EMC enhancer (only work for @Gridify with taskClass argument)
  • Dynamically enhance any service class with the Groovy EMC enhancer

Step-by-Step demo

For existing Grails users, you may skip the first 2 steps:
  1. Download and install a Java SE Development Kit (JDK, not JRE)
  2. Download and install/extract Grails
    • You generally want to set GRAILS_HOME to your extracted directory (it is not a mandatory requirement in the latest snapshot), and
    • set the $GRAILS_HOME/bin to your PATH, e.g.
      • on windows
        SET PATH=%GRAILS_HOME%bin;%PATH%
      • on unix/linux
        export PATH=$GRAILS_HOME/bin:$PATH
  3. Create a Grails project and install the plugin ( Quick Start Guide )
    grails create-app gg0 
    cd gg0 
    grails install-plugin gridgain
  4. Add Log4j configuration at the end of grails-app/conf/Config.groovy
    // for Grails 1.1 only 
    log4j = { 
      appenders { 
        console name: 'consoleAppender', layout: pattern(conversionPattern: "%d{ABSOLUTE} %-5p [%c{1}][%X{tid}] %m%n") 
      } 
      debug consoleAppender: 'org.grails.plugins.gridgain' 
      info  consoleAppender: 'org.gridgain' 
    … 
    
  5. Start the Grails instance
    grails run-app -Dserver.port=8080
  6. Repeat Step 3 to Step 5 to create, configure, and start more Grails GridGain instance. You need to give different project name and port, e.g. gg0 start at 8080, gg1 start at 8081 etc.
  7. Access the demo page at, e.g. http://localhost:8080/gg0/gridGainDemo Both the two examples print two words in two different nodes only. Go to /gg0/plugins/gridgain-*/grails-app/controllers/org/grails/plugins/gridgain/GridGainDemoController.groovy, modify demo the demo1 and try again, e.g.
    GridTaskFuture<Integer> future = grid.execute(GridHelloWorldGroovyTask.class, "hello to the world wide web");

Demo Explained

The demo sends a hardcoded string "hello world" as a parallel processing task. The string is splitted and be processed by multiple node concurrently. On every node that receive a job, it prints the word to the console, and return the number of characters. The original server receives the sum of all characters and print it on screen.

Usage

Installation

  • Install the plugin for your main Grails project
  • Start additional nodes by any of the following methods:
    • Create a new Grails project and install the plugin, either run on different network node or configure it to listen to another port.
    • Download a GridGain binary distribution, set a GRIDGAIN_HOME environmental variable, and start with bin/gridgain.bat/sh

Create MapReduce Task and Job

  • At your main Grails project, create a MapReduce task that extends GridTaskSplitAdapter. The task has to implement a split() and a reduce() method. e.g. a class with the following signature:
public class GridHelloWorldGroovyTask extends GridTaskSplitAdapter<String, Integer> {
  public Collection split(int gridSize, String phrase) throws GridException {
    …
  }
  public Integer reduce(List<GridJobResult> results) throws GridException {
    …
  }
}

Start the job

  • Start the job in either one of the following ways:
class DemoController{ // any Grails managed artifects
  def grid;

def demo = { GridTaskFuture<Integer> future = grid.execute(GridHelloWorldGroovyTask.class, "hello world") def phraseLen = future.get(); //sync render("phrase length is ${phraseLen }"); } }

    • alternatively, use the @Gridify annotation on a Service method
class DemoService {
  boolean transactional = false

@Gridify (taskClass = GridHelloWorldGroovyTask.class,timeout = 3000L) static int sayIt(String phrase) { println ">>>" println ">>> Printing '$phrase' on this node from grid-enabled method." println ">>>"

return phrase.size() } }

Configuration

  • You don't need to install a copy of GridGain on the Grails server, nor you need to configure the GRIDGAIN_HOME environmental variable. By default, the plugin set the variable to Grails project path, that contains a copy of the the /config .
  • you may override the GRIDGAIN_HOME environmental variable to point to your GridGain installation

Design and Implementation

The plugin is quite simple, the following are main elements:

Version and compatibility

  • The plugin bundle with GridGain 2.1 release
  • The plugin is tested with Grails 1.
Check CHANGE.txt for change history

Source repository

Please access the trunk of the source repository.

Contact and Author

  • Please send any question to the grails user mail list. There is no issue tracking system nor any roadmap yet.
  • There is no roadmap for this project. You may check the TODO list for some known missing features
Author: Mingfai Ma (mingfai.ma at gmail dot com), Disclaimer: I'm just a beginner of GridGain. :-)