Java Reference
In-Depth Information
you take the results and join them, and those results are then sent back. Often, you won't have results,
per se; instead, you'll have sought only to distribute the processing asynchronously.
GridGain packs a lot of power in the few interfaces you're required to ever deal with. Its internal
configuration system is Spring, and when you wish to avail yourself of anything besides the absolute
minimum configuration options — for example, configuring a certain node with characteristics upon
which job routing might be predicated — you do so using Spring. GridGain provides a Spring AOP
Aspect for use on beans with the @Gridify annotation for the very simple cases.
Deployment
To get started, download GridGain from the web site, http://www.gridgain.com . Unzip the distribution
and then descend into the bin directory and run gridgain.(bat|sh) . If you're running a Unix/Linux
instance, you may need to make the scripts executable:
chmod a+x *sh
You need to set up an environment variable, GRIDGAIN_HOME , pointing to the directory in which you
installed the distribution for it to function correctly. If you're running Unix, you need to set the variable
in your shell environment. Usually, this happens in something like ~.bashrc:
export GRIDGAIN_HOME=<YOUR DIRECTORY>
If you are running Windows, then you will need to go to System Properties -> Advanced ->
Environment Variables and add a new system variable, GRIDGAIN_HOME , pointing to the directory of your
installation. Regardless of what operating system you're using, you need to ensure that there are no
trailing “/” or “\”s on the variable's path.
Finally, run the script.
./gridgain.sh
If you have more than a few hundred megabytes of RAM, you might run the script several times.
Each invocation creates a new node, so that, in essence, you'll have started a grid on your local machine.
GridGain uses multicast, so you could put GridGain on several boxes and run numerous instances on
each machine, and they'd all join the same grid. If you want to expand your grid to 10 boxes, simply
repeat the installation of the GridGain software and set up the environment variable on each. You can
partition the grid and characteristics of the nodes using Spring, if you want, but for now we'll concern
ourselves with the defaults.
Astonishingly, this is all that's required for deployment. Shortly, you'll create executable code (with
numerous .jars , no doubt) and make changes on your local development machine, and then run the
changed job and the rest of the nodes in the grid will just “notice” the updated job and participate in
running it thanks to its first-rate class-loading magic. This mechanism, peer-to-peer class loading,
means that you don't need to do anything to deploy a job besides run the code with the job itself once.
10-4. Load Balancing a Method
Problem
You want to quickly grid-enable a method on a bean using GridGain. You can see doing this, for
example, to expose service methods that in turn instantiate longer-running jobs on the grid. One
example might be sending notification e-mails, or image processing, or any process you don't want
bogging down a single machine or VM instance, or whose results you need sooner.
 
Search WWH ::




Custom Search