diff --git a/CHANGES.txt b/CHANGES.txt index 63f6b2b8299..633402b12fd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -83,6 +83,7 @@ Hbase Change Log HBASE-672 Sort regions in the regionserver UI HBASE-677 Make HTable, HRegion, HRegionServer, HStore, and HColumnDescriptor subclassable (Clint Morgan via Stack) + HBASE-682 Regularize toString NEW FEATURES HBASE-47 Option to set TTL for columns in hbase diff --git a/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java b/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java index 6a9237fa760..5e9b6241054 100644 --- a/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java +++ b/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java @@ -93,6 +93,17 @@ public class HColumnDescriptor implements WritableComparable { public static final BloomFilterDescriptor DEFAULT_BLOOM_FILTER_DESCRIPTOR = null; + // Defines for jruby/shell + public static final String NAME = "NAME"; + public static final String MAX_VERSIONS = "MAX_VERSIONS"; + public static final String COMPRESSION = "COMPRESSION"; + public static final String IN_MEMORY = "IN_MEMORY"; + public static final String BLOCKCACHE = "BLOCKCACHE"; + public static final String MAX_LENGTH = "MAX_LENGTH"; + public static final String TTL = "TTL"; + public static final String BLOOMFILTER = "BLOOMFILTER"; + public static final String FOREVER = "FOREVER"; + // Column family name private byte [] name; // Number of versions to keep @@ -289,16 +300,17 @@ public class HColumnDescriptor implements WritableComparable { /** {@inheritDoc} */ @Override public String toString() { - return "{name: " + Bytes.toString(name) + - ", max versions: " + maxVersions + - ", compression: " + this.compressionType + ", in memory: " + inMemory + - ", block cache enabled: " + blockCacheEnabled + - ", max length: " + maxValueLength + - ", time to live: " + + return "{" + NAME + " => '" + Bytes.toString(name) + + "', " + MAX_VERSIONS + " => " + maxVersions + + ", " + COMPRESSION + " => " + this.compressionType + + ", " + IN_MEMORY + " => " + inMemory + + ", " + BLOCKCACHE + " => " + blockCacheEnabled + + ", " + MAX_LENGTH + " => " + maxValueLength + + ", " + TTL + " => " + (timeToLive == HConstants.FOREVER ? "FOREVER" : Integer.toString(timeToLive)) + - ", bloom filter: " + - (bloomFilterSpecified ? bloomFilter.toString() : "none") + + ", " + BLOOMFILTER + " => " + + (bloomFilterSpecified ? bloomFilter.toString() : CompressionType.NONE) + "}"; } diff --git a/src/java/org/apache/hadoop/hbase/HTableDescriptor.java b/src/java/org/apache/hadoop/hbase/HTableDescriptor.java index 8a991cdcc1d..47b0b48fe33 100644 --- a/src/java/org/apache/hadoop/hbase/HTableDescriptor.java +++ b/src/java/org/apache/hadoop/hbase/HTableDescriptor.java @@ -59,6 +59,8 @@ public class HTableDescriptor implements WritableComparable { private byte [] name = HConstants.EMPTY_BYTE_ARRAY; private String nameAsString = ""; + public static final String FAMILIES = "FAMILIES"; + // Key is hash of the family name. private final Map families = new HashMap(); @@ -189,8 +191,8 @@ public class HTableDescriptor implements WritableComparable { */ @Override public String toString() { - return "name: " + Bytes.toString(this.name) + ", families: " + - this.families.values(); + return HColumnDescriptor.NAME + " => '" + Bytes.toString(this.name) + + "', " + FAMILIES + " => " + this.families.values(); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/hadoop/hbase/master/BaseScanner.java b/src/java/org/apache/hadoop/hbase/master/BaseScanner.java index 7d0a8127e2f..69623f8accc 100644 --- a/src/java/org/apache/hadoop/hbase/master/BaseScanner.java +++ b/src/java/org/apache/hadoop/hbase/master/BaseScanner.java @@ -172,9 +172,9 @@ abstract class BaseScanner extends Chore implements HConstants { String serverName = Writables.cellToString(values.get(COL_SERVER)); long startCode = Writables.cellToLong(values.get(COL_STARTCODE)); if (LOG.isDebugEnabled()) { - LOG.debug(Thread.currentThread().getName() + " regioninfo: {" + - info.toString() + "}, server: " + serverName + ", startCode: " + - startCode); + LOG.debug(Thread.currentThread().getName() + " {" + + info.toString() + "}, SERVER => '" + serverName + + "', STARTCODE => " + startCode); } // Note Region has been assigned. diff --git a/src/test/org/apache/hadoop/hbase/TestToString.java b/src/test/org/apache/hadoop/hbase/TestToString.java index 06e61886a7d..059da76f2b7 100644 --- a/src/test/org/apache/hadoop/hbase/TestToString.java +++ b/src/test/org/apache/hadoop/hbase/TestToString.java @@ -36,30 +36,4 @@ public class TestToString extends TestCase { assertEquals("HServerInfo", "address: " + hostport + ", startcode: -1" + ", load: (requests: 0 regions: 0)", info.toString()); } - - /** - * Test HTableDescriptor.toString(); - */ - public void testHTableDescriptor() { - HTableDescriptor htd = HTableDescriptor.ROOT_TABLEDESC; - System. out.println(htd.toString()); - assertEquals("Table descriptor", "name: -ROOT-, families: [{name: " + - "info, max versions: 1, compression: NONE, in memory: false, " + - "block cache enabled: false, max length: 2147483647, " + - "time to live: FOREVER, bloom filter: none}]", htd.toString()); - } - - /** - * Tests HRegionInfo.toString() - */ - public void testHRegionInfo() { - HRegionInfo hri = HRegionInfo.ROOT_REGIONINFO; - System.out.println(hri.toString()); - assertEquals("HRegionInfo", - "regionname: -ROOT-,,0, startKey: <>, endKey: <>, encodedName: 70236052, tableDesc: " + - "{name: -ROOT-, families: [{name: info, max versions: 1, " + - "compression: NONE, in memory: false, block cache enabled: false, " + - "max length: 2147483647, time to live: FOREVER, bloom filter: none}]}", - hri.toString()); - } }