diff options
author | Remigiusz Janeczek <remigiusz.janeczek@nokia.com> | 2020-07-23 13:00:25 +0200 |
---|---|---|
committer | Remigiusz Janeczek <remigiusz.janeczek@nokia.com> | 2020-07-28 15:01:17 +0200 |
commit | cfc1a64f0ec5e29ea11dd769bb7ef560f5491202 (patch) | |
tree | bb831dfc5209f8842cdeab6f136bb5e714c7dff7 /datafile-app-server/src/main | |
parent | a4638a48f6b369c3913e464bd73a952427d74c4a (diff) |
Add log when file is skipped because it was already published
Issue-ID: DCAEGEN2-2366
Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com>
Change-Id: I913b887833e412dd9c0093936a9231d37f63e7d1
Diffstat (limited to 'datafile-app-server/src/main')
-rw-r--r-- | datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java index de45da31..42a6fea3 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java @@ -220,17 +220,26 @@ public class ScheduledTasks { private boolean shouldBePublished(FileDataWithContext fileData) { Path localFilePath = fileData.fileData.getLocalFilePath(); - if (publishedFilesCache.put(localFilePath) == null) { - try { - return !createPublishedChecker().isFilePublished(fileData.fileData.name(), + boolean shouldBePublished = (publishedFilesCache.put(localFilePath) == null); + if (shouldBePublished) { + shouldBePublished = checkIfFileIsNotPublishedInDataRouter(fileData); + } + + if (!shouldBePublished) { + logger.debug("File: {} is being processed or was already published. Skipping.", fileData.fileData.name()); + } + return shouldBePublished; + } + + private boolean checkIfFileIsNotPublishedInDataRouter(FileDataWithContext fileData) { + boolean isNotPublished = true; + try { + isNotPublished = !createPublishedChecker().isFilePublished(fileData.fileData.name(), fileData.fileData.messageMetaData().changeIdentifier(), fileData.context); - } catch (DatafileTaskException e) { - logger.error("Cannot check if a file {} is published", fileData.fileData.name(), e); - return true; // Publish it then - } - } else { - return false; + } catch (DatafileTaskException e) { + logger.error("Cannot check if a file {} is published", fileData.fileData.name(), e); } + return isNotPublished; } private Mono<FilePublishInformation> fetchFile(FileDataWithContext fileData) { |