- Return a success-message in the response-body, of the "shutdownWorkerGracefully" and "cancelShutdownWorkerGracefully" endpoints.

- Apply the checks for the "totalZipBatches" param, before the Worker-related checks, in "FullTextsController.getMultipleFullTexts()"
- Show the Heap-sizes in megabytes.
This commit is contained in:
Lampros Smyrnaios 2022-12-05 21:58:16 +02:00
parent 5f48f72f06
commit 326af0f12d
3 changed files with 20 additions and 19 deletions

View File

@ -58,9 +58,10 @@ public class UrlsWorkerApplication {
context = SpringApplication.run(UrlsWorkerApplication.class, args);
Runtime javaRuntime = Runtime.getRuntime();
logger.debug("HeapSize: " + javaRuntime.totalMemory());
logger.debug("HeapMaxSize: " + javaRuntime.maxMemory());
logger.debug("HeapFreeSize: " + javaRuntime.freeMemory());
int mb = 1048576;
logger.debug("HeapSize: " + (javaRuntime.totalMemory() / mb) + " mb");
logger.debug("HeapMaxSize: " + (javaRuntime.maxMemory() / mb) + " mb");
logger.debug("HeapFreeSize: " + (javaRuntime.freeMemory() / mb) + " mb");
}

View File

@ -46,16 +46,6 @@ public class FullTextsController {
return ResponseEntity.badRequest().body(errorMsg);
}
logger.info("Received a \"getMultipleFullTexts\" request for returning a zip-file containing " + fileNamesListNum + " full-texts, from assignments_" + assignmentsCounter + ", for batch_" + zipBatchCounter + " (out of " + totalZipBatches + ").");
String currentAssignmentsBaseFullTextsPath = assignmentsBaseDir + "assignments_" + assignmentsCounter + "_fullTexts" + File.separator;
if ( ! (new File(currentAssignmentsBaseFullTextsPath).isDirectory()) ) {
String errorMsg = "The base directory for assignments_" + assignmentsCounter + " was not found: " + currentAssignmentsBaseFullTextsPath;
logger.error(errorMsg);
return ResponseEntity.badRequest().body(errorMsg);
}
if ( totalZipBatches == 0 ) {
String errorMsg = "The given \"totalZipBatches\" (" + totalZipBatches + ") was < 0 >!";
logger.error(errorMsg);
@ -67,6 +57,16 @@ public class FullTextsController {
return ResponseEntity.badRequest().body(errorMsg);
}
logger.info("Received a \"getMultipleFullTexts\" request for returning a zip-file containing " + fileNamesListNum + " full-texts, from assignments_" + assignmentsCounter + ", for batch_" + zipBatchCounter + " (out of " + totalZipBatches + ").");
String currentAssignmentsBaseFullTextsPath = assignmentsBaseDir + "assignments_" + assignmentsCounter + "_fullTexts" + File.separator;
if ( ! (new File(currentAssignmentsBaseFullTextsPath).isDirectory()) ) {
String errorMsg = "The base directory for assignments_" + assignmentsCounter + " was not found: " + currentAssignmentsBaseFullTextsPath;
logger.error(errorMsg);
return ResponseEntity.badRequest().body(errorMsg);
}
File zipFile = FilesZipper.zipMultipleFilesAndGetZip(assignmentsCounter, zipBatchCounter, fileNamesWithExtensions, currentAssignmentsBaseFullTextsPath);
if ( zipFile == null ) {
String errorMsg = "Failed to create the zip file for \"zipBatchCounter\"-" + zipBatchCounter;

View File

@ -40,14 +40,14 @@ public class GeneralController {
public ResponseEntity<?> shutdownWorkerGracefully(@PathVariable String shutdownCode, HttpServletRequest request)
{
String initMsg = "Received a \"shutdownWorker\" request.";
ResponseEntity<?> responseEntity = passSecurityChecks(request, shutdownCode, initMsg);
if ( responseEntity != null )
return responseEntity;
shouldShutdownWorker = true;
logger.info(initMsg + " The worker will shutdown, after finishing current work.");
return ResponseEntity.ok().build();
String finalMsg = " The worker will shutdown, after finishing current work.";
logger.info(initMsg + finalMsg);
return ResponseEntity.ok().body(finalMsg);
}
@ -55,14 +55,14 @@ public class GeneralController {
public ResponseEntity<?> cancelShutdownWorkerGracefully(@PathVariable String cancelCode, HttpServletRequest request)
{
String initMsg = "Received a \"cancelShutdownWorker\" request.";
ResponseEntity<?> responseEntity = passSecurityChecks(request, cancelCode, initMsg);
if ( responseEntity != null )
return responseEntity;
shouldShutdownWorker = false;
logger.info(initMsg + " Any previous \"shutdownWorker\"-request is canceled. The \"maxAssignmentsBatchesToHandleBeforeShutdown\" will still be honored (if it's set).");
return ResponseEntity.ok().build();
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);
}