Created
September 18, 2014 15:06
-
-
Save rofr/b4da21d0a793eba4a850 to your computer and use it in GitHub Desktop.
Getting started example code from the gridgain docs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try (Grid g = GridGain.start()) { | |
Collection<GridCallable<Integer>> calls = new ArrayList<>(); | |
// Iterate through all the words in the sentence and create Callable jobs. | |
for (final String word : "Count characters using callable".split(" ")) { | |
calls.add(new GridCallable<Integer>() { | |
@Override public Integer call() throws Exception { | |
return word.length(); | |
} | |
}); | |
} | |
// Execute collection of Callables on the grid. | |
Collection<Integer> res = g.compute().call(calls).get(); | |
int sum = 0; | |
// Add up individual word lengths received from remote nodes. | |
for (int len : res) | |
sum += len; | |
System.out.println(">>> Total number of characters in the phrase is '" + sum + "'."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment