diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java index b3c8b82aab9..8a1beee430b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java @@ -119,8 +119,14 @@ public class TableSplit implements InputSplit, Comparable { @Override public String toString() { - return m_regionLocation + ":" + - Bytes.toStringBinary(m_startRow) + "," + Bytes.toStringBinary(m_endRow); + StringBuilder sb = new StringBuilder(); + sb.append("HBase table split("); + sb.append("table name: ").append(m_tableName); + sb.append(", start row: ").append(Bytes.toStringBinary(m_startRow)); + sb.append(", end row: ").append(Bytes.toStringBinary(m_endRow)); + sb.append(", region location: ").append(m_regionLocation); + sb.append(")"); + return sb.toString(); } @Override diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSplit.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSplit.java index 5e3aeef7f1a..b43e870ed5d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSplit.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSplit.java @@ -314,8 +314,15 @@ implements Writable, Comparable { */ @Override public String toString() { - return regionLocation + ":" + - Bytes.toStringBinary(startRow) + "," + Bytes.toStringBinary(endRow); + StringBuilder sb = new StringBuilder(); + sb.append("HBase table split("); + sb.append("table name: ").append(tableName); + sb.append(", scan: ").append(scan); + sb.append(", start row: ").append(Bytes.toStringBinary(startRow)); + sb.append(", end row: ").append(Bytes.toStringBinary(endRow)); + sb.append(", region location: ").append(regionLocation); + sb.append(")"); + return sb.toString(); } /** diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java index 86f62723d85..d60a5e7edc2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestSplitTable.java @@ -23,7 +23,9 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import org.apache.hadoop.hbase.SmallTests; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.util.Bytes; +import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -88,4 +90,22 @@ public class TestSplitTable { assertEquals(tablesplit.hashCode(), same.hashCode()); assertEquals(tablesplit, same); } + + @Test + @SuppressWarnings("deprecation") + public void testToString() { + TableSplit split = + new TableSplit(TableName.valueOf("table"), "row-start".getBytes(), "row-end".getBytes(), + "location"); + String str = + "HBase table split(table name: table, start row: row-start, " + + "end row: row-end, region location: location)"; + Assert.assertEquals(str, split.toString()); + + split = new TableSplit((TableName) null, null, null, null); + str = + "HBase table split(table name: null, start row: null, " + + "end row: null, region location: null)"; + Assert.assertEquals(str, split.toString()); + } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java index 9daef9a0152..e40c5fcf4cc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSplit.java @@ -85,5 +85,21 @@ public class TestTableSplit { Assert.assertEquals(666, deserialized.getLength()); } + @Test + public void testToString() { + TableSplit split = + new TableSplit(TableName.valueOf("table"), "row-start".getBytes(), "row-end".getBytes(), + "location"); + String str = + "HBase table split(table name: table, scan: , start row: row-start, " + + "end row: row-end, region location: location)"; + Assert.assertEquals(str, split.toString()); + + split = new TableSplit((TableName) null, null, null, null); + str = + "HBase table split(table name: null, scan: , start row: null, " + + "end row: null, region location: null)"; + Assert.assertEquals(str, split.toString()); + } }