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:
parent
0271ef616d
commit
1a7c2fc882
|
@ -39,6 +39,7 @@ Hbase Change Log
|
||||||
HBASE-655 Need programmatic way to add column family: need programmatic way
|
HBASE-655 Need programmatic way to add column family: need programmatic way
|
||||||
to enable/disable table
|
to enable/disable table
|
||||||
HBASE-654 API HTable.getMetadata().addFamily shouldn't be exposed to user
|
HBASE-654 API HTable.getMetadata().addFamily shouldn't be exposed to user
|
||||||
|
HBASE-666 UnmodifyableHRegionInfo gives the wrong encoded name
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
HBASE-559 MR example job to count table rows
|
HBASE-559 MR example job to count table rows
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class HRegionInfo implements WritableComparable {
|
||||||
private String regionNameStr = "";
|
private String regionNameStr = "";
|
||||||
private boolean split = false;
|
private boolean split = false;
|
||||||
private byte [] startKey = HConstants.EMPTY_BYTE_ARRAY;
|
private byte [] startKey = HConstants.EMPTY_BYTE_ARRAY;
|
||||||
private HTableDescriptor tableDesc = null;
|
protected HTableDescriptor tableDesc = null;
|
||||||
private int hashCode = -1;
|
private int hashCode = -1;
|
||||||
public static final int NO_HASH = -1;
|
public static final int NO_HASH = -1;
|
||||||
private volatile int encodedName = NO_HASH;
|
private volatile int encodedName = NO_HASH;
|
||||||
|
@ -156,6 +156,24 @@ public class HRegionInfo implements WritableComparable {
|
||||||
setHashCode();
|
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,
|
private static byte [] createRegionName(final byte [] tableName,
|
||||||
final byte [] startKey, final long regionid) {
|
final byte [] startKey, final long regionid) {
|
||||||
return createRegionName(tableName, startKey, Long.toString(regionid));
|
return createRegionName(tableName, startKey, Long.toString(regionid));
|
||||||
|
|
|
@ -24,49 +24,14 @@ import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
|
|
||||||
class UnmodifyableHRegionInfo extends HRegionInfo {
|
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
|
* Creates an unmodifyable copy of an HRegionInfo
|
||||||
*
|
*
|
||||||
* @param info
|
* @param info
|
||||||
*/
|
*/
|
||||||
UnmodifyableHRegionInfo(HRegionInfo info) {
|
UnmodifyableHRegionInfo(HRegionInfo info) {
|
||||||
super(new UnmodifyableHTableDescriptor(info.getTableDesc()),
|
super(info);
|
||||||
info.getStartKey(), info.getEndKey(), info.isSplit());
|
this.tableDesc = new UnmodifyableHTableDescriptor(info.getTableDesc());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,38 +25,6 @@ import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
|
||||||
class UnmodifyableHTableDescriptor extends HTableDescriptor {
|
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
|
* Create an unmodifyable copy of an HTableDescriptor
|
||||||
* @param desc
|
* @param desc
|
||||||
|
|
Loading…
Reference in New Issue