Author: dhruba Date: Wed Oct 24 11:41:28 2007 New Revision: 587959 URL: http://svn.apache.org/viewvc?rev=587959&view=rev Log: HADOOP-2073. Change size of VERSION file after writing contents to it. (Konstantin Shvachko via dhruba) svn merge -c 587957 from trunk
Modified: lucene/hadoop/branches/branch-0.15/CHANGES.txt lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/dfs/Storage.java Modified: lucene/hadoop/branches/branch-0.15/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/hadoop/branches/branch-0.15/CHANGES.txt?rev=587959&r1=587958&r2=587959&view=diff ============================================================================== --- lucene/hadoop/branches/branch-0.15/CHANGES.txt (original) +++ lucene/hadoop/branches/branch-0.15/CHANGES.txt Wed Oct 24 11:41:28 2007 @@ -325,6 +325,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/branches/branch-0.15/src/java/org/apache/hadoop/dfs/Storage.java URL: http://svn.apache.org/viewvc/lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/dfs/Storage.java?rev=587959&r1=587958&r2=587959&view=diff ============================================================================== --- lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/dfs/Storage.java (original) +++ lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/dfs/Storage.java Wed Oct 24 11:41:28 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();