Updated ExternalAgentSolver.java
This commit is contained in:
@@ -95,7 +95,7 @@ public class ExternalAgentSolver extends StepSolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int maxTries = 100;
|
int maxTries = 500;
|
||||||
// Pool the status GET api until it return the SUCCESS or FAILED message
|
// Pool the status GET api until it return the SUCCESS or FAILED message
|
||||||
while(!jsonResponse.get("status").equals("COMPLETED") && !jsonResponse.get("status").equals("FAILED") && maxTries > 0){
|
while(!jsonResponse.get("status").equals("COMPLETED") && !jsonResponse.get("status").equals("FAILED") && maxTries > 0){
|
||||||
response = restTemplate.exchange(
|
response = restTemplate.exchange(
|
||||||
@@ -107,16 +107,18 @@ public class ExternalAgentSolver extends StepSolver {
|
|||||||
jsonResponse = new JSONObject(response.getBody());
|
jsonResponse = new JSONObject(response.getBody());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(5000);
|
Thread.sleep(2000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
logger.error("Thread was interrupted", e);
|
logger.error("Thread was interrupted", e);
|
||||||
}
|
}
|
||||||
|
logger.info ("Check status => Remaining tryes :" + maxTries)
|
||||||
maxTries--;
|
maxTries--;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info ("Stop pooling agents pod. Latest status = "+jsonResponse.get("status"));
|
||||||
|
|
||||||
if(jsonResponse.get("status").equals("COMPLETED")){
|
if(jsonResponse.get("status").equals("COMPLETED")){
|
||||||
response = restTemplate.exchange(
|
response = restTemplate.exchange(
|
||||||
this.agent_base_url + "/execution_result/" + this.scenarioExecution.getId(),
|
this.agent_base_url + "/execution_result/" + this.scenarioExecution.getId(),
|
||||||
@@ -130,6 +132,8 @@ public class ExternalAgentSolver extends StepSolver {
|
|||||||
this.scenarioExecution.setNextStepId(this.step.getNextStepId());
|
this.scenarioExecution.setNextStepId(this.step.getNextStepId());
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
logger.error ("ERROR on pooling Agents");
|
||||||
|
|
||||||
throw new Exception("Agent execution failed with status: " + jsonResponse.get("status"));
|
throw new Exception("Agent execution failed with status: " + jsonResponse.get("status"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user