Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it recommended to use ExecutionCallBacks for distributed executor service - hazelcast
    text
    copied!<p>I observed that there is some latency involved in collecting results of the tasks submitted to the IExecutorService . This is only in the context of trying to collect results in the form of futures, by using the submit(Callable task) inherited from ExecutorService..I also found that the performance is good when you collect results via asynchronous callbacks. Considering futures are asynchronous too, i am trying to understand why there is a lag in retreiving results.Is it something specific to the way hazelcast works?</p> <p>Also, if i am using submit(Callable task, ExecutionCallback callback) , what kind of behaviour should i expect? Should i expect that it randomly picks one member to execute on and with or without load balancing?</p> <p><strong>Edit</strong>:Updating question with some sample code . I am storing futures in the collection and retrieving it later.But when the main thread keeps on reading the future values,i see a delay when compared to the asynchronous callbacks.</p> <pre><code>final IExecutorService executorService = hz.getExecutorService("default"); List&lt;Future&lt;String&gt;&gt; list = Lists.newArrayList(); for (int i = 0; i &lt; 100; i++) { final Future&lt;String&gt; f = executorService.submit(new Echo(" " + i)); list.add(f); } System.out.println(); for (Future&lt;String&gt; f : list){ System.out.println(f.get()); } </code></pre> <p>as opposed to</p> <pre><code>final IExecutorService executorService = hz.getExecutorService("default"); final List&lt;String&gt; list = Lists.newArrayList(); final Stopwatch stopwatch = Stopwatch.createStarted(); for (int i = 0; i &lt; 100; i++) { executorService.submit(new Echo(" " + i), new ExecutionCallback&lt;String&gt;() { @Override public void onResponse(String response) { System.out.println(response); list.add(response); if(list.size() == 100){ stopwatch.stop(); // optional long millis = stopwatch.elapsed(TimeUnit.MILLISECONDS); System.out.println("time taken to complete is: "+millis); } } @Override public void onFailure(Throwable t) { t.printStackTrace(); } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload