Auto-Searches On The Cloud
In GridGain 3.0 we are coming up with a set of useful annotations to
automate grid-enabling of common functionality that works on ranges and
collections. The whole idea is that given a certain collection, GridGain
can automatically split that collection into sub-collections, send them
to remote nodes for execution, get results back, reduce them and return
them back to user. Sort of automatic
map-reduce for collections.
Let's take search for example. You can model
almost any search as taking a collection of values, picking the right
value in that collection, and returning that value. For example, let's
assume that we need to find the max
value in a collection (forgive the simplicity of the example, in real
life you would probably be grid-enabling searches that are a lot more
complex than this one).
In Java this would look like the
following:
public Integer findMax(Collection<Integer> vals) {
Integer max = Collections.max(vals);
return max;
} If
we were to grid-enable above functionality, we would have to do the
following:- Map Step: Split the initial collection into a number of sub-collections
- Send each sub-collection to a remote node
- Have every remote node find a max value in the sub-collection assigned to it and return it.
- Reduce Step: Find the maximum out of all values returned from remote nodes and return it to user.
To do this search in GridGain 3.0, all you would have to do is attach @GridifySetToValue(recursive=true) annotation to your method and you are done:
@GridifySetToValue(recursive=true)By a virtue of attaching a single annotation, you are basically telling GridGain to perform steps 1 to 4 described above automatically. On top of that, with GridGain peer-class-loading functionality no code needs to be explicitly deployed to remote nodes at all. Simply bring up several GridGain images on a cloud and they are ready to start computing whatever you throw at them.
public Integer findMax(Collection<Integer> vals) {
Integer max = Collections.max(vals);
return max;
}
In the coming weeks I will show how some other annotations can be used to automate grid-enabling of other common tasks we encounter on daily basis.
I should also mention that you can achieve the above with relative ease on the current version of GridGain (you would have to do some of the steps manually though).
Stay tuned for GridGain 3.0 scheduled for release this summer.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)





