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/89073b13 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/89073b13 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/89073b13 Branch: refs/heads/develop Commit: 89073b13444728eded65d93373058bac227585ec Parents: 3dd6ac4 Author: Steve Loughran <[email protected]> Authored: Tue Nov 11 14:37:28 2014 +0000 Committer: Steve Loughran <[email protected]> Committed: Tue Nov 11 14:37:28 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/89073b13/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 a816a0d..856ad11 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 @@ -572,18 +573,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) + } } /**
