Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Auto-Searches On The Cloud

DZone's Guide to

Auto-Searches On The Cloud

· Cloud Zone
Free Resource

What if you could learn how to use MongoDB directly from the experts, on your schedule, for free? We've put together the ultimate guide for learning MongoDB. Sign up and you'll receive instructions for how to get started!

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:
  1. Map Step: Split the initial collection into a number of sub-collections
  2. Send each sub-collection to a remote node
  3. Have every remote node find a max value in the sub-collection assigned to it and return it.
  4. Reduce Step: Find the maximum out of all values returned from remote nodes and return it to user.
As simple as it is, you can apply the same kind of steps to many other searches you do in real life.

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)  
public Integer findMax(Collection<Integer> vals) {
Integer max = Collections.max(vals);

return max;
}
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.

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.

What if you could learn how to use MongoDB directly from the experts, on your schedule, for free? We've put together the ultimate guide for learning MongoDBSign up and you'll receive instructions for how to get started!

Topics:

Published at DZone with permission of Dmitriy Setrakyan, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}