From 927512443038fafb6728fbe12a7a558723822634 Mon Sep 17 00:00:00 2001 From: Nick Dimiduk Date: Thu, 13 Nov 2014 16:07:04 -0800 Subject: [PATCH] HBASE-12472 Improve debuggability of IntegrationTestBulkLoad --- .../hbase/mapreduce/IntegrationTestBulkLoad.java | 54 +++++++++++++++------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/mapreduce/IntegrationTestBulkLoad.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/mapreduce/IntegrationTestBulkLoad.java index 954ece2..e7d6435 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/mapreduce/IntegrationTestBulkLoad.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/mapreduce/IntegrationTestBulkLoad.java @@ -29,19 +29,14 @@ import java.util.Map; import java.util.Random; import java.util.Set; +import com.google.common.base.Joiner; import org.apache.commons.cli.CommandLine; import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.Cell; -import org.apache.hadoop.hbase.CellUtil; -import org.apache.hadoop.hbase.HBaseConfiguration; -import org.apache.hadoop.hbase.IntegrationTestBase; -import org.apache.hadoop.hbase.IntegrationTestingUtility; -import org.apache.hadoop.hbase.IntegrationTests; -import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.*; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; @@ -519,27 +514,50 @@ public class IntegrationTestBulkLoad extends IntegrationTestBase { protected void reduce(LinkKey key, Iterable values, Context context) throws java.io.IOException, java.lang.InterruptedException { long next = -1L; + long prev = -1L; long count = 0L; for (LinkChain lc : values) { if (next == -1) { - if (lc.getRk() != 0L) throw new RuntimeException("Chains should all start at 0 rk" - + ". Chain:" + key.chainId + ", order:" + key.order); + if (lc.getRk() != 0L) { + String msg = "Chains should all start at rk 0, but read rk " + lc.getRk() + + ". Chain:" + key.chainId + ", order:" + key.order; + logError(msg, context); + throw new RuntimeException(msg); + } next = lc.getNext(); } else { - if (next != lc.getRk()) - throw new RuntimeException("Missing a link in the chain. Expecting " + - next + " got " + lc.getRk() + ". Chain:" + key.chainId + ", order:" + key.order); + if (next != lc.getRk()) { + String msg = "Missing a link in the chain. Prev rk " + prev + " was, expecting " + + next + " but got " + lc.getRk() + ". Chain:" + key.chainId + + ", order:" + key.order; + logError(msg, context); + throw new RuntimeException(msg); + } + prev = lc.getRk(); next = lc.getNext(); } count++; } int expectedChainLen = context.getConfiguration().getInt(CHAIN_LENGTH_KEY, CHAIN_LENGTH); - if (count != expectedChainLen) - throw new RuntimeException("Chain wasn't the correct length. Expected " + - expectedChainLen + " got " + count + ". Chain:" + key.chainId + ", order:" + key.order); + if (count != expectedChainLen) { + String msg = "Chain wasn't the correct length. Expected " + expectedChainLen + " got " + + count + ". Chain:" + key.chainId + ", order:" + key.order; + logError(msg, context); + throw new RuntimeException(msg); + } + } + + private static void logError(String msg, Context context) throws IOException { + HBaseTestingUtility util = new HBaseTestingUtility(context.getConfiguration()); + TableName table = TableName.valueOf(getTableName(context.getConfiguration())); + + LOG.error("Failure in chain verification: " + msg); + LOG.error("cluster status:\n" + util.getHBaseClusterInterface().getClusterStatus()); + LOG.error("table regions:\n" + + Joiner.on("\n").join(util.getHBaseAdmin().getTableRegions(table))); } } @@ -641,7 +659,11 @@ public class IntegrationTestBulkLoad extends IntegrationTestBase { @Override public String getTablename() { - return getConf().get(TABLE_NAME_KEY, TABLE_NAME); + return getTableName(getConf()); + } + + public static String getTableName(Configuration conf) { + return conf.get(TABLE_NAME_KEY, TABLE_NAME); } @Override -- 1.9.3 (Apple Git-50)