forked from lsmyrnaios/UrlsController
- Avoid requesting the remaining full-text batches in case the Worker returns a 5XX error in one of the batches.
- Add nullability-checks for "datasourceId" and "hash" before constructing the new filename and upload the full-text on S3. - Improve a log-message.
This commit is contained in:
parent
495d5de19b
commit
484cf5cefc
|
@ -290,7 +290,7 @@ public class FileUtils {
|
||||||
continue; // To the next batch.
|
continue; // To the next batch.
|
||||||
}
|
}
|
||||||
else if ( (extractedFileNames.length -2) != fileNamesForCurBatch.size() ) {
|
else if ( (extractedFileNames.length -2) != fileNamesForCurBatch.size() ) {
|
||||||
logger.warn("The number of extracted files (" + (extractedFileNames.length -2) + ") was not equal to the number of the current-batch's files (" + fileNamesForCurBatch.size() + ").");
|
logger.warn("The number of extracted files (" + (extractedFileNames.length -2) + ") was not equal to the number of the current-batch's (" + batchCounter + ") files (" + fileNamesForCurBatch.size() + ").");
|
||||||
// We do NOT have to find and cross-reference the missing files with the urlReports, in order to set their locations to <null>,
|
// We do NOT have to find and cross-reference the missing files with the urlReports, in order to set their locations to <null>,
|
||||||
// since, in the end of each assignments-batch, an iteration will be made and for all the non-retrieved and non-uploaded full-texts, the app will set them to null.
|
// since, in the end of each assignments-batch, an iteration will be made and for all the non-retrieved and non-uploaded full-texts, the app will set them to null.
|
||||||
}
|
}
|
||||||
|
@ -330,9 +330,13 @@ public class FileUtils {
|
||||||
conn.connect();
|
conn.connect();
|
||||||
int statusCode = conn.getResponseCode();
|
int statusCode = conn.getResponseCode();
|
||||||
if ( statusCode != 200 ) {
|
if ( statusCode != 200 ) {
|
||||||
logger.warn("HTTP-" + statusCode + ": " + getMessageFromResponseBody(conn, true) + "\nProblem when requesting the ZstdFile of batch_" + batchNum + " from the Worker with ID \"" + workerId + "\" and requestUrl: " + requestUrl);
|
logger.warn("HTTP-" + statusCode + ": " + getMessageFromResponseBody(conn, true) + "\n\nProblem when requesting the ZstdFile of batch_" + batchNum + " from the Worker with ID \"" + workerId + "\" and requestUrl: " + requestUrl);
|
||||||
|
if ( (statusCode >= 500) && (statusCode <= 599) )
|
||||||
|
throw new RuntimeException(); // Throw an exception to indicate that the Worker has problems and all remaining batches will fail as well.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} catch (RuntimeException re) {
|
||||||
|
throw re;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String exMessage = e.getMessage();
|
String exMessage = e.getMessage();
|
||||||
logger.warn("Problem when requesting the ZstdFile of batch_" + batchNum + " of assignments_" + assignmentsBatchCounter + " from the Worker with ID \"" + workerId + "\" and requestUrl: " + requestUrl + "\n" + exMessage);
|
logger.warn("Problem when requesting the ZstdFile of batch_" + batchNum + " of assignments_" + assignmentsBatchCounter + " from the Worker with ID \"" + workerId + "\" and requestUrl: " + requestUrl + "\n" + exMessage);
|
||||||
|
@ -413,6 +417,16 @@ public class FileUtils {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( datasourceId == null ) {
|
||||||
|
logger.error("The retrieved \"datasourceId\" was \"null\" for file: " + fileName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( hash == null ) {
|
||||||
|
logger.error("The retrieved \"hash\" was \"null\" for file: " + fileName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
String fileFullPath = targetDirectory + fileName; // The fullPath to the local file.
|
String fileFullPath = targetDirectory + fileName; // The fullPath to the local file.
|
||||||
|
|
||||||
// Use the "fileNameID" and not the "filenameWithoutExtension", as we want to avoid keeping the possible "parenthesis" with the increasing number (about the duplication of ID-fileName).
|
// Use the "fileNameID" and not the "filenameWithoutExtension", as we want to avoid keeping the possible "parenthesis" with the increasing number (about the duplication of ID-fileName).
|
||||||
|
|
Loading…
Reference in New Issue