Browse Source

HADOOP-2349. Improve code layout in file system transaction logging code.
(Tsz Wo (Nicholas), SZE via dhruba)



git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@601476 13f79535-47bb-0310-9956-ffa450edef68

Dhruba Borthakur 17 năm trước cách đây
mục cha
commit
d04e841f7c
2 tập tin đã thay đổi với 9 bổ sung9 xóa
  1. 3 0
      CHANGES.txt
  2. 6 9
      src/java/org/apache/hadoop/dfs/FSEditLog.java

+ 3 - 0
CHANGES.txt

@@ -195,6 +195,9 @@ Trunk (unreleased changes)
     would be ignored even if it was set in hadoop-site.xml.
     (Amareshwari Sri Ramadasu via ddas)
 
+    HADOOP-2349.  Improve code layout in file system transaction logging code.
+    (Tsz Wo (Nicholas), SZE via dhruba)
+
 Branch 0.15 (unreleased)
 
   BUG FIXES

+ 6 - 9
src/java/org/apache/hadoop/dfs/FSEditLog.java

@@ -603,7 +603,7 @@ class FSEditLog {
    * Write an operation to the edit log. Do not sync to persistent
    * store yet.
    */
-  synchronized void logEdit(byte op, Writable w1, Writable w2) {
+  synchronized void logEdit(byte op, Writable ... writables) {
     assert this.getNumEditStreams() > 0 : "no editlog streams";
     long start = FSNamesystem.now();
     for (int idx = 0; idx < editStreams.size(); idx++) {
@@ -611,11 +611,8 @@ class FSEditLog {
       try {
         DataOutputStream od = eStream.getOutputStream();
         od.write(op);
-        if (w1 != null) {
-          w1.write(od);
-        }
-        if (w2 != null) {
-          w2.write(od);
+        for(Writable w : writables) {
+          w.write(od);
         }
       } catch (IOException ie) {
         try {
@@ -763,7 +760,7 @@ class FSEditLog {
       new UTF8(path),
       FSEditLog.toLogLong(newNode.getModificationTime())
     };
-    logEdit(OP_MKDIR, new ArrayWritable(UTF8.class, info), null);
+    logEdit(OP_MKDIR, new ArrayWritable(UTF8.class, info));
   }
   
   /** 
@@ -775,7 +772,7 @@ class FSEditLog {
       new UTF8(src),
       new UTF8(dst),
       FSEditLog.toLogLong(timestamp)};
-    logEdit(OP_RENAME, new ArrayWritable(UTF8.class, info), null);
+    logEdit(OP_RENAME, new ArrayWritable(UTF8.class, info));
   }
   
   /** 
@@ -794,7 +791,7 @@ class FSEditLog {
     UTF8 info[] = new UTF8[] { 
       new UTF8(src),
       FSEditLog.toLogLong(timestamp)};
-    logEdit(OP_DELETE, new ArrayWritable(UTF8.class, info), null);
+    logEdit(OP_DELETE, new ArrayWritable(UTF8.class, info));
   }
   
   static UTF8 toLogReplication(short replication) {