You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/11/11 16:05:19 UTC

[16/17] incubator-slider git commit: SLIDER-622 bypass Haddop APIs and go to commons IO directory delete if the path is file://

SLIDER-622 bypass Haddop APIs and go to commons IO directory delete if the path is file://


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

Branch: refs/heads/releases/slider-0.60
Commit: f5324897d1649f79db9775b2f917282edfb9c810
Parents: 5afa9b3
Author: Steve Loughran <st...@apache.org>
Authored: Tue Nov 11 14:37:28 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Nov 11 15:04:47 2014 +0000

----------------------------------------------------------------------
 .../slider/test/YarnMiniClusterTestBase.groovy  | 38 +++++++++++++++++---
 1 file changed, 34 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/f5324897/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy b/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
index ffd3dab..326c217 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/YarnMiniClusterTestBase.groovy
@@ -19,6 +19,7 @@
 package org.apache.slider.test
 
 import groovy.util.logging.Slf4j
+import org.apache.commons.io.FileUtils
 import org.apache.commons.logging.Log
 import org.apache.commons.logging.LogFactory
 import org.apache.hadoop.conf.Configuration
@@ -550,18 +551,47 @@ public abstract class YarnMiniClusterTestBase extends ServiceLauncherBaseTest {
   public void rigorousDelete(
       SliderFileSystem sliderFileSystem,
       Path path, long timeout) {
+
+    if (path.toUri().scheme == "file") {
+      File dir = new File(path.toUri().getPath());
+      rigorousDelete(dir, timeout)
+    } else {
+      Duration duration = new Duration(timeout)
+      duration.start()
+      HadoopFS dfs = sliderFileSystem.fileSystem
+      boolean deleted = false;
+      while (!deleted && !duration.limitExceeded) {
+        dfs.delete(path, true)
+        deleted = !dfs.exists(path)
+        if (!deleted) {
+          sleep(1000)
+        }
+      }
+    }
+    sliderFileSystem.verifyDirectoryNonexistent(path)
+  }
+
+  /**
+   * Delete with some pauses and backoff; designed to handle slow delete
+   * operation in windows
+   * @param dir dir to delete
+   * @param timeout timeout in millis
+   */
+  public void rigorousDelete(File dir, long timeout) {
     Duration duration = new Duration(timeout)
     duration.start()
-    HadoopFS dfs = sliderFileSystem.fileSystem
     boolean deleted = false;
     while (!deleted && !duration.limitExceeded) {
-      dfs.delete(path, true)
-      deleted = !dfs.exists(path)
+      FileUtils.deleteQuietly(dir)
+      deleted = !dir.exists()
       if (!deleted) {
         sleep(1000)
       }
     }
-    sliderFileSystem.verifyDirectoryNonexistent(path)
+    if (!deleted) {
+      // noisy delete raises an IOE
+      FileUtils.deleteDirectory(dir)
+    }
   }
 
   /**