accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [accumulo] branch 1.8 updated: ACCUMULO-4805 Optimize file manager when no files to open (#389)
Date Wed, 21 Feb 2018 17:11:07 GMT
This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch 1.8
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/1.8 by this push:
     new fb72991  ACCUMULO-4805 Optimize file manager when no files to open (#389)
fb72991 is described below

commit fb7299118fbe16f41e969fccbc8aadaa30bd0d88
Author: Keith Turner <keith@deenlo.com>
AuthorDate: Wed Feb 21 12:11:04 2018 -0500

    ACCUMULO-4805 Optimize file manager when no files to open (#389)
---
 .../org/apache/accumulo/tserver/FileManager.java    | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java
index 2aaad39..9833232 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java
@@ -245,10 +245,8 @@ public class FileManager {
   }
 
   private List<String> takeOpenFiles(Collection<String> files, Map<FileSKVIterator,String>
readersReserved) {
-    List<String> filesToOpen = new LinkedList<>(files);
-    for (Iterator<String> iterator = filesToOpen.iterator(); iterator.hasNext();) {
-      String file = iterator.next();
-
+    List<String> filesToOpen = Collections.emptyList();
+    for (String file : files) {
       List<OpenReader> ofl = openFiles.get(file);
       if (ofl != null && ofl.size() > 0) {
         OpenReader openReader = ofl.remove(ofl.size() - 1);
@@ -256,9 +254,12 @@ public class FileManager {
         if (ofl.size() == 0) {
           openFiles.remove(file);
         }
-        iterator.remove();
+      } else {
+        if (filesToOpen.isEmpty()) {
+          filesToOpen = new ArrayList<>(files.size());
+        }
+        filesToOpen.add(file);
       }
-
     }
     return filesToOpen;
   }
@@ -291,10 +292,12 @@ public class FileManager {
 
       filesToOpen = takeOpenFiles(files, readersReserved);
 
-      int numOpen = countReaders(openFiles);
+      if (!filesToOpen.isEmpty()) {
+        int numOpen = countReaders(openFiles);
 
-      if (filesToOpen.size() + numOpen + reservedReaders.size() > maxOpen) {
-        filesToClose = takeLRUOpenFiles((filesToOpen.size() + numOpen + reservedReaders.size())
- maxOpen);
+        if (filesToOpen.size() + numOpen + reservedReaders.size() > maxOpen) {
+          filesToClose = takeLRUOpenFiles((filesToOpen.size() + numOpen + reservedReaders.size())
- maxOpen);
+        }
       }
     }
 

-- 
To stop receiving notification emails like this one, please contact
kturner@apache.org.

Mime
View raw message