From 1a7c2fc882d311855517d8b25132f0600c30e716 Mon Sep 17 00:00:00 2001 From: Jim Kellerman Date: Wed, 4 Jun 2008 19:24:40 +0000 Subject: [PATCH] HBASE-666 UnmodifyableHRegionInfo gives the wrong encoded name git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@663350 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + .../org/apache/hadoop/hbase/HRegionInfo.java | 20 +++++++++- .../hbase/client/UnmodifyableHRegionInfo.java | 39 +------------------ .../client/UnmodifyableHTableDescriptor.java | 32 --------------- 4 files changed, 22 insertions(+), 70 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d83d7241661..8ae4a14db10 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -39,6 +39,7 @@ Hbase Change Log HBASE-655 Need programmatic way to add column family: need programmatic way to enable/disable table HBASE-654 API HTable.getMetadata().addFamily shouldn't be exposed to user + HBASE-666 UnmodifyableHRegionInfo gives the wrong encoded name IMPROVEMENTS HBASE-559 MR example job to count table rows diff --git a/src/java/org/apache/hadoop/hbase/HRegionInfo.java b/src/java/org/apache/hadoop/hbase/HRegionInfo.java index e647f15f95e..0a89c28d0b7 100644 --- a/src/java/org/apache/hadoop/hbase/HRegionInfo.java +++ b/src/java/org/apache/hadoop/hbase/HRegionInfo.java @@ -82,7 +82,7 @@ public class HRegionInfo implements WritableComparable { private String regionNameStr = ""; private boolean split = false; private byte [] startKey = HConstants.EMPTY_BYTE_ARRAY; - private HTableDescriptor tableDesc = null; + protected HTableDescriptor tableDesc = null; private int hashCode = -1; public static final int NO_HASH = -1; private volatile int encodedName = NO_HASH; @@ -156,6 +156,24 @@ public class HRegionInfo implements WritableComparable { setHashCode(); } + /** + * Costruct a copy of another HRegionInfo + * + * @param other + */ + public HRegionInfo(HRegionInfo other) { + this.endKey = other.getEndKey(); + this.offLine = other.isOffline(); + this.regionId = other.getRegionId(); + this.regionName = other.getRegionName(); + this.regionNameStr = Bytes.toString(this.regionName); + this.split = other.isSplit(); + this.startKey = other.getStartKey(); + this.tableDesc = other.getTableDesc(); + this.hashCode = other.hashCode(); + this.encodedName = other.getEncodedName(); + } + private static byte [] createRegionName(final byte [] tableName, final byte [] startKey, final long regionid) { return createRegionName(tableName, startKey, Long.toString(regionid)); diff --git a/src/java/org/apache/hadoop/hbase/client/UnmodifyableHRegionInfo.java b/src/java/org/apache/hadoop/hbase/client/UnmodifyableHRegionInfo.java index c443c8ac8fe..c05d9d59dad 100644 --- a/src/java/org/apache/hadoop/hbase/client/UnmodifyableHRegionInfo.java +++ b/src/java/org/apache/hadoop/hbase/client/UnmodifyableHRegionInfo.java @@ -24,49 +24,14 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; class UnmodifyableHRegionInfo extends HRegionInfo { - /* Default constructor - creates empty object */ - UnmodifyableHRegionInfo() { - super(new UnmodifyableHTableDescriptor(), null, null); - } - - /* - * Construct HRegionInfo with explicit parameters - * - * @param tableDesc the table descriptor - * @param startKey first key in region - * @param endKey end of key range - * @throws IllegalArgumentException - */ - UnmodifyableHRegionInfo(final HTableDescriptor tableDesc, - final byte [] startKey, final byte [] endKey) - throws IllegalArgumentException { - super(new UnmodifyableHTableDescriptor(tableDesc), startKey, endKey, false); - } - - /* - * Construct HRegionInfo with explicit parameters - * - * @param tableDesc the table descriptor - * @param startKey first key in region - * @param endKey end of key range - * @param split true if this region has split and we have daughter regions - * regions that may or may not hold references to this region. - * @throws IllegalArgumentException - */ - UnmodifyableHRegionInfo(HTableDescriptor tableDesc, - final byte [] startKey, final byte [] endKey, final boolean split) - throws IllegalArgumentException { - super(new UnmodifyableHTableDescriptor(tableDesc), startKey, endKey, split); - } - /* * Creates an unmodifyable copy of an HRegionInfo * * @param info */ UnmodifyableHRegionInfo(HRegionInfo info) { - super(new UnmodifyableHTableDescriptor(info.getTableDesc()), - info.getStartKey(), info.getEndKey(), info.isSplit()); + super(info); + this.tableDesc = new UnmodifyableHTableDescriptor(info.getTableDesc()); } /** diff --git a/src/java/org/apache/hadoop/hbase/client/UnmodifyableHTableDescriptor.java b/src/java/org/apache/hadoop/hbase/client/UnmodifyableHTableDescriptor.java index c090b417a0c..30dced1cc0f 100644 --- a/src/java/org/apache/hadoop/hbase/client/UnmodifyableHTableDescriptor.java +++ b/src/java/org/apache/hadoop/hbase/client/UnmodifyableHTableDescriptor.java @@ -25,38 +25,6 @@ import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.util.Bytes; class UnmodifyableHTableDescriptor extends HTableDescriptor { - /* - * Constructs an empty object. - * For deserializing an HTableDescriptor instance only. - */ - UnmodifyableHTableDescriptor() { - super(); - } - - /* - * Constructor. - * @param name Table name. - * @throws IllegalArgumentException if passed a table name - * that is made of other than 'word' characters, underscore or period: i.e. - * [a-zA-Z_0-9.]. - * @see HADOOP-1581 HBASE: Un-openable tablename bug - */ - UnmodifyableHTableDescriptor(final String name) { - this(Bytes.toBytes(name)); - } - - /* - * Constructor. - * @param name Table name. - * @throws IllegalArgumentException if passed a table name - * that is made of other than 'word' characters, underscore or period: i.e. - * [a-zA-Z_0-9.]. - * @see HADOOP-1581 HBASE: Un-openable tablename bug - */ - UnmodifyableHTableDescriptor(final byte [] name) { - super(name); - } - /* * Create an unmodifyable copy of an HTableDescriptor * @param desc