HADOOP-2156 BufferUnderflowException for un-named HTableDescriptors
git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@592551 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9be624fc93
commit
656cee4138
|
@ -27,6 +27,7 @@ Trunk (unreleased changes)
|
|||
the test more deterministic and getting META reassigned was
|
||||
problematic.
|
||||
HADOOP-2155 Method expecting HBaseConfiguration throws NPE when given Configuration
|
||||
HADOOP-2156 BufferUnderflowException for un-named HTableDescriptors
|
||||
|
||||
IMPROVEMENTS
|
||||
HADOOP-2401 Add convenience put method that takes writable
|
||||
|
|
|
@ -112,7 +112,6 @@ public class HBaseAdmin implements HConstants {
|
|||
*/
|
||||
public void createTable(HTableDescriptor desc)
|
||||
throws IOException {
|
||||
|
||||
createTableAsync(desc);
|
||||
|
||||
// Wait for new table to come on-line
|
||||
|
@ -134,15 +133,12 @@ public class HBaseAdmin implements HConstants {
|
|||
*/
|
||||
public void createTableAsync(HTableDescriptor desc)
|
||||
throws IOException {
|
||||
|
||||
if (this.master == null) {
|
||||
throw new MasterNotRunningException("master has been shut down");
|
||||
}
|
||||
|
||||
checkReservedTableName(desc.getName());
|
||||
try {
|
||||
this.master.createTable(desc);
|
||||
|
||||
} catch (RemoteException e) {
|
||||
throw RemoteExceptionHandler.decodeRemoteException(e);
|
||||
}
|
||||
|
@ -492,10 +488,12 @@ public class HBaseAdmin implements HConstants {
|
|||
* @throws IllegalArgumentException - if the table name is reserved
|
||||
*/
|
||||
protected void checkReservedTableName(Text tableName) {
|
||||
if (tableName == null || tableName.getLength() <= 0) {
|
||||
throw new IllegalArgumentException("Null or empty table name");
|
||||
}
|
||||
if(tableName.charAt(0) == '-' ||
|
||||
tableName.charAt(0) == '.' ||
|
||||
tableName.find(",") != -1) {
|
||||
|
||||
throw new IllegalArgumentException(tableName + " is a reserved table name");
|
||||
}
|
||||
}
|
||||
|
@ -507,4 +505,4 @@ public class HBaseAdmin implements HConstants {
|
|||
return metaservers.get((metaservers.containsKey(tableName)) ?
|
||||
tableName : metaservers.headMap(tableName).lastKey());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -74,7 +74,11 @@ public class HTableDescriptor implements WritableComparable {
|
|||
families.put(family.getName(), family);
|
||||
}
|
||||
|
||||
/** Constructs an empty object */
|
||||
/**
|
||||
* Constructs an empty object.
|
||||
* For deserializing an HTableDescriptor instance only.
|
||||
* @see #HTableDescriptor(String)
|
||||
*/
|
||||
public HTableDescriptor() {
|
||||
this.name = new Text();
|
||||
this.families = new TreeMap<Text, HColumnDescriptor>();
|
||||
|
|
|
@ -41,6 +41,15 @@ public class TestMasterAdmin extends HBaseClusterTestCase {
|
|||
/** @throws Exception */
|
||||
public void testMasterAdmin() throws Exception {
|
||||
admin = new HBaseAdmin(conf);
|
||||
// Add test that exception is thrown if descriptor is without a table name.
|
||||
// HADOOP-2156.
|
||||
boolean exception = false;
|
||||
try {
|
||||
admin.createTable(new HTableDescriptor());
|
||||
} catch (IllegalArgumentException e) {
|
||||
exception = true;
|
||||
}
|
||||
assertTrue(exception);
|
||||
admin.createTable(testDesc);
|
||||
admin.disableTable(testDesc.getName());
|
||||
|
||||
|
@ -68,4 +77,4 @@ public class TestMasterAdmin extends HBaseClusterTestCase {
|
|||
admin.deleteColumn(testDesc.getName(), new Text("col2:"));
|
||||
admin.deleteTable(testDesc.getName());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue