hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jiten...@apache.org
Subject svn commit: r1195620 - in /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: ./ src/main/java/org/apache/hadoop/hdfs/server/namenode/
Date Mon, 31 Oct 2011 19:03:55 GMT
Author: jitendra
Date: Mon Oct 31 19:03:55 2011
New Revision: 1195620

URL: http://svn.apache.org/viewvc?rev=1195620&view=rev
Log:
HDFS-2334. Add Closeable to JournalManager. Contributed by Ivan Kelly.

Modified:
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupJournalManager.java
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/JournalManager.java
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/JournalSet.java

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1195620&r1=1195619&r2=1195620&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Mon Oct 31 19:03:55 2011
@@ -50,6 +50,8 @@ Trunk (unreleased changes)
 
     HDFS-2479 HDFS Client Data Types in Protocol Buffers (sanjay)
 
+    HDFS-2334. Add Closeable to JournalManager. (Ivan Kelly via jitendra)
+
   BUG FIXES
     HDFS-2287. TestParallelRead has a small off-by-one bug. (todd)
 

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupJournalManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupJournalManager.java?rev=1195620&r1=1195619&r2=1195620&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupJournalManager.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupJournalManager.java
Mon Oct 31 19:03:55 2011
@@ -77,6 +77,9 @@ class BackupJournalManager implements Jo
   public void recoverUnfinalizedSegments() throws IOException {
   }
 
+  @Override 
+  public void close() throws IOException {}
+
   public boolean matchesRegistration(NamenodeRegistration bnReg) {
     return bnReg.getAddress().equals(this.bnReg.getAddress());
   }

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java?rev=1195620&r1=1195619&r2=1195620&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
Mon Oct 31 19:03:55 2011
@@ -215,6 +215,12 @@ public class FSEditLog  {
       waitForSyncToFinish();
       endCurrentLogSegment(true);
     }
+    
+    try {
+      journalSet.close();
+    } catch (IOException ioe) {
+      LOG.warn("Error closing journalSet", ioe);
+    }
 
     state = State.CLOSED;
   }

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java?rev=1195620&r1=1195619&r2=1195620&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileJournalManager.java
Mon Oct 31 19:03:55 2011
@@ -70,6 +70,9 @@ class FileJournalManager implements Jour
     this.sd = sd;
   }
 
+  @Override 
+  public void close() throws IOException {}
+
   @Override
   synchronized public EditLogOutputStream startLogSegment(long txid) 
       throws IOException {

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/JournalManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/JournalManager.java?rev=1195620&r1=1195619&r2=1195620&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/JournalManager.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/JournalManager.java
Mon Oct 31 19:03:55 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hdfs.server.namenode;
 
+import java.io.Closeable;
 import java.io.IOException;
 
 
@@ -27,7 +28,7 @@ import java.io.IOException;
  * each conceptual place of storage corresponds to exactly one instance of
  * this class, which is created when the EditLog is first opened.
  */
-interface JournalManager {
+interface JournalManager extends Closeable {
   /**
    * Begin writing to a new segment of the log stream, which starts at
    * the given transaction ID.
@@ -81,6 +82,11 @@ interface JournalManager {
    */
   void recoverUnfinalizedSegments() throws IOException;
 
+  /**
+   * Close the journal manager, freeing any resources it may hold.
+   */
+  void close() throws IOException;
+
   /** 
    * Indicate that a journal is cannot be used to load a certain range of 
    * edits.

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/JournalSet.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/JournalSet.java?rev=1195620&r1=1195619&r2=1195620&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/JournalSet.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/JournalSet.java
Mon Oct 31 19:03:55 2011
@@ -72,11 +72,20 @@ public class JournalSet implements Journ
     /**
      * Closes the stream, also sets it to null.
      */
-    public void close() throws IOException {
+    public void closeStream() throws IOException {
       if (stream == null) return;
       stream.close();
       stream = null;
     }
+
+    /**
+     * Close the Journal and Stream
+     */
+    public void close() throws IOException {
+      closeStream();
+
+      journal.close();
+    }
     
     /**
      * Aborts the stream, also sets it to null.
@@ -145,13 +154,23 @@ public class JournalSet implements Journ
       @Override
       public void apply(JournalAndStream jas) throws IOException {
         if (jas.isActive()) {
-          jas.close();
+          jas.closeStream();
           jas.getManager().finalizeLogSegment(firstTxId, lastTxId);
         }
       }
     }, "finalize log segment " + firstTxId + ", " + lastTxId);
   }
-  
+   
+  @Override
+  public void close() throws IOException {
+    mapJournalsAndReportErrors(new JournalClosure() {
+      @Override
+      public void apply(JournalAndStream jas) throws IOException {
+        jas.close();
+      }
+    }, "close journal");
+  }
+
   
   /**
    * Find the best editlog input stream to read from txid.
@@ -332,7 +351,7 @@ public class JournalSet implements Journ
       mapJournalsAndReportErrors(new JournalClosure() {
         @Override
         public void apply(JournalAndStream jas) throws IOException {
-          jas.close();
+          jas.closeStream();
         }
       }, "close");
     }



Mime
View raw message