[prev in list] [next in list] [prev in thread] [next in thread]
List: hadoop-commits
Subject: svn commit: r1367297 - in /hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common: ./
From: bobby () apache ! org
Date: 2012-07-30 21:00:16
Message-ID: 20120730210016.8526023889EC () eris ! apache ! org
[Download RAW message or body]
Author: bobby
Date: Mon Jul 30 21:00:15 2012
New Revision: 1367297
URL: http://svn.apache.org/viewvc?rev=1367297&view=rev
Log:
svn merge -c 1367296 FIXES: HADOOP-8635. Cannot cancel paths registered deleteOnExit \
(daryn via bobby)
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1367297&r1=1367296&r2=1367297&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt \
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt \
Mon Jul 30 21:00:15 2012 @@ -684,6 +684,8 @@ Release 0.23.3 - UNRELEASED
HADOOP-8550. hadoop fs -touchz automatically created parent directories
(John George via bobby)
+ HADOOP-8635. Cannot cancel paths registered deleteOnExit (daryn via bobby)
+
Release 0.23.2 - UNRELEASED
NEW FEATURES
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-projec \
t/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java?rev=1367297&r1=1367296&r2=1367297&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java \
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java \
Mon Jul 30 21:00:15 2012 @@ -1214,6 +1214,16 @@ public abstract class FileSystem \
extends }
return true;
}
+
+ /**
+ * Cancel the deletion of the path when the FileSystem is closed
+ * @param f the path to cancel deletion
+ */
+ public boolean cancelDeleteOnExit(Path f) {
+ synchronized (deleteOnExit) {
+ return deleteOnExit.remove(f);
+ }
+ }
/**
* Delete all files that were marked as delete-on-exit. This recursively
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-projec \
t/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java?rev=1367297&r1=1367296&r2=1367297&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java \
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java \
Mon Jul 30 21:00:15 2012 @@ -269,26 +269,82 @@ public class TestFileSystemCaching {
}
@Test
- public void testDeleteOnExitChecksExists() throws Exception {
+ public void testDelete() throws IOException {
+ FileSystem mockFs = mock(FileSystem.class);
+ FileSystem fs = new FilterFileSystem(mockFs);
+ Path path = new Path("/a");
+
+ fs.delete(path, false);
+ verify(mockFs).delete(eq(path), eq(false));
+ reset(mockFs);
+ fs.delete(path, true);
+ verify(mockFs).delete(eq(path), eq(true));
+ }
+
+ @Test
+ public void testDeleteOnExit() throws IOException {
FileSystem mockFs = mock(FileSystem.class);
FileSystem fs = new FilterFileSystem(mockFs);
- Path p = new Path("/a");
-
- // path has to exist for deleteOnExit to register it
- when(mockFs.getFileStatus(p)).thenReturn(new FileStatus());
- fs.deleteOnExit(p);
- verify(mockFs).getFileStatus(eq(p));
+ Path path = new Path("/a");
+
+ // delete on close if path does exist
+ when(mockFs.getFileStatus(eq(path))).thenReturn(new FileStatus());
+ assertTrue(fs.deleteOnExit(path));
+ verify(mockFs).getFileStatus(eq(path));
+ reset(mockFs);
+ when(mockFs.getFileStatus(eq(path))).thenReturn(new FileStatus());
+ fs.close();
+ verify(mockFs).getFileStatus(eq(path));
+ verify(mockFs).delete(eq(path), eq(true));
+ }
+
+ @Test
+ public void testDeleteOnExitFNF() throws IOException {
+ FileSystem mockFs = mock(FileSystem.class);
+ FileSystem fs = new FilterFileSystem(mockFs);
+ Path path = new Path("/a");
+
+ // don't delete on close if path doesn't exist
+ assertFalse(fs.deleteOnExit(path));
+ verify(mockFs).getFileStatus(eq(path));
+ reset(mockFs);
fs.close();
- verify(mockFs).delete(eq(p), anyBoolean());
+ verify(mockFs, never()).getFileStatus(eq(path));
+ verify(mockFs, never()).delete(any(Path.class), anyBoolean());
+ }
+
+
+ @Test
+ public void testDeleteOnExitRemoved() throws IOException {
+ FileSystem mockFs = mock(FileSystem.class);
+ FileSystem fs = new FilterFileSystem(mockFs);
+ Path path = new Path("/a");
+
+ // don't delete on close if path existed, but later removed
+ when(mockFs.getFileStatus(eq(path))).thenReturn(new FileStatus());
+ assertTrue(fs.deleteOnExit(path));
+ verify(mockFs).getFileStatus(eq(path));
reset(mockFs);
-
- // make sure it doesn't try to delete a file that doesn't exist
- when(mockFs.getFileStatus(p)).thenReturn(new FileStatus());
- fs.deleteOnExit(p);
- verify(mockFs).getFileStatus(eq(p));
+ fs.close();
+ verify(mockFs).getFileStatus(eq(path));
+ verify(mockFs, never()).delete(any(Path.class), anyBoolean());
+ }
+
+ @Test
+ public void testCancelDeleteOnExit() throws IOException {
+ FileSystem mockFs = mock(FileSystem.class);
+ FileSystem fs = new FilterFileSystem(mockFs);
+ Path path = new Path("/a");
+
+ // don't delete on close if path existed, but later cancelled
+ when(mockFs.getFileStatus(eq(path))).thenReturn(new FileStatus());
+ assertTrue(fs.deleteOnExit(path));
+ verify(mockFs).getFileStatus(eq(path));
+ assertTrue(fs.cancelDeleteOnExit(path));
+ assertFalse(fs.cancelDeleteOnExit(path)); // false because not registered
reset(mockFs);
fs.close();
- verify(mockFs).getFileStatus(eq(p));
+ verify(mockFs, never()).getFileStatus(any(Path.class));
verify(mockFs, never()).delete(any(Path.class), anyBoolean());
}
-}
\ No newline at end of file
+}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-projec \
t/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java?rev=1367297&r1=1367296&r2=1367297&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java \
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java \
Mon Jul 30 21:00:15 2012 @@ -182,6 +182,9 @@ public class TestFilterFileSystem {
public boolean deleteOnExit(Path f) throws IOException {
return false;
}
+ public boolean cancelDeleteOnExit(Path f) throws IOException {
+ return false;
+ }
public String getScheme() {
return "dontcheck";
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic