- Reduce memory consumption when loading a zipFile.

- Check whether the "zipBatchCounter" is larger than the "totalZipBatches".
- Improve the "failed tasks" log-message.
This commit is contained in:
Lampros Smyrnaios 2021-12-03 16:29:16 +02:00
parent 018326eedd
commit ce49bff50e
3 changed files with 9 additions and 3 deletions

View File

@ -60,6 +60,12 @@ public class FullTextsController {
return ResponseEntity.badRequest().body(errorMsg); return ResponseEntity.badRequest().body(errorMsg);
} }
if ( zipBatchCounter > totalZipBatches ) {
String errorMsg = "The given \"zipBatchCounter\" (" + zipBatchCounter + ") is greater than the \"totalZipBatches\" (" + totalZipBatches + ")!";
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;

View File

@ -127,7 +127,7 @@ public class PublicationsRetrieverPlugin {
int numFailedTasks = LoaderAndChecker.invokeAllTasksAndWait(callableTasks); int numFailedTasks = LoaderAndChecker.invokeAllTasksAndWait(callableTasks);
if ( numFailedTasks > 0 ) if ( numFailedTasks > 0 )
logger.warn(numFailedTasks + " tasks failed!"); logger.warn(numFailedTasks + " tasks failed, from assignments_" + assignmentRequestCounter);
addUrlReportsToWorkerReport(); addUrlReportsToWorkerReport();
callableTasks.clear(); // Reset the thread-tasks-list for the next batch. callableTasks.clear(); // Reset the thread-tasks-list for the next batch.
} }

View File

@ -49,10 +49,10 @@ public class FileStorageService {
} }
private static final int bufferSize = 20971520; private static final int bufferSize = 10485760; // 10 MB
public ByteArrayOutputStream loadFileAsAStream(String fullFileName) public ByteArrayOutputStream loadFileAsAStream(String fullFileName)
{ {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(bufferSize); // 20 MB ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(bufferSize);
try { try {
FileInputStream fileInputStream = new FileInputStream(fullFileName); FileInputStream fileInputStream = new FileInputStream(fullFileName);
int bytesRead; int bytesRead;