From 98516498ebe960e4a2aae370fc2296550ba4d2c8 Mon Sep 17 00:00:00 2001 From: LSmyrnaios Date: Mon, 4 Sep 2023 12:46:55 +0300 Subject: [PATCH] - Increase app's version. - Code polishing. --- build.gradle | 2 +- .../openaire/urls_controller/services/UrlsServiceImpl.java | 4 +--- .../java/eu/openaire/urls_controller/util/FileUtils.java | 7 +++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 2859a5e..9954268 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { java { group = 'eu.openaire.urls_controller' - version = '2.1.0-SNAPSHOT' + version = '2.4.0-SNAPSHOT' sourceCompatibility = JavaVersion.VERSION_1_8 } diff --git a/src/main/java/eu/openaire/urls_controller/services/UrlsServiceImpl.java b/src/main/java/eu/openaire/urls_controller/services/UrlsServiceImpl.java index 4508fde..981b862 100644 --- a/src/main/java/eu/openaire/urls_controller/services/UrlsServiceImpl.java +++ b/src/main/java/eu/openaire/urls_controller/services/UrlsServiceImpl.java @@ -12,7 +12,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -29,7 +28,6 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Timestamp; -import java.time.Duration; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -270,7 +268,7 @@ public class UrlsServiceImpl implements UrlsService { if ( logger.isTraceEnabled() ) logger.trace("numDuplicates in returned assignments_" + curAssignmentsBatchCounter + " = " + (assignmentsSize - distinctAssignmentsSize)); - logger.info("Sending batch-assignments_" + curAssignmentsBatchCounter + " with " + distinctAssignmentsSize + " assignments to worker with ID: " + workerId + "."); + logger.info("Sending batch-assignments_" + curAssignmentsBatchCounter + ", with " + distinctAssignmentsSize + " assignments, to worker with ID: " + workerId + "."); return ResponseEntity.status(HttpStatus.OK).body(new AssignmentsResponse(curAssignmentsBatchCounter, distinctAssignments)); } diff --git a/src/main/java/eu/openaire/urls_controller/util/FileUtils.java b/src/main/java/eu/openaire/urls_controller/util/FileUtils.java index 8dad09c..e15b094 100644 --- a/src/main/java/eu/openaire/urls_controller/util/FileUtils.java +++ b/src/main/java/eu/openaire/urls_controller/util/FileUtils.java @@ -207,8 +207,8 @@ public class FileUtils { workerIp = workerInfo.getWorkerIP(); // This won't be null. // Get the file-locations. - AtomicInteger numFullTextsFound = new AtomicInteger(); - AtomicInteger numFilesFoundFromPreviousAssignmentsBatches = new AtomicInteger(); + final AtomicInteger numFullTextsFound = new AtomicInteger(); + final AtomicInteger numFilesFoundFromPreviousAssignmentsBatches = new AtomicInteger(); SetMultimap allFileNamesWithPayloads = Multimaps.synchronizedSetMultimap(HashMultimap.create((sizeOfUrlReports / 5), 3)); // Holds multiple values for any key, if a fileName(key) has many IDs(values) associated with it. @@ -288,8 +288,7 @@ public class FileUtils { logger.warn("The current thread was interrupted when waiting for the worker-threads to finish checking for already-found file-hashes: " + ie.getMessage()); // This is a very rare case. At the moment, we just move on with what we have so far. } catch (Exception e) { - String errorMsg = "Unexpected error when checking for already-found file-hashes in parallel! " + e.getMessage(); - logger.error(errorMsg, e); + logger.error("Unexpected error when checking for already-found file-hashes in parallel!", e); return UploadFullTextsResponse.unsuccessful; } finally { DatabaseConnector.databaseLock.unlock(); // The remaining work of this function does not use the database.