diff options
author | Henrik Andersson <henrik.b.andersson@est.tech> | 2020-07-29 06:08:25 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-07-29 06:08:25 +0000 |
commit | 9be7af131a459607eebe0fe45c35abe6a41d49cc (patch) | |
tree | f1f6a859dfdca63e092c3d863bf28a1a9f872b16 /datafile-app-server/src/main/java | |
parent | 5135fde49e1268873e688d14f541b8ff673bae22 (diff) | |
parent | cfc1a64f0ec5e29ea11dd769bb7ef560f5491202 (diff) |
Merge "Add log when file is skipped because it was already published"
Diffstat (limited to 'datafile-app-server/src/main/java')
-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) { |