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 36A2C952C for ; Sat, 18 Feb 2012 01:13:26 +0000 (UTC) Received: (qmail 89402 invoked by uid 500); 18 Feb 2012 01:13:26 -0000 Delivered-To: apmail-hadoop-hdfs-commits-archive@hadoop.apache.org Received: (qmail 89359 invoked by uid 500); 18 Feb 2012 01:13:26 -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 89350 invoked by uid 99); 18 Feb 2012 01:13:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Feb 2012 01:13:26 +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, 18 Feb 2012 01:13:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F0E3323889C5; Sat, 18 Feb 2012 01:13:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1245829 - in /hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt src/main/java/org/apache/hadoop/hdfs/protocol/ExtendedBlock.java src/test/java/org/apache/hadoop/hdfs/protocol/TestExtendedBlock.java Date: Sat, 18 Feb 2012 01:13:04 -0000 To: hdfs-commits@hadoop.apache.org From: todd@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120218011304.F0E3323889C5@eris.apache.org> Author: todd Date: Sat Feb 18 01:13:04 2012 New Revision: 1245829 URL: http://svn.apache.org/viewvc?rev=1245829&view=rev Log: HDFS-2969. ExtendedBlock.equals is incorrectly implemented. Contributed by Todd Lipcon. Added: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestExtendedBlock.java Modified: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/ExtendedBlock.java Modified: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1245829&r1=1245828&r2=1245829&view=diff ============================================================================== --- hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Sat Feb 18 01:13:04 2012 @@ -47,6 +47,8 @@ Release 0.23.2 - UNRELEASED HDFS-2938. Recursive delete of a large directory make namenode unresponsive. (Hari Mankude via suresh) + HDFS-2969. ExtendedBlock.equals is incorrectly implemented (todd) + Release 0.23.1 - 2012-02-08 INCOMPATIBLE CHANGES Modified: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/ExtendedBlock.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/ExtendedBlock.java?rev=1245829&r1=1245828&r2=1245829&view=diff ============================================================================== --- hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/ExtendedBlock.java (original) +++ hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/ExtendedBlock.java Sat Feb 18 01:13:04 2012 @@ -145,7 +145,7 @@ public class ExtendedBlock implements Wr return false; } ExtendedBlock b = (ExtendedBlock)o; - return b.block.equals(block) || b.poolId.equals(poolId); + return b.block.equals(block) && b.poolId.equals(poolId); } @Override // Object Added: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestExtendedBlock.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestExtendedBlock.java?rev=1245829&view=auto ============================================================================== --- hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestExtendedBlock.java (added) +++ hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestExtendedBlock.java Sat Feb 18 01:13:04 2012 @@ -0,0 +1,56 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hdfs.protocol; + +import static org.junit.Assert.*; + +import org.junit.Test; + + +public class TestExtendedBlock { + static final String POOL_A = "blockpool-a"; + static final String POOL_B = "blockpool-b"; + static final Block BLOCK_1_GS1 = new Block(1L, 100L, 1L); + static final Block BLOCK_1_GS2 = new Block(1L, 100L, 2L); + static final Block BLOCK_2_GS1 = new Block(2L, 100L, 1L); + + @Test + public void testEquals() { + // Same block -> equal + assertEquals( + new ExtendedBlock(POOL_A, BLOCK_1_GS1), + new ExtendedBlock(POOL_A, BLOCK_1_GS1)); + // Different pools, same block id -> not equal + assertNotEquals( + new ExtendedBlock(POOL_A, BLOCK_1_GS1), + new ExtendedBlock(POOL_B, BLOCK_1_GS1)); + // Same pool, different block id -> not equal + assertNotEquals( + new ExtendedBlock(POOL_A, BLOCK_1_GS1), + new ExtendedBlock(POOL_A, BLOCK_2_GS1)); + // Same block, different genstamps -> equal + assertEquals( + new ExtendedBlock(POOL_A, BLOCK_1_GS1), + new ExtendedBlock(POOL_A, BLOCK_1_GS2)); + } + + private static void assertNotEquals(Object a, Object b) { + assertFalse("expected not equal: '" + a + "' and '" + b + "'", + a.equals(b)); + } +}