Repository: nifi
Updated Branches:
  refs/heads/support/nifi-0.6.x d1c82ac62 -> 3df623df0


NIFI-1726: Addressed issue where we can run into an infinite loop if we are 
expiring data based on a timestamp instead of disk space usage and we have a 
file whose timestamp is exactly equal to our threshold for deletion

Signed-off-by: joewitt <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/bcc1c6e6
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/bcc1c6e6
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/bcc1c6e6

Branch: refs/heads/support/nifi-0.6.x
Commit: bcc1c6e6cce1a709c7693b18e1afbe5c8614b1e4
Parents: d1c82ac
Author: Mark Payne <[email protected]>
Authored: Tue Apr 5 16:41:56 2016 -0400
Committer: joewitt <[email protected]>
Committed: Wed Apr 6 09:52:19 2016 -0400

----------------------------------------------------------------------
 .../nifi/controller/repository/FileSystemRepository.java      | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/bcc1c6e6/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java
index 9fec793..497e630 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java
@@ -1196,7 +1196,7 @@ public class FileSystemRepository implements 
ContentRepository {
     private long destroyExpiredArchives(final String containerName, final Path 
container) throws IOException {
         archiveExpirationLog.debug("Destroying Expired Archives for Container 
{}", containerName);
         final List<ArchiveInfo> notYetExceedingThreshold = new ArrayList<>();
-        final long removalTimeThreshold = System.currentTimeMillis() - 
maxArchiveMillis;
+        long removalTimeThreshold = System.currentTimeMillis() - 
maxArchiveMillis;
         long oldestArchiveDateFound = System.currentTimeMillis();
 
         // determine how much space we must have in order to stop deleting old 
data
@@ -1230,6 +1230,8 @@ public class FileSystemRepository implements 
ContentRepository {
             try {
                 final long fileSize = toDelete.getSize();
 
+                removalTimeThreshold = System.currentTimeMillis() - 
maxArchiveMillis;
+
                 // we use fileQueue.peek above instead of fileQueue.poll() 
because we don't always want to
                 // remove the head of the queue. Instead, we want to remove it 
only if we plan to delete it.
                 // In order to accomplish this, we just peek at the head and 
check if it should be deleted.
@@ -1287,6 +1289,7 @@ public class FileSystemRepository implements 
ContentRepository {
             }
 
             try {
+                final long timestampThreshold = removalTimeThreshold;
                 Files.walkFileTree(archive, new SimpleFileVisitor<Path>() {
                     @Override
                     public FileVisitResult visitFile(final Path file, final 
BasicFileAttributes attrs) throws IOException {
@@ -1295,7 +1298,7 @@ public class FileSystemRepository implements 
ContentRepository {
                         }
 
                         final long lastModTime = getLastModTime(file);
-                        if (lastModTime < removalTimeThreshold) {
+                        if (lastModTime < timestampThreshold) {
                             try {
                                 Files.deleteIfExists(file);
                                 containerState.decrementArchiveCount();

Reply via email to