You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by nk...@apache.org on 2012/09/10 11:47:03 UTC
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
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