Return-Path: Delivered-To: apmail-hadoop-core-commits-archive@www.apache.org Received: (qmail 40730 invoked from network); 27 Sep 2008 16:04:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Sep 2008 16:04:27 -0000 Received: (qmail 30738 invoked by uid 500); 27 Sep 2008 16:04:25 -0000 Delivered-To: apmail-hadoop-core-commits-archive@hadoop.apache.org Received: (qmail 30700 invoked by uid 500); 27 Sep 2008 16:04:25 -0000 Mailing-List: contact core-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-dev@hadoop.apache.org Delivered-To: mailing list core-commits@hadoop.apache.org Received: (qmail 30691 invoked by uid 99); 27 Sep 2008 16:04:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Sep 2008 09:04:25 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Sep 2008 16:03:32 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BEA2E2388892; Sat, 27 Sep 2008 09:04:05 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r699677 - in /hadoop/core/branches/branch-0.19: CHANGES.txt src/hdfs/org/apache/hadoop/hdfs/server/datanode/FSDataset.java src/test/org/apache/hadoop/hdfs/TestFileCreation.java Date: Sat, 27 Sep 2008 16:04:05 -0000 To: core-commits@hadoop.apache.org From: szetszwo@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080927160405.BEA2E2388892@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: szetszwo Date: Sat Sep 27 09:04:05 2008 New Revision: 699677 URL: http://svn.apache.org/viewvc?rev=699677&view=rev Log: HADOOP-3614. Fix a bug that Datanode may use an old GenerationStamp to get meta file. (szetszwo) Modified: hadoop/core/branches/branch-0.19/CHANGES.txt hadoop/core/branches/branch-0.19/src/hdfs/org/apache/hadoop/hdfs/server/datanode/FSDataset.java hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/TestFileCreation.java Modified: hadoop/core/branches/branch-0.19/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/CHANGES.txt?rev=699677&r1=699676&r2=699677&view=diff ============================================================================== --- hadoop/core/branches/branch-0.19/CHANGES.txt (original) +++ hadoop/core/branches/branch-0.19/CHANGES.txt Sat Sep 27 09:04:05 2008 @@ -761,6 +761,9 @@ HADOOP-4116. Balancer should provide better resource management. (hairong) + HADOOP-3614. Fix a bug that Datanode may use an old GenerationStamp to get + meta file. (szetszwo) + Release 0.18.1 - 2008-09-17 IMPROVEMENTS Modified: hadoop/core/branches/branch-0.19/src/hdfs/org/apache/hadoop/hdfs/server/datanode/FSDataset.java URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/src/hdfs/org/apache/hadoop/hdfs/server/datanode/FSDataset.java?rev=699677&r1=699676&r2=699677&view=diff ============================================================================== --- hadoop/core/branches/branch-0.19/src/hdfs/org/apache/hadoop/hdfs/server/datanode/FSDataset.java (original) +++ hadoop/core/branches/branch-0.19/src/hdfs/org/apache/hadoop/hdfs/server/datanode/FSDataset.java Sat Sep 27 09:04:05 2008 @@ -621,9 +621,9 @@ } } - public File findBlockFile(Block b) { - assert b.getGenerationStamp() == GenerationStamp.WILDCARD_STAMP; - + /** Return the block file for the given ID */ + public File findBlockFile(long blockId) { + final Block b = new Block(blockId); File blockfile = null; ActiveFile activefile = ongoingCreates.get(b); if (activefile != null) { @@ -643,15 +643,13 @@ /** {@inheritDoc} */ public synchronized Block getStoredBlock(long blkid) throws IOException { - Block b = new Block(blkid); - File blockfile = findBlockFile(b); + File blockfile = findBlockFile(blkid); if (blockfile == null) { return null; } File metafile = findMetaFile(blockfile); - b.setGenerationStamp(parseGenerationStamp(blockfile, metafile)); - b.setNumBytes(blockfile.length()); - return b; + return new Block(blkid, blockfile.length(), + parseGenerationStamp(blockfile, metafile)); } public boolean metaFileExists(Block b) throws IOException { @@ -830,14 +828,13 @@ throw new IOException("Cannot update oldblock (=" + oldblock + ") to newblock (=" + newblock + ")."); } - - File blockFile = findBlockFile(oldblock); + File blockFile = findBlockFile(oldblock.getBlockId()); if (blockFile == null) { throw new IOException("Block " + oldblock + " does not exist."); } interruptOngoingCreates(oldblock); - File oldMetaFile = getMetaFile(blockFile, oldblock); + File oldMetaFile = findMetaFile(blockFile); long oldgs = parseGenerationStamp(blockFile, oldMetaFile); //rename meta file to a tmp file Modified: hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/TestFileCreation.java URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/TestFileCreation.java?rev=699677&r1=699676&r2=699677&view=diff ============================================================================== --- hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/TestFileCreation.java (original) +++ hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/hdfs/TestFileCreation.java Sat Sep 27 09:04:05 2008 @@ -17,11 +17,20 @@ */ package org.apache.hadoop.hdfs; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; import java.net.InetSocketAddress; +import org.apache.commons.logging.impl.Log4JLogger; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.*; +import org.apache.hadoop.fs.BlockLocation; +import org.apache.hadoop.fs.FSDataInputStream; +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.protocol.Block; import org.apache.hadoop.hdfs.protocol.DatanodeInfo; import org.apache.hadoop.hdfs.protocol.FSConstants; @@ -33,8 +42,6 @@ import org.apache.hadoop.hdfs.server.namenode.FSNamesystem; import org.apache.hadoop.hdfs.server.namenode.LeaseManager; import org.apache.hadoop.io.IOUtils; - -import org.apache.commons.logging.impl.Log4JLogger; import org.apache.log4j.Level; @@ -690,7 +697,7 @@ DataNode datanode = cluster.getDataNode(datanodeinfo.ipcPort); FSDataset dataset = (FSDataset)datanode.data; Block b = dataset.getStoredBlock(locatedblock.getBlock().getBlockId()); - File blockfile = dataset.findBlockFile(b); + File blockfile = dataset.findBlockFile(b.getBlockId()); System.out.println("blockfile=" + blockfile); if (blockfile != null) { BufferedReader in = new BufferedReader(new FileReader(blockfile));