hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhr...@apache.org
Subject svn commit: r587957 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/Storage.java
Date Wed, 24 Oct 2007 18:39:26 GMT
Author: dhruba
Date: Wed Oct 24 11:39:26 2007
New Revision: 587957

URL: http://svn.apache.org/viewvc?rev=587957&view=rev
Log:
HADOOP-2073.  Change size of VERSION file after writing contents to it.
(Konstantin Shvachko via dhruba)


Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/Storage.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=587957&r1=587956&r2=587957&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Wed Oct 24 11:39:26 2007
@@ -341,6 +341,9 @@
     HADOOP-2048.  Change error handling in distcp so that each map copies
     as much as possible before reporting the error. Also report progress on
     every copy. (Chris Douglas via omalley)
+
+    HADOOP-2073.  Change size of VERSION file after writing contents to it.
+    (Konstantin Shvachko via dhruba)
  
   IMPROVEMENTS
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/Storage.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/Storage.java?rev=587957&r1=587956&r2=587957&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/Storage.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/Storage.java Wed Oct 24 11:39:26 2007
@@ -170,10 +170,22 @@
       RandomAccessFile file = new RandomAccessFile(to, "rws");
       FileOutputStream out = null;
       try {
-        file.setLength(0);
         file.seek(0);
         out = new FileOutputStream(file.getFD());
+        /*
+         * If server is interrupted before this line, 
+         * the version file will remain unchanged.
+         */
         props.store(out, null);
+        /*
+         * Now the new fields are flushed to the head of the file, but file 
+         * length can still be larger then required and therefore the file can 
+         * contain whole or corrupted fields from its old contents in the end.
+         * If server is interrupted here and restarted later these extra fields
+         * either should not effect server behavior or should be handled
+         * by the server correctly.
+         */
+        file.setLength(out.getChannel().position());
       } finally {
         if (out != null) {
           out.close();



Mime
View raw message