Resource injection example.
This example demonstrates how GridGain resource injection may be used in job to work with some storage (or with database the same way).
Grid task is responsible for splitting the task into jobs. This particular implementation splits given string into individual words and creates grid jobs for each word. Every job will send data through context injected in job as user resource. Only one context object will be created and injected in all splitted jobs.
Context object will be initialized when task deployed. And new storage will be created during context initialization.
You can find this example at ${GRIDGAIN_HOME}/examples/java folder in package org.gridgain.examples.resources. Source code is fully Javadoc-ed and you can find the examples' Javadoc at ${GRIDGAIN_HOME}/examples/javadoc folder.
Package:
org.gridgain.examples.resources
| Class | Description |
|---|---|
| GridResourcesExample.java | This is main class in this example. It basically starts grid locally (local node) and execute task. |
| GridResourcesTask.java | This class represents grid task. |
| GridResourcesContext.java | It is a context which used in grid jobs. |
Running Grid Node
This example may be used with one or more remote nodes. Note that you don't need another machine for it - you can start remote node on the same machine you are running example on.
To start a remote node open the terminal window on Linux/Mac OS X or Command Prompt on Windows, change directory to ${GRIDGAIN_HOME}/bin and run the gridgain.{sh|bat} script. It takes 2-3 seconds for grid node to start and if everything worked fine you should see starting log ending with successful start acknowledgment.
