hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhr...@apache.org
Subject svn commit: r632174 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/ClientProtocol.java src/java/org/apache/hadoop/dfs/DFSClient.java src/java/org/apache/hadoop/dfs/NameNode.java src/test/org/apache/hadoop/dfs/TestFileCreation.java
Date Thu, 28 Feb 2008 23:55:30 GMT
Author: dhruba
Date: Thu Feb 28 15:55:27 2008
New Revision: 632174

URL: http://svn.apache.org/viewvc?rev=632174&view=rev
Log:
HADOOP-2891.  DFSClient.close() closes all open files. (dhruba)


Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/dfs/ClientProtocol.java
    hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java
    hadoop/core/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
    hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestFileCreation.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=632174&r1=632173&r2=632174&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu Feb 28 15:55:27 2008
@@ -89,6 +89,8 @@
     HADOOP-2800.  Deprecate SetFile.Writer constructor not the whole class.
     (Johan Oskarsson via tomwhite)
 
+    HADOOP-2891.  DFSClient.close() closes all open files. (dhruba)
+
 Release 0.16.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/dfs/ClientProtocol.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/dfs/ClientProtocol.java?rev=632174&r1=632173&r2=632174&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/dfs/ClientProtocol.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/dfs/ClientProtocol.java Thu Feb 28 15:55:27
2008
@@ -185,6 +185,7 @@
    * @param src The filename
    * @param holder The datanode holding the lease
    */
+  @Deprecated
   public void abandonFileInProgress(String src, 
                                     String holder) throws IOException;
 

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java?rev=632174&r1=632173&r2=632174&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/dfs/DFSClient.java Thu Feb 28 15:55:27 2008
@@ -172,10 +172,13 @@
         Iterator file_itr = pendingCreates.keySet().iterator();
         while (file_itr.hasNext()) {
           String name = (String) file_itr.next();
+          OutputStream out = pendingCreates.get(name);
           try {
-            namenode.abandonFileInProgress(name, clientName);
+            if (out != null) {
+              out.close();
+            }
           } catch (IOException ie) {
-            System.err.println("Exception abandoning create lock on " + name);
+            System.err.println("Exception closing file " + name);
             ie.printStackTrace();
           }
         }

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/dfs/NameNode.java?rev=632174&r1=632173&r2=632174&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/dfs/NameNode.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/dfs/NameNode.java Thu Feb 28 15:55:27 2008
@@ -325,6 +325,7 @@
   }
   /**
    */
+  @Deprecated
   public void abandonFileInProgress(String src, 
                                     String holder) throws IOException {
     stateChangeLog.debug("*DIR* NameNode.abandonFileInProgress:" + src);

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestFileCreation.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestFileCreation.java?rev=632174&r1=632173&r2=632174&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestFileCreation.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestFileCreation.java Thu Feb 28 15:55:27
2008
@@ -418,6 +418,52 @@
     }
   }
 
+  /**
+   * Test that all open files are closed when client dies abnormally.
+   */
+  public void testDFSClientDeath() throws IOException {
+    Configuration conf = new Configuration();
+    System.out.println("Testing adbornal client death.");
+    if (simulatedStorage) {
+      conf.setBoolean(SimulatedFSDataset.CONFIG_PROPERTY_SIMULATED, true);
+    }
+    MiniDFSCluster cluster = new MiniDFSCluster(conf, 1, true, null);
+    FileSystem fs = cluster.getFileSystem();
+    DistributedFileSystem dfs = (DistributedFileSystem) fs;
+    DFSClient dfsclient = dfs.dfs;
+    try {
+
+      // create a new file in home directory. Do not close it.
+      //
+      Path file1 = new Path("/clienttest.dat");
+      FSDataOutputStream stm = createFile(fs, file1, 1);
+      System.out.println("Created file clienttest.dat");
+
+      // write to file
+      writeFile(stm);
+
+      // close the dfsclient before closing the output stream.
+      // This should close all existing file.
+      dfsclient.close();
+
+      try {
+        fs.close();
+        fs = null;
+      } catch (IOException e) {
+      }
+
+      // reopen file system and verify that file exists.
+      fs = cluster.getFileSystem();
+      assertTrue(file1 + " does not exist.", fs.exists(file1));
+
+    } finally {
+      if (fs != null) {
+        fs.close();
+      }
+      cluster.shutdown();
+    }
+  }
+
 /**
  * Test that file data becomes available before file is closed.
  */



Mime
View raw message