Question about distributed execution thread.
seto Jan 16, 2017 5:34 AM1. Use DefaultExecutorService for distributed execution.
DefaultExecutorService des = new DefaultExecutorService(idCache);
for (int i = 0; i < 5; i++) {
des.submitEverywhere(new TestCallable());
}
In the node who submit everywhere, the callable is run one by one in order in the same thread. I think it's not as expected.
callable Thread[pool-6-thread-1,5,main]
Cache 'id-cache'@DESKTOP-7SRGBKP-9787
id-cache
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
callable Thread[pool-6-thread-1,5,main]
Cache 'id-cache'@DESKTOP-7SRGBKP-9787
id-cache
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
callable Thread[pool-6-thread-1,5,main]
Cache 'id-cache'@DESKTOP-7SRGBKP-9787
id-cache
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
callable Thread[pool-6-thread-1,5,main]
Cache 'id-cache'@DESKTOP-7SRGBKP-9787
id-cache
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
callable Thread[pool-6-thread-1,5,main]
Cache 'id-cache'@DESKTOP-7SRGBKP-9787
id-cache
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
In the node who accept the callable, the callable is run concurrently in multiple threads. It's expected.
callable Thread[remote-thread--p2-t5,5,main]
Cache 'id-cache'@DESKTOP-7SRGBKP-31706
id-cache
callable Thread[remote-thread--p2-t2,5,main]
Cache 'id-cache'@DESKTOP-7SRGBKP-31706
id-cache
callable Thread[remote-thread--p2-t3,5,main]
Cache 'id-cache'@DESKTOP-7SRGBKP-31706
id-cache
callable Thread[remote-thread--p2-t1,5,main]
Cache 'id-cache'@DESKTOP-7SRGBKP-31706
id-cache
callable Thread[remote-thread--p2-t4,5,main]
Cache 'id-cache'@DESKTOP-7SRGBKP-31706
id-cache
ccc,eee
bbb,bbb
eee,[eee]
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
EMPTY
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
ccc,eee
bbb,bbb
eee,[eee]
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
EMPTY
2. Use ClusterExecutor for distributed execution.
for (int i = 0; i < 5; i++) {
idCache.getCacheManager().executor().submitConsumer(localManager -> {
System.out.println("runnable " + Thread.currentThread());
output(localManager.getCache("id-cache"));
System.out.println(((TestData) localManager.getCache("id-cache").get("ccc")).getState());
return null;
}, null);
}
Both is expected.
In the node who submit everywhere, the callable is run concurrently in multiple threads. It seems that it's expected. But there's two remote-thread--p2-t1.
runnable Thread[remote-thread--p2-t1,5,main]
id-cache
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
runnable Thread[remote-thread--p2-t1,5,main]
id-cache
runnable Thread[remote-thread--p2-t2,5,main]
id-cache
runnable Thread[remote-thread--p2-t3,5,main]
id-cache
runnable Thread[remote-thread--p2-t4,5,main]
id-cache
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
In the node who accept the callable, the callable is run concurrently in multiple threads. It's expected.
runnable Thread[remote-thread--p2-t1,5,main]
id-cache
runnable Thread[remote-thread--p2-t8,5,main]
runnable Thread[remote-thread--p2-t9,5,main]
id-cache
runnable Thread[remote-thread--p2-t6,5,main]
id-cache
runnable Thread[remote-thread--p2-t7,5,main]
id-cache
id-cache
ccc,eee
bbb,bbb
eee,[eee]
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
EMPTY
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
ccc,eee
bbb,bbb
eee,[eee]
EMPTY
ccc,eee
bbb,bbb
eee,[eee]
EMPTY