Return-Path: X-Original-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6EF778CD6 for ; Sat, 17 Sep 2011 10:54:15 +0000 (UTC) Received: (qmail 54203 invoked by uid 500); 17 Sep 2011 10:54:15 -0000 Delivered-To: apmail-hadoop-hdfs-commits-archive@hadoop.apache.org Received: (qmail 54150 invoked by uid 500); 17 Sep 2011 10:54:14 -0000 Mailing-List: contact hdfs-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hdfs-dev@hadoop.apache.org Delivered-To: mailing list hdfs-commits@hadoop.apache.org Received: (qmail 54136 invoked by uid 99); 17 Sep 2011 10:54:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Sep 2011 10:54:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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, 17 Sep 2011 10:54:08 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id EC28823888E4; Sat, 17 Sep 2011 10:53:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1171945 - in /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: ./ src/main/java/org/apache/hadoop/hdfs/protocol/ src/main/java/org/apache/hadoop/hdfs/server/namenode/ src/main/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/ src/m... Date: Sat, 17 Sep 2011 10:53:45 -0000 To: hdfs-commits@hadoop.apache.org From: szetszwo@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20110917105345.EC28823888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: szetszwo Date: Sat Sep 17 10:53:44 2011 New Revision: 1171945 URL: http://svn.apache.org/viewvc?rev=1171945&view=rev Log: HDFS-362. FSEditLog should not writes long and short as UTF8, and should not use ArrayWritable for writing non-array items. Contributed by Uma Maheswara Rao G Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LayoutVersion.java hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageSerialization.java hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/EditsLoaderCurrent.java hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/ImageLoaderCurrent.java hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSEditLogLoader.java hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestHDFSConcat.java Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1171945&r1=1171944&r2=1171945&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Sat Sep 17 10:53:44 2011 @@ -49,6 +49,10 @@ Trunk (unreleased changes) HDFS-2333. Change DFSOutputStream back to package private, otherwise, there are two SC_START_IN_CTOR findbugs warnings. (szetszwo) + HDFS-362. FSEditLog should not writes long and short as UTF8, and should + not use ArrayWritable for writing non-array items. (Uma Maheswara Rao G + via szetszwo) + Release 0.23.0 - Unreleased INCOMPATIBLE CHANGES Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LayoutVersion.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LayoutVersion.java?rev=1171945&r1=1171944&r2=1171945&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LayoutVersion.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/LayoutVersion.java Sat Sep 17 10:53:44 2011 @@ -80,7 +80,9 @@ public class LayoutVersion { FEDERATION(-35, "Support for namenode federation"), LEASE_REASSIGNMENT(-36, "Support for persisting lease holder reassignment"), STORED_TXIDS(-37, "Transaction IDs are stored in edits log and image files"), - TXID_BASED_LAYOUT(-38, "File names in NN Storage are based on transaction IDs"); + TXID_BASED_LAYOUT(-38, "File names in NN Storage are based on transaction IDs"), + EDITLOG_OP_OPTIMIZATION(-39, + "Use LongWritable and ShortWritable directly instead of ArrayWritable of UTF8"); final int lv; final int ancestorLV; Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java?rev=1171945&r1=1171944&r2=1171945&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java Sat Sep 17 10:53:44 2011 @@ -30,19 +30,16 @@ import org.apache.hadoop.fs.permission.F import org.apache.hadoop.fs.permission.PermissionStatus; import org.apache.hadoop.hdfs.protocol.Block; import org.apache.hadoop.hdfs.protocol.DatanodeID; -import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.LayoutVersion; import org.apache.hadoop.hdfs.protocol.LayoutVersion.Feature; import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor; import org.apache.hadoop.hdfs.server.common.GenerationStamp; -import org.apache.hadoop.hdfs.server.common.Storage; import org.apache.hadoop.util.PureJavaCrc32; import static org.apache.hadoop.hdfs.server.namenode.FSEditLogOpCodes.*; import org.apache.hadoop.security.token.delegation.DelegationKey; import org.apache.hadoop.io.BytesWritable; import org.apache.hadoop.io.DataOutputBuffer; -import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.ArrayWritable; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableFactories; @@ -192,19 +189,17 @@ public abstract class FSEditLogOp { @Override void writeFields(DataOutputStream out) throws IOException { - DeprecatedUTF8 nameReplicationPair[] = new DeprecatedUTF8[] { - new DeprecatedUTF8(path), - toLogReplication(replication), - toLogLong(mtime), - toLogLong(atime), - toLogLong(blockSize)}; - new ArrayWritable(DeprecatedUTF8.class, nameReplicationPair).write(out); + FSImageSerialization.writeString(path, out); + FSImageSerialization.writeShort(replication, out); + FSImageSerialization.writeLong(mtime, out); + FSImageSerialization.writeLong(atime, out); + FSImageSerialization.writeLong(blockSize, out); new ArrayWritable(Block.class, blocks).write(out); permissions.write(out); if (this.opCode == OP_ADD) { - new DeprecatedUTF8(clientName).write(out); - new DeprecatedUTF8(clientMachine).write(out); + FSImageSerialization.writeString(clientName,out); + FSImageSerialization.writeString(clientMachine,out); } } @@ -213,25 +208,43 @@ public abstract class FSEditLogOp { throws IOException { // versions > 0 support per file replication // get name and replication - this.length = in.readInt(); + if (!LayoutVersion.supports(Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) { + this.length = in.readInt(); + } if (-7 == logVersion && length != 3|| -17 < logVersion && logVersion < -7 && length != 4 || - logVersion <= -17 && length != 5) { + (logVersion <= -17 && length != 5 && !LayoutVersion.supports( + Feature.EDITLOG_OP_OPTIMIZATION, logVersion))) { throw new IOException("Incorrect data format." + " logVersion is " + logVersion + " but writables.length is " + length + ". "); } this.path = FSImageSerialization.readString(in); - this.replication = readShort(in); - this.mtime = readLong(in); + + if (LayoutVersion.supports(Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) { + this.replication = FSImageSerialization.readShort(in); + this.mtime = FSImageSerialization.readLong(in); + } else { + this.replication = readShort(in); + this.mtime = readLong(in); + } + if (LayoutVersion.supports(Feature.FILE_ACCESS_TIME, logVersion)) { - this.atime = readLong(in); + if (LayoutVersion.supports(Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) { + this.atime = FSImageSerialization.readLong(in); + } else { + this.atime = readLong(in); + } } else { this.atime = 0; } if (logVersion < -7) { - this.blockSize = readLong(in); + if (LayoutVersion.supports(Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) { + this.blockSize = FSImageSerialization.readLong(in); + } else { + this.blockSize = readLong(in); + } } else { this.blockSize = 0; } @@ -335,15 +348,19 @@ public abstract class FSEditLogOp { @Override void writeFields(DataOutputStream out) throws IOException { - new DeprecatedUTF8(path).write(out); - new DeprecatedUTF8(Short.toString(replication)).write(out); + FSImageSerialization.writeString(path, out); + FSImageSerialization.writeShort(replication, out); } @Override void readFields(DataInputStream in, int logVersion) throws IOException { this.path = FSImageSerialization.readString(in); - this.replication = readShort(in); + if (LayoutVersion.supports(Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) { + this.replication = FSImageSerialization.readShort(in); + } else { + this.replication = readShort(in); + } } } @@ -379,32 +396,45 @@ public abstract class FSEditLogOp { @Override void writeFields(DataOutputStream out) throws IOException { - int size = 1 + srcs.length + 1; // trg, srcs, timestamp - DeprecatedUTF8 info[] = new DeprecatedUTF8[size]; + FSImageSerialization.writeString(trg, out); + + DeprecatedUTF8 info[] = new DeprecatedUTF8[srcs.length]; int idx = 0; - info[idx++] = new DeprecatedUTF8(trg); for(int i=0; i