apurtell commented on a change in pull request #549: HBASE-22912 [Backport] 
HBASE-22867 to branch-1 to avoid ForkJoinPool to spawn thousands of threads
URL: https://github.com/apache/hbase/pull/549#discussion_r319325060
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
 ##########
 @@ -322,140 +330,154 @@ public boolean getEnabled() {
     T act() throws IOException;
   }
 
-  /**
-   * Attemps to clean up a directory, its subdirectories, and files. Return 
value is true if
-   * everything was deleted. false on partial / total failures.
-   */
-  private final class CleanerTask extends RecursiveTask<Boolean> {
-    private static final long serialVersionUID = -1584635903138015418L;
-    private final Path dir;
-    private final boolean root;
+  private interface Callback {
+    void run(boolean val);
+  }
 
-    CleanerTask(final FileStatus dir, final boolean root) {
-      this(dir.getPath(), root);
+  private final class AsyncResult {
+
+    private Callback callback;
+    private boolean result;
+    private boolean resultSet = false;
+
+    AsyncResult(Callback callback) {
+      this.callback = callback;
     }
 
-    CleanerTask(final Path dir, final boolean root) {
-      this.dir = dir;
-      this.root = root;
+    AsyncResult() {
     }
 
-    @Override
-    protected Boolean compute() {
-      LOG.trace("Cleaning under " + dir);
-      List<FileStatus> subDirs;
-      List<FileStatus> tmpFiles;
-      final List<FileStatus> files;
-      try {
-        // if dir doesn't exist, we'll get null back for both of these
-        // which will fall through to succeeding.
-        subDirs = FSUtils.listStatusWithStatusFilter(fs, dir, new 
FileStatusFilter() {
-          @Override
-          public boolean accept(FileStatus f) {
-            return f.isDirectory();
-          }
-        });
-        if (subDirs == null) {
-          subDirs = Collections.emptyList();
+    void set(boolean result) {
+      synchronized (this) {
+        this.result = result;
+        if (callback != null) {
+          callback.run(result);
         }
-        tmpFiles = FSUtils.listStatusWithStatusFilter(fs, dir, new 
FileStatusFilter() {
-          @Override
-          public boolean accept(FileStatus f) {
-            return f.isFile();
-          }
-        });
-        files = tmpFiles == null ? Collections.<FileStatus>emptyList() : 
tmpFiles;
-      } catch (IOException ioe) {
-        LOG.warn("failed to get FileStatus for contents of '" + dir + "'", 
ioe);
-        return false;
+        // Mark the result set process finished and notify the waiting get 
method.
+        this.resultSet = true;
+        this.notify();
 
 Review comment:
   notifyAll?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to