From e1a59c47b7373c1165cc10623e4a2c945e470a4b Mon Sep 17 00:00:00 2001 From: danbress Date: Sat, 13 Jun 2015 12:22:38 -0400 Subject: [PATCH] NIFI-632 moving thread startup from constructor to initialize methods --- .../repository/FileSystemRepository.java | 36 +++++++++---------- .../repository/VolatileContentRepository.java | 8 ++--- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java index 3a03fad44e..1171636d96 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java @@ -130,7 +130,6 @@ public class FileSystemRepository implements ContentRepository { final String maxArchiveRetentionPeriod = properties.getProperty(NiFiProperties.CONTENT_ARCHIVE_MAX_RETENTION_PERIOD); final String maxArchiveSize = properties.getProperty(NiFiProperties.CONTENT_ARCHIVE_MAX_USAGE_PERCENTAGE); final String archiveBackPressureSize = properties.getProperty(NiFiProperties.CONTENT_ARCHIVE_BACK_PRESSURE_PERCENTAGE); - final String archiveCleanupFrequency = properties.getProperty(NiFiProperties.CONTENT_ARCHIVE_CLEANUP_FREQUENCY); if ("true".equalsIgnoreCase(enableArchiving)) { archiveData = true; @@ -193,24 +192,7 @@ public class FileSystemRepository implements ContentRepository { LOG.info("Initializing FileSystemRepository with 'Always Sync' set to {}", alwaysSync); initializeRepository(); - final long cleanupMillis; - if (archiveCleanupFrequency == null) { - cleanupMillis = 1000L; - } else { - try { - cleanupMillis = FormatUtils.getTimeDuration(archiveCleanupFrequency.trim(), TimeUnit.MILLISECONDS); - } catch (final Exception e) { - throw new RuntimeException("Invalid value set for property " + NiFiProperties.CONTENT_ARCHIVE_CLEANUP_FREQUENCY); - } - } - containerCleanupExecutor = new FlowEngine(containers.size(), "Cleanup FileSystemRepository Container", true); - for (final Map.Entry containerEntry : containers.entrySet()) { - final String containerName = containerEntry.getKey(); - final Path containerPath = containerEntry.getValue(); - final Runnable cleanup = new DestroyExpiredArchiveClaims(containerName, containerPath); - containerCleanupExecutor.scheduleWithFixedDelay(cleanup, cleanupMillis, cleanupMillis, TimeUnit.MILLISECONDS); - } } @Override @@ -225,6 +207,24 @@ public class FileSystemRepository implements ContentRepository { for (int i = 0; i < fileRespositoryPaths.size(); i++) { executor.scheduleWithFixedDelay(new ArchiveOrDestroyDestructableClaims(), 1, 1, TimeUnit.SECONDS); } + + final String archiveCleanupFrequency = properties.getProperty(NiFiProperties.CONTENT_ARCHIVE_CLEANUP_FREQUENCY); + final long cleanupMillis; + if (archiveCleanupFrequency == null) { + cleanupMillis = 1000L; + } else { + try { + cleanupMillis = FormatUtils.getTimeDuration(archiveCleanupFrequency.trim(), TimeUnit.MILLISECONDS); + } catch (final Exception e) { + throw new RuntimeException("Invalid value set for property " + NiFiProperties.CONTENT_ARCHIVE_CLEANUP_FREQUENCY); + } + } + for (final Map.Entry containerEntry : containers.entrySet()) { + final String containerName = containerEntry.getKey(); + final Path containerPath = containerEntry.getValue(); + final Runnable cleanup = new DestroyExpiredArchiveClaims(containerName, containerPath); + containerCleanupExecutor.scheduleWithFixedDelay(cleanup, cleanupMillis, cleanupMillis, TimeUnit.MILLISECONDS); + } } @Override diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java index 597186547c..6109ba3830 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java @@ -118,15 +118,15 @@ public class VolatileContentRepository implements ContentRepository { } memoryManager = new MemoryManager(maxBytes, blockSize); - - for (int i = 0; i < 3; i++) { - executor.scheduleWithFixedDelay(new CleanupOldClaims(), 1000, 10, TimeUnit.MILLISECONDS); - } } @Override public void initialize(final ContentClaimManager claimManager) { this.claimManager = claimManager; + + for (int i = 0; i < 3; i++) { + executor.scheduleWithFixedDelay(new CleanupOldClaims(), 1000, 10, TimeUnit.MILLISECONDS); + } } @Override