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
This commit is contained in:
Jim Kellerman 2008-06-04 19:24:40 +00:00
parent 0271ef616d
commit 1a7c2fc882
4 changed files with 22 additions and 70 deletions

View File

@ -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

View File

@ -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));

View File

@ -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());
}
/**

View File

@ -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.
* <code>[a-zA-Z_0-9.].
* @see <a href="HADOOP-1581">HADOOP-1581 HBASE: Un-openable tablename bug</a>
*/
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.
* <code>[a-zA-Z_0-9.].
* @see <a href="HADOOP-1581">HADOOP-1581 HBASE: Un-openable tablename bug</a>
*/
UnmodifyableHTableDescriptor(final byte [] name) {
super(name);
}
/*
* Create an unmodifyable copy of an HTableDescriptor
* @param desc