RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Grid Enable Your Java Applications with GridGain

Grid computing, the idea of executing code among various computers to solve complex time- and resource-intensive algorithms, has intrigued researchers for decades. GridGain lets Java developers tap into the grid.

llowing developers to leverage distributed computing resources has long been a goal of emerging technologies, including most recently RPC, CORBA, and RMI. However, these distributed computing technologies require considerable initial infrastructure setup and maintenance, and they face many hurdles to scalability. Enter grid computing, in which the individual parts of a code base are run remotely and in parallel among the available nodes of a grid (a computer cluster).

Grid computing involves setting up nodes and a network of topologies. Each node is an independent entity having its own or a shared set of resources such as memory, CPU(s), and processor(s). When several of the nodes are pooled and work in conjunction, they form a topology. Because even applications that were designed and developed as parallel-processing grid applications required lots of custom code for network programming, synchronization, and assembly of the results, grid computing has been too costly for many enterprises. Enter GridGain, an open-source, Java-based framework for grid computing that can be a cost-effective introduction to grid application development. GridGain not only provides simple APIs for developing grid applications but also enables developers to grid enable existing applications.

This article demonstrates grid computing with GridGain using the classic example of matrix multiplication.

Get to Know GridGain
GridGain provides a Java-based framework to handle network programming, synchronization, recovery on failure, and more importantly dynamic class loading for grid computing. Because it is written in Java, GridGain has all the write once, run anywhere benefits that come with Java. GridGain nodes could be run on computers running different operating systems and still be part of a topology.

To establish a grid-enabled, enterprise-wide network setup, GridGain provides a simple batch script to start up a node with a default no-name topology. The batch script takes a Spring XML configuration to set up the nodes as a named topology. At that point, a single topology or multiple topologies can be set up within an enterprise network. A single server can run multiple nodes, and each node can be part of a different topology.

At its core, GridGain is a very well architected system that uses all the features offered by Java 2 Platform Standard Edition (J2SE) 5.0 and resolves cross-cutting concerns using Aspect-Oriented Programming (AOP). GridGain provides various interfaces, along with helper interfaces and classes such as listeners and adapters, to enable developers to gain access to the grid.

GridGain also provides a pluggable service provider interface (SPI) for various fundamental, low-level functionalities of the grid, such as discovery, failover, communication, and load balancing. GridGain comes with certain pre-built SPI implementations and new ones could be added with relative ease. Review the documentation to learn how to gain programmatic access to these SPI services.

The source code download includes the file GridTest.java, which contains the following four lines of code to demonstrate the network lookup and connection establishment to a default no-name grid:

try {
    Grid grid = GridFactory.getGrid();
}finally {

To connect to a specific grid, you would pass the name of the grid to the getGrid() method. If no other nodes are available, this program starts up as a grid node. The nodes that are already running will get a notification about the start of a new node. GridGain has in effect reduced what previously would have required several thousand lines of code to accomplish down to these four lines.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date