Updated ExternalAgentSolver.java

This commit is contained in:
Andrea Terzani
2024-12-18 12:16:23 +00:00
parent 2c538cdba3
commit f482712cd2

View File

@@ -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
while(!jsonResponse.get("status").equals("COMPLETED") && !jsonResponse.get("status").equals("FAILED") && maxTries > 0){
response = restTemplate.exchange(
@@ -107,16 +107,18 @@ public class ExternalAgentSolver extends StepSolver {
jsonResponse = new JSONObject(response.getBody());
try {
Thread.sleep(5000);
Thread.sleep(2000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
logger.error("Thread was interrupted", e);
}
logger.info ("Check status => Remaining tryes :" + maxTries)
maxTries--;
}
logger.info ("Stop pooling agents pod. Latest status = "+jsonResponse.get("status"));
if(jsonResponse.get("status").equals("COMPLETED")){
response = restTemplate.exchange(
this.agent_base_url + "/execution_result/" + this.scenarioExecution.getId(),
@@ -130,6 +132,8 @@ public class ExternalAgentSolver extends StepSolver {
this.scenarioExecution.setNextStepId(this.step.getNextStepId());
}else{
logger.error ("ERROR on pooling Agents");
throw new Exception("Agent execution failed with status: " + jsonResponse.get("status"));
}