- 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:
parent
5f48f72f06
commit
326af0f12d
|
@ -58,9 +58,10 @@ public class UrlsWorkerApplication {
|
||||||
context = SpringApplication.run(UrlsWorkerApplication.class, args);
|
context = SpringApplication.run(UrlsWorkerApplication.class, args);
|
||||||
|
|
||||||
Runtime javaRuntime = Runtime.getRuntime();
|
Runtime javaRuntime = Runtime.getRuntime();
|
||||||
logger.debug("HeapSize: " + javaRuntime.totalMemory());
|
int mb = 1048576;
|
||||||
logger.debug("HeapMaxSize: " + javaRuntime.maxMemory());
|
logger.debug("HeapSize: " + (javaRuntime.totalMemory() / mb) + " mb");
|
||||||
logger.debug("HeapFreeSize: " + javaRuntime.freeMemory());
|
logger.debug("HeapMaxSize: " + (javaRuntime.maxMemory() / mb) + " mb");
|
||||||
|
logger.debug("HeapFreeSize: " + (javaRuntime.freeMemory() / mb) + " mb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,16 +46,6 @@ public class FullTextsController {
|
||||||
return ResponseEntity.badRequest().body(errorMsg);
|
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 ) {
|
if ( totalZipBatches == 0 ) {
|
||||||
String errorMsg = "The given \"totalZipBatches\" (" + totalZipBatches + ") was < 0 >!";
|
String errorMsg = "The given \"totalZipBatches\" (" + totalZipBatches + ") was < 0 >!";
|
||||||
logger.error(errorMsg);
|
logger.error(errorMsg);
|
||||||
|
@ -67,6 +57,16 @@ public class FullTextsController {
|
||||||
return ResponseEntity.badRequest().body(errorMsg);
|
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);
|
File zipFile = FilesZipper.zipMultipleFilesAndGetZip(assignmentsCounter, zipBatchCounter, fileNamesWithExtensions, currentAssignmentsBaseFullTextsPath);
|
||||||
if ( zipFile == null ) {
|
if ( zipFile == null ) {
|
||||||
String errorMsg = "Failed to create the zip file for \"zipBatchCounter\"-" + zipBatchCounter;
|
String errorMsg = "Failed to create the zip file for \"zipBatchCounter\"-" + zipBatchCounter;
|
||||||
|
|
|
@ -40,14 +40,14 @@ public class GeneralController {
|
||||||
public ResponseEntity<?> shutdownWorkerGracefully(@PathVariable String shutdownCode, HttpServletRequest request)
|
public ResponseEntity<?> shutdownWorkerGracefully(@PathVariable String shutdownCode, HttpServletRequest request)
|
||||||
{
|
{
|
||||||
String initMsg = "Received a \"shutdownWorker\" request.";
|
String initMsg = "Received a \"shutdownWorker\" request.";
|
||||||
|
|
||||||
ResponseEntity<?> responseEntity = passSecurityChecks(request, shutdownCode, initMsg);
|
ResponseEntity<?> responseEntity = passSecurityChecks(request, shutdownCode, initMsg);
|
||||||
if ( responseEntity != null )
|
if ( responseEntity != null )
|
||||||
return responseEntity;
|
return responseEntity;
|
||||||
|
|
||||||
shouldShutdownWorker = true;
|
shouldShutdownWorker = true;
|
||||||
logger.info(initMsg + " The worker will shutdown, after finishing current work.");
|
String finalMsg = " The worker will shutdown, after finishing current work.";
|
||||||
return ResponseEntity.ok().build();
|
logger.info(initMsg + finalMsg);
|
||||||
|
return ResponseEntity.ok().body(finalMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,14 +55,14 @@ public class GeneralController {
|
||||||
public ResponseEntity<?> cancelShutdownWorkerGracefully(@PathVariable String cancelCode, HttpServletRequest request)
|
public ResponseEntity<?> cancelShutdownWorkerGracefully(@PathVariable String cancelCode, HttpServletRequest request)
|
||||||
{
|
{
|
||||||
String initMsg = "Received a \"cancelShutdownWorker\" request.";
|
String initMsg = "Received a \"cancelShutdownWorker\" request.";
|
||||||
|
|
||||||
ResponseEntity<?> responseEntity = passSecurityChecks(request, cancelCode, initMsg);
|
ResponseEntity<?> responseEntity = passSecurityChecks(request, cancelCode, initMsg);
|
||||||
if ( responseEntity != null )
|
if ( responseEntity != null )
|
||||||
return responseEntity;
|
return responseEntity;
|
||||||
|
|
||||||
shouldShutdownWorker = false;
|
shouldShutdownWorker = false;
|
||||||
logger.info(initMsg + " 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).";
|
||||||
return ResponseEntity.ok().build();
|
logger.info(initMsg + finalMsg);
|
||||||
|
return ResponseEntity.ok().body(finalMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue