Author: dhruba Date: Fri Oct 5 10:37:36 2007 New Revision: 582356 URL: http://svn.apache.org/viewvc?rev=582356&view=rev Log: HADOOP-1997. TestCheckpoint closes the edits file after writing to it, otherwise the rename of this file on Windows fails. (Konstantin Shvachko via dhruba)
Modified: lucene/hadoop/trunk/CHANGES.txt lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSEditLog.java lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSImage.java lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/TestCheckpoint.java Modified: lucene/hadoop/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=582356&r1=582355&r2=582356&view=diff ============================================================================== --- lucene/hadoop/trunk/CHANGES.txt (original) +++ lucene/hadoop/trunk/CHANGES.txt Fri Oct 5 10:37:36 2007 @@ -381,6 +381,10 @@ HADOOP-1961. The -get option to dfs-shell works when a single filename is specified. (Raghu Angadi via dhruba) + HADOOP-1997. TestCheckpoint closes the edits file after writing to it, + otherwise the rename of this file on Windows fails. + (Konstantin Shvachko via dhruba) + Release 0.14.1 - 2007-09-04 BUG FIXES Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSEditLog.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSEditLog.java?rev=582356&r1=582355&r2=582356&view=diff ============================================================================== --- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSEditLog.java (original) +++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSEditLog.java Fri Oct 5 10:37:36 2007 @@ -161,7 +161,7 @@ * server to exit */ synchronized void processIOError(int index) throws IOException { - if (editStreams == null || editStreams.size() == 1) { + if (editStreams == null || editStreams.size() <= 1) { throw new IOException("Checkpoint directories inaccessible."); } assert(index < getNumStorageDirs()); @@ -630,7 +630,7 @@ // getEditFile(idx).delete(); if (!getEditNewFile(idx).renameTo(getEditFile(idx))) { - processIOError(idx); + fsimage.processIOError(idx); idx--; } } Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSImage.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSImage.java?rev=582356&r1=582355&r2=582356&view=diff ============================================================================== --- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSImage.java (original) +++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSImage.java Fri Oct 5 10:37:36 2007 @@ -446,7 +446,7 @@ void processIOError(int index) throws IOException { int nrDirs = getNumStorageDirs(); assert(index >= 0 && index < nrDirs); - if (nrDirs == 1) + if (nrDirs <= 1) throw new IOException("Checkpoint directories inaccessible."); storageDirs.remove(index); } Modified: lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/TestCheckpoint.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/TestCheckpoint.java?rev=582356&r1=582355&r2=582356&view=diff ============================================================================== --- lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/TestCheckpoint.java (original) +++ lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/TestCheckpoint.java Fri Oct 5 10:37:36 2007 @@ -173,8 +173,16 @@ assertFalse(image.getEditNewFile(idx).exists()); File edits = image.getEditFile(idx); assertTrue(edits.exists()); // edits should exist and be empty - assertTrue( - (new RandomAccessFile(edits, "r")).length() == Integer.SIZE/Byte.SIZE); + long editsLen = -1; + RandomAccessFile eF = null; + try { + eF = new RandomAccessFile(edits, "r"); + editsLen = eF.length(); + } finally { + if(eF != null) + eF.close(); + } + assertTrue(editsLen == Integer.SIZE/Byte.SIZE); } fileSys = cluster.getFileSystem();