소스 검색

HADOOP-1520. Add appropriate synchronization to FSEditsLog. Contributed by Dhruba

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@551979 13f79535-47bb-0310-9956-ffa450edef68
Nigel Daley 18 년 전
부모
커밋
0c48d2ef94
3개의 변경된 파일15개의 추가작업 그리고 12개의 파일을 삭제
  1. 3 0
      CHANGES.txt
  2. 10 10
      src/java/org/apache/hadoop/dfs/FSEditLog.java
  3. 2 2
      src/java/org/apache/hadoop/dfs/FSNamesystem.java

+ 3 - 0
CHANGES.txt

@@ -268,6 +268,9 @@ Trunk (unreleased changes)
  82. HADOOP-1536.  Remove file locks from libhdfs tests.
      (Dhruba Borthakur via nigel)
 
+ 83. HADOOP-1520.  Add appropriate synchronization to FSEditsLog.
+     (Dhruba Borthakur via nigel)
+
 
 Release 0.13.0 - 2007-06-08
 

+ 10 - 10
src/java/org/apache/hadoop/dfs/FSEditLog.java

@@ -88,7 +88,7 @@ class FSEditLog {
     return fsimage.getNumStorageDirs();
   }
   
-  int getNumEditStreams() {
+  synchronized int getNumEditStreams() {
     return editStreams == null ? 0 : editStreams.size();
   }
 
@@ -98,7 +98,7 @@ class FSEditLog {
    * 
    * @throws IOException
    */
-  void open() throws IOException {
+  synchronized void open() throws IOException {
     int size = getNumStorageDirs();
     if (editStreams == null)
       editStreams = new ArrayList<EditLogOutputStream>(size);
@@ -115,7 +115,7 @@ class FSEditLog {
     }
   }
 
-  void createEditLogFile(File name) throws IOException {
+  synchronized void createEditLogFile(File name) throws IOException {
     EditLogOutputStream eStream = new EditLogOutputStream(name);
     eStream.create();
     eStream.flushAndSync();
@@ -125,7 +125,7 @@ class FSEditLog {
   /**
    * Create edits.new if non existant.
    */
-  void createNewIfMissing() throws IOException {
+  synchronized void createNewIfMissing() throws IOException {
     for (int idx = 0; idx < getNumStorageDirs(); idx++) {
       File newFile = getEditNewFile(idx);
       if (!newFile.exists())
@@ -136,7 +136,7 @@ class FSEditLog {
   /**
    * Shutdown the filestore
    */
-  void close() throws IOException {
+  synchronized void close() throws IOException {
     if (editStreams == null) {
       return;
     }
@@ -159,7 +159,7 @@ class FSEditLog {
    * remain, then raise an exception that will possibly cause the
    * server to exit
    */
-  void processIOError(int index) throws IOException {
+  synchronized void processIOError(int index) throws IOException {
     if (editStreams == null || editStreams.size() == 1) {
       throw new IOException("Checkpoint directories inaccessible.");
     }
@@ -557,7 +557,7 @@ class FSEditLog {
   /**
    * Return the size of the current EditLog
    */
-  long getEditLogSize() throws IOException {
+  synchronized long getEditLogSize() throws IOException {
     assert(getNumStorageDirs() == editStreams.size());
     long size = 0;
     for (int idx = 0; idx < getNumStorageDirs(); idx++) {
@@ -572,7 +572,7 @@ class FSEditLog {
   /**
    * Closes the current edit log and opens edits.new. 
    */
-  void rollEditLog() throws IOException {
+  synchronized void rollEditLog() throws IOException {
     //
     // If edits.new already exists, then return error.
     //
@@ -601,7 +601,7 @@ class FSEditLog {
    * Removes the old edit log and renamed edits.new as edits.
    * Reopens the edits file.
    */
-  void purgeEditLog() throws IOException {
+  synchronized void purgeEditLog() throws IOException {
     //
     // If edits.new does not exists, then return error.
     //
@@ -636,7 +636,7 @@ class FSEditLog {
   /**
    * Return the name of the edit file
    */
-  File getFsEditName() throws IOException {
+  synchronized File getFsEditName() throws IOException {
     return getEditFile(0);
   }
 }

+ 2 - 2
src/java/org/apache/hadoop/dfs/FSNamesystem.java

@@ -3352,12 +3352,12 @@ class FSNamesystem implements FSConstants {
       throw new SafeModeException("Checkpoint not created",
                                   safeMode);
     }
-    LOG.info("Roll Edit Log");
+    LOG.info("Roll Edit Log from " + Server.getRemoteAddress());
     getEditLog().rollEditLog();
   }
 
   synchronized void rollFSImage() throws IOException {
-    LOG.info("Roll FSImage");
+    LOG.info("Roll FSImage from " + Server.getRemoteAddress());
     if (isInSafeMode()) {
       throw new SafeModeException("Checkpoint not created",
                                   safeMode);