- Use the "POST" method for shutdown and cancelShutdown requests.
- Polish some messages.
This commit is contained in:
parent
9fdaa9503b
commit
bfa569685a
|
@ -56,7 +56,7 @@ public class GeneralController {
|
|||
|
||||
public static boolean shouldShutdownWorker = false;
|
||||
|
||||
@GetMapping("shutdownWorker")
|
||||
@PostMapping("shutdownWorker")
|
||||
public ResponseEntity<?> shutdownWorkerGracefully(HttpServletRequest request)
|
||||
{
|
||||
String initMsg = "Received a \"shutdownWorker\" request. ";
|
||||
|
@ -76,16 +76,16 @@ public class GeneralController {
|
|||
}
|
||||
|
||||
|
||||
@GetMapping("cancelShutdownWorker")
|
||||
@PostMapping("cancelShutdownWorker")
|
||||
public ResponseEntity<?> cancelShutdownWorkerGracefully(HttpServletRequest request)
|
||||
{
|
||||
String initMsg = "Received a \"cancelShutdownWorker\" request.";
|
||||
String initMsg = "Received a \"cancelShutdownWorker\" request. ";
|
||||
ResponseEntity<?> responseEntity = passSecurityChecks(request, initMsg);
|
||||
if ( responseEntity != null )
|
||||
return responseEntity;
|
||||
|
||||
shouldShutdownWorker = false;
|
||||
String finalMsg = " Any previous \"shutdownWorker\"-request is canceled. The \"maxAssignmentsBatchesToHandleBeforeShutdown\" will still be honored (if it's set).";
|
||||
String finalMsg = "Any previous \"shutdownWorker\"-request is canceled. The \"maxAssignmentsBatchesToHandleBeforeShutdown\" will still be honored (if it's set).";
|
||||
logger.info(initMsg + finalMsg);
|
||||
return ResponseEntity.ok().body(finalMsg + "\n");
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class GeneralController {
|
|||
public ResponseEntity<?> passSecurityChecks(HttpServletRequest request, String initMsg)
|
||||
{
|
||||
if ( request == null ) {
|
||||
logger.error(initMsg + " The \"HttpServletRequest\" is null!");
|
||||
logger.error(initMsg + "The \"HttpServletRequest\" is null!");
|
||||
return ResponseEntity.internalServerError().build();
|
||||
}
|
||||
String remoteAddr = request.getHeader("X-FORWARDED-FOR");
|
||||
|
@ -130,7 +130,7 @@ public class GeneralController {
|
|||
remoteAddr = request.getRemoteAddr();
|
||||
|
||||
if ( ! (remoteAddr.equals("127.0.0.1") || remoteAddr.equals(UriBuilder.ip) || remoteAddr.equals(controllerIp)) ) {
|
||||
logger.error(initMsg + " The request came from another IP: " + remoteAddr + " | while this worker has the IP: " + UriBuilder.ip);
|
||||
logger.error(initMsg + "The request came from another IP: " + remoteAddr + " | while this worker has the IP: " + UriBuilder.ip);
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
||||
}
|
||||
return null; // The checks are passing.
|
||||
|
|
Loading…
Reference in New Issue