Reputation: 3201
I made a cluster using Hazelcast: it has one master node that spreads Runnables among 5 other nodes. My question is: does Hazelcast ExecuterService
perform computations within each computing node also in parallel?
I mean, if each of my computing nodes have 4 CPUs (or 4 cores on a single CPU), what will be the total number of threads participating in computations? 5 (thread per node) or 5*4=20 (thread per CPU/core)?
Upvotes: 0
Views: 701
Reputation: 3201
Well, we can figutre it out manually:
public class HazelcastTest {
@Test
public void test() {
HazelcastInstance instance = Hazelcast.newHazelcastInstance();
IExecutorService exec = instance.getExecutorService("exec");
for (int i = 0; i < 100; i++) {
exec.submit(new MyRunnable());
}
}
}
public class MyRunnable implements Runnable, Serializable {
@Override
public void run() {
long threadId = Thread.currentThread().getId();
System.err.println("threadId: " + threadId);
}
}
The result is:
threadId: 48
threadId: 48
threadId: 46
threadId: 48
threadId: 46
threadId: 48
threadId: 46
threadId: 46
threadId: 54
threadId: 48
...etc...
Another proof is that CPU monitor shows 100% load for all available cores.
Upvotes: 0
Reputation: 886
your runnable sent to the member will run once per member, which means it will use only single thread. So 5
Upvotes: 1