// In case the Controller is running inside a docker container, and we want to send the "shutdownServiceRequest" from the terminal (with curl), without entering inside the container,
logger.error("HTTP-Connection problem with the submission of the \"postShutdownOrCancelRequestToWorker\" of worker \""+workerId+"\"! Error-code was: "+responseCode);
returnfalse;
}else
returntrue;
}catch(HttpServerErrorExceptionhsee){
logger.error("The Worker \""+workerId+"\" failed to handle the \"postShutdownOrCancelRequestToWorker\": "+hsee.getMessage());
returnfalse;
}catch(Exceptione){
// The Spring RestTemplate may return a "ResourceAccessException", but the actual cause will has to be identified, in order to set the worker as shutdown.
Throwablecause=e.getCause();// No need to check explicitly for null.
if(causeinstanceofConnectException){// This includes the "ConnectException".
logger.error("Got a \"ConnectException\" when doing a \"postShutdownOrCancelRequestToWorker\", to the Worker: \""+workerId+"\". | Will register this worker as \"shutdown\".\n"+cause.getMessage());
logger.error("Error for \"postShutdownOrCancelRequestToWorker\", to the Worker: "+workerId,e);
// TODO - What should we do? If there was some error from the Controller, side, it does not mean that the worker has shutdown..
// For now, let's handle that case manually, by check with that specific worker and sending it a shutdownRequest from inside its VM.
// Then the Worker will automatically send a "shutdownReport" to the Controller, causing it to shutdown (when all other workers have shutdown as well).