Commit ffabd4ea authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] When adding a execution action, make sure the ppol accepted it. Avoid execution lost

parent 37917551
Pipeline #4206 passed with stage
in 37 seconds
...@@ -1074,25 +1074,26 @@ public class Duniter4jClientImpl implements Duniter4jClient { ...@@ -1074,25 +1074,26 @@ public class Duniter4jClientImpl implements Duniter4jClient {
public void safeExecuteRequest(ActionRequestBuilder<?, ?, ?> request, boolean wait) { public void safeExecuteRequest(ActionRequestBuilder<?, ?, ?> request, boolean wait) {
// Execute in a pool // Execute in a pool
if (!wait) { ListenableActionFuture<?> actionFuture = null;
boolean acceptedInPool = false; boolean acceptedInPool = false;
while(!acceptedInPool) while(!acceptedInPool) {
try {
actionFuture = request.execute();
acceptedInPool = true;
}
catch(EsRejectedExecutionException e) {
// not accepted, so wait
try { try {
request.execute(); Thread.sleep(1000); // 1s
acceptedInPool = true;
} }
catch(EsRejectedExecutionException e) { catch(InterruptedException e2) {
// not accepted, so wait // silent
try {
Thread.sleep(1000); // 1s
}
catch(InterruptedException e2) {
// silent
}
} }
}
} else { }
request.execute().actionGet(); // Wait end of action, if need
if (wait && actionFuture != null) {
actionFuture.actionGet();
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment