- Allow the user to set a maximum number of assignments-batches for the Worker to handle. After handling those batches, the Worker will shut down. A number of < 0 > indicates an infinite number of batches.
- Avoid converting the zero fileSize to < null >. Now, the default value is < null >, so the zero-value will indicate a zero-byte file.
- Update dependencies.
- Code cleanup.
@ -115,7 +126,7 @@ public class UrlsWorkerApplication {
myReader=newScanner(inputDataFile);
if(myReader.hasNextLine()){
String[]data=myReader.nextLine().split(",");
if(data.length<3){
if(data.length<4){
StringerrorMsg="Not all data were retrieved from file \""+inputDataFilePath+"\"!";
logger.error(errorMsg);
System.err.println(errorMsg);
@ -129,7 +140,14 @@ public class UrlsWorkerApplication {
logger.warn("The given \"maxAssignmentsLimitPerBatch\" ("+maxAssignmentsLimitStr+") was not a number! Will use the default one: "+WorkerConstants.ASSIGNMENTS_LIMIT);
logger.warn("The given \"maxAssignmentsBatchesToHandleBeforeRestart\" ("+maxAssignmentsBatchesStr+") was not a number! Will handle an infinite number of batches!");
maxAssignmentsBatchesToHandleBeforeRestart=0;
}
controllerBaseUrl=data[3].trim();
try{
newURL(controllerBaseUrl);
}catch(MalformedURLExceptionmue){
@ -142,14 +160,14 @@ public class UrlsWorkerApplication {
controllerBaseUrl+="/";// Make sure the other urls will not break later.
StringerrorMsg="No \"workerId\" or/and \"maxAssignmentsLimitPerBatch\" or/and \"controllerBaseUrl\" could be retrieved from the file: " +inputDataFilePath;
StringerrorMsg="No \"workerId\" or/and \"maxAssignmentsLimitPerBatch\" or/and \"maxAssignmentsBatchesToHandleBeforeRestart\" or/and \"controllerBaseUrl\" could be retrieved from the file: " +inputDataFilePath;
logger.error(errorMsg);
System.err.println(errorMsg);
System.exit(63);
}
logger.info("workerId: "+workerId+", maxAssignmentsLimitPerBatch: "+maxAssignmentsLimitPerBatch+", controllerBaseUrl: " +controllerBaseUrl);// It's safe and helpful to show them in the logs.
logger.info("workerId: "+workerId+", maxAssignmentsLimitPerBatch: "+maxAssignmentsLimitPerBatch+", maxAssignmentsBatchesToHandleBeforeRestart: " +maxAssignmentsBatchesToHandleBeforeRestart+", controllerBaseUrl: " +controllerBaseUrl);// It's safe and helpful to show them in the logs.
}catch(Exceptione){
StringerrorMsg="An error prevented the retrieval of the workerId and the controllerBaseUrl from the file: "+inputDataFilePath+"\n"+e.getMessage();
logger.info("The maximum assignments-batches ("+UrlsWorkerApplication.maxAssignmentsBatchesToHandleBeforeRestart+") to be handled was reached! Shut down, in order for the external Linux-service to restart on its own..");
UrlsWorkerApplication.gentleShutdown();
}
}else{
//logger.debug("The worker is not available for work at the moment.."); // JUST FOR DEBUG!
@ -171,7 +171,7 @@ public class PublicationsRetrieverPlugin {
fileLocation=comment;// This is the full-file-path.
mimeType="application/pdf";
}else// Else the file was not retrieved, so all file-related data are kept "null".
error=newError(Error.ErrorType.couldRetry,comment);// We can still try to download it in the future.
error=newError(Error.ErrorType.couldRetry,comment);// We can still try to download it from the found docUrl, in the future.
if(error==null)// If the file was retrieved, in any time.
error=newError(Error.ErrorType.couldRetry,null);// We do not want to send a "null" object, since it just adds more complicated handling in the controller..
@ -188,10 +188,7 @@ public class PublicationsRetrieverPlugin {
logger.info("The submission of the WorkerReport of assignments_"+assignmentRequestCounter+" to the Controller, and the full-text delivering, were successful!");
returntrue;
}else{
logger.error("HTTP-Connection problem with the submission of the WorkerReport of assignment_"+assignmentRequestCounter+" to the Controller. Error-code was: "+responseCode);
returnfalse;
}
@ -150,7 +157,6 @@ public class AssignmentsHandler {
urlReports.clear();// Reset, without de-allocating.