Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1A08DD429 for ; Mon, 10 Sep 2012 09:47:55 +0000 (UTC) Received: (qmail 16936 invoked by uid 500); 10 Sep 2012 09:47:55 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 16577 invoked by uid 500); 10 Sep 2012 09:47:48 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 16540 invoked by uid 99); 10 Sep 2012 09:47:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2012 09:47:47 +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; Mon, 10 Sep 2012 09:47:46 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2407F23888FE for ; Mon, 10 Sep 2012 09:47:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1382723 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/fs/HFileSystem.java test/java/org/apache/hadoop/hbase/fs/TestBlockReorder.java Date: Mon, 10 Sep 2012 09:47:03 -0000 To: commits@hbase.apache.org From: nkeywal@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120910094703.2407F23888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: nkeywal Date: Mon Sep 10 09:47:02 2012 New Revision: 1382723 URL: http://svn.apache.org/viewvc?rev=1382723&view=rev Log: HBASE-6746 Impacts of HBASE-6435 vs. HDFS 2.0 trunk Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/fs/TestBlockReorder.java Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java?rev=1382723&r1=1382722&r2=1382723&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java Mon Sep 10 09:47:02 2012 @@ -262,7 +262,8 @@ public class HFileSystem extends FilterF Object[] args) throws Throwable { try { Object res = method.invoke(cp, args); - if (res != null && args.length == 3 && "getBlockLocations".equals(method.getName()) + if (res != null && args != null && args.length == 3 + && "getBlockLocations".equals(method.getName()) && res instanceof LocatedBlocks && args[0] instanceof String && args[0] != null) { Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/fs/TestBlockReorder.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/fs/TestBlockReorder.java?rev=1382723&r1=1382722&r2=1382723&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/fs/TestBlockReorder.java (original) +++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/fs/TestBlockReorder.java Mon Sep 10 09:47:02 2012 @@ -371,88 +371,42 @@ public class TestBlockReorder { fop.writeDouble(toWrite); fop.close(); - - // The interceptor is not set in this test, so we get the raw list at this point - LocatedBlocks l; - final long max = System.currentTimeMillis() + 10000; - do { - l = getNamenode(dfs.getClient()).getBlockLocations(fileName, 0, 1); - Assert.assertNotNull(l.getLocatedBlocks()); - Assert.assertEquals(l.getLocatedBlocks().size(), 1); - Assert.assertTrue("Expecting " + repCount + " , got " + l.get(0).getLocations().length, - System.currentTimeMillis() < max); - } while (l.get(0).getLocations().length != repCount); - - - // Let's fix our own order - setOurOrder(l); - - HFileSystem.ReorderWALBlocks lrb = new HFileSystem.ReorderWALBlocks(); - // Should be filtered, the name is different - lrb.reorderBlocks(conf, l, fileName); - checkOurOrder(l); - - // Should be reordered, as we pretend to be a file name with a compliant stuff - Assert.assertNotNull(conf.get(HConstants.HBASE_DIR)); - Assert.assertFalse(conf.get(HConstants.HBASE_DIR).isEmpty()); - String pseudoLogFile = conf.get(HConstants.HBASE_DIR) + "/" + - HConstants.HREGION_LOGDIR_NAME + "/" + host1 + ",6977,6576" + "/mylogfile"; - - // Check that it will be possible to extract a ServerName from our construction - Assert.assertNotNull("log= " + pseudoLogFile, - HLog.getServerNameFromHLogDirectoryName(dfs.getConf(), pseudoLogFile)); - - // And check we're doing the right reorder. - lrb.reorderBlocks(conf, l, pseudoLogFile); - checkOurFixedOrder(l); - - // And change again and check again - l.get(0).getLocations()[0].setHostName(host2); - l.get(0).getLocations()[1].setHostName(host1); - l.get(0).getLocations()[2].setHostName(host3); - lrb.reorderBlocks(conf, l, pseudoLogFile); - checkOurFixedOrder(l); - - // And change again and check again - l.get(0).getLocations()[0].setHostName(host2); - l.get(0).getLocations()[1].setHostName(host1); - l.get(0).getLocations()[2].setHostName(host3); - lrb.reorderBlocks(conf, l, pseudoLogFile); - checkOurFixedOrder(l); - - // nothing to do here, but let's check - l.get(0).getLocations()[0].setHostName(host2); - l.get(0).getLocations()[1].setHostName(host3); - l.get(0).getLocations()[2].setHostName(host1); - lrb.reorderBlocks(conf, l, pseudoLogFile); - checkOurFixedOrder(l); - - // nothing to do here, check again - l.get(0).getLocations()[0].setHostName(host2); - l.get(0).getLocations()[1].setHostName(host3); - l.get(0).getLocations()[2].setHostName("nothing"); - lrb.reorderBlocks(conf, l, pseudoLogFile); - Assert.assertEquals(host2, l.get(0).getLocations()[0].getHostName()); - Assert.assertEquals(host3, l.get(0).getLocations()[1].getHostName()); - Assert.assertEquals("nothing", l.get(0).getLocations()[2].getHostName()); - } - - private void setOurOrder(LocatedBlocks l) { - l.get(0).getLocations()[0].setHostName(host1); - l.get(0).getLocations()[1].setHostName(host2); - l.get(0).getLocations()[2].setHostName(host3); - } - - private void checkOurOrder(LocatedBlocks l) { - Assert.assertEquals(host1, l.get(0).getLocations()[0].getHostName()); - Assert.assertEquals(host2, l.get(0).getLocations()[1].getHostName()); - Assert.assertEquals(host3, l.get(0).getLocations()[2].getHostName()); - } - - private void checkOurFixedOrder(LocatedBlocks l) { - Assert.assertEquals(host2, l.get(0).getLocations()[0].getHostName()); - Assert.assertEquals(host3, l.get(0).getLocations()[1].getHostName()); - Assert.assertEquals(host1, l.get(0).getLocations()[2].getHostName()); + for (int i=0; i<10; i++){ + // The interceptor is not set in this test, so we get the raw list at this point + LocatedBlocks l; + final long max = System.currentTimeMillis() + 10000; + do { + l = getNamenode(dfs.getClient()).getBlockLocations(fileName, 0, 1); + Assert.assertNotNull(l.getLocatedBlocks()); + Assert.assertEquals(l.getLocatedBlocks().size(), 1); + Assert.assertTrue("Expecting " + repCount + " , got " + l.get(0).getLocations().length, + System.currentTimeMillis() < max); + } while (l.get(0).getLocations().length != repCount); + + // Should be filtered, the name is different => The order won't change + Object originalList[] = l.getLocatedBlocks().toArray(); + HFileSystem.ReorderWALBlocks lrb = new HFileSystem.ReorderWALBlocks(); + lrb.reorderBlocks(conf, l, fileName); + Assert.assertArrayEquals(originalList, l.getLocatedBlocks().toArray()); + + // Should be reordered, as we pretend to be a file name with a compliant stuff + Assert.assertNotNull(conf.get(HConstants.HBASE_DIR)); + Assert.assertFalse(conf.get(HConstants.HBASE_DIR).isEmpty()); + String pseudoLogFile = conf.get(HConstants.HBASE_DIR) + "/" + + HConstants.HREGION_LOGDIR_NAME + "/" + host1 + ",6977,6576" + "/mylogfile"; + + // Check that it will be possible to extract a ServerName from our construction + Assert.assertNotNull("log= " + pseudoLogFile, + HLog.getServerNameFromHLogDirectoryName(dfs.getConf(), pseudoLogFile)); + + // And check we're doing the right reorder. + lrb.reorderBlocks(conf, l, pseudoLogFile); + Assert.assertEquals(host1, l.get(0).getLocations()[2].getHostName()); + + // Check again, it should remain the same. + lrb.reorderBlocks(conf, l, pseudoLogFile); + Assert.assertEquals(host1, l.get(0).getLocations()[2].getHostName()); + } } @org.junit.Rule