Fix IgniteUtilsSelfTest.testDoInParallelWithStealingJobRunTaskInExecutor flaky in PDS Basic 1
@@ -62,6 +62,7 @@ import org.apache.ignite.compute.ComputeJob;
import org.apache.ignite.compute.ComputeJobAdapter;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.GridPeerDeployAware;
import org.apache.ignite.internal.util.lang.IgniteThrowableConsumer;
import org.apache.ignite.internal.util.typedef.F;
@@ -1095,14 +1096,31 @@ public class IgniteUtilsSelfTest extends GridCommonAbstractTest {
Collection<Integer> res;
+ // Future for avoiding fast execution in only executor threads.
+ // Here we try to pass a number of tasks more that executor size,
+ // but there is a case when all task will be completed after last submit return control and
+ // current thread can not steal task because all task will be already finished.
+ GridFutureAdapter fut = new GridFutureAdapter();
+
try {
res = U.doInParallel(10,
executorService,
data,
new IgniteThrowableConsumer<Integer, Integer>() {
@Override public Integer accept(Integer cnt) {
- if (Thread.currentThread().getId() == threadId)
+ if (Thread.currentThread().getId() == threadId) {
+ fut.onDone();
+
curThreadCnt.incrementAndGet();
+ }
+ else {
+ try {
+ fut.get();
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
return -cnt;
}
