aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java')
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java39
1 files changed, 21 insertions, 18 deletions
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java
index 72341ee5..df5302c0 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java
@@ -123,24 +123,7 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
running = true;
while (running) {
key = watcher.take();
-
- for (final WatchEvent<?> event : key.pollEvents()) {
- final WatchEvent<Path> ev = (WatchEvent<Path>) event;
- final Path fileName = ev.context();
- pool.execute(() -> {
- LOGGER.debug("new CSAR found: {}", fileName);
- DistributionStatisticsManager.updateTotalDistributionCount();
- final String fullFilePath = dir.toString() + File.separator + fileName.toString();
- try {
- waitForFileToBeReady(fullFilePath);
- createPolicyInputAndCallHandler(fullFilePath);
- LOGGER.debug("CSAR complete: {}", fileName);
- } catch (InterruptedException e) {
- LOGGER.error("waitForFileToBeReady interrupted", e);
- Thread.currentThread().interrupt();
- }
- });
- }
+ processFileEvents(dir, key, pool);
final boolean valid = key.reset();
if (!valid) {
LOGGER.error("Watch key no longer valid!");
@@ -152,6 +135,26 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
}
}
+ private void processFileEvents(Path dir, WatchKey key, ExecutorService pool) {
+ for (final WatchEvent<?> event : key.pollEvents()) {
+ final WatchEvent<Path> ev = (WatchEvent<Path>) event;
+ final Path fileName = ev.context();
+ pool.execute(() -> {
+ LOGGER.debug("new CSAR found: {}", fileName);
+ DistributionStatisticsManager.updateTotalDistributionCount();
+ final String fullFilePath = dir.toString() + File.separator + fileName.toString();
+ try {
+ waitForFileToBeReady(fullFilePath);
+ createPolicyInputAndCallHandler(fullFilePath);
+ LOGGER.debug("CSAR complete: {}", fileName);
+ } catch (InterruptedException e) {
+ LOGGER.error("waitForFileToBeReady interrupted", e);
+ Thread.currentThread().interrupt();
+ }
+ });
+ }
+ }
+
/**
* Method to create policy input & call policy handlers.
*