I have narrowed this down, but still don't understand the problem.
When the 2nd run of the tests fails (due to not being able to enable
the 1st table created), when I go to the shell and do a list, the
table is there. If i do a "drop 'MyTable1" it reports success, but
when I do a 'list' again it is still there. I have to execute 'drop
'MyTable1" 2x in order for it to drop?
On Oct 18, 2009, at 11:48 AM, yz5od2 wrote:
Hi,
I am running the latest version of Hbase in standalone mode.
I have a Junit test which connects to the local Hbase process,
creates 2 tables, inserts some records, reads those records, then
deletes the records. When the test is done, it disables both tables
and then deletes the tables. All of these actions complete
successfully. When I bring up the Hbase shell, I verify that the
tables do not exist. (code below)
-----------------
1st run
-----------------
Here is the console output when it creates the new tables before
inserting data
[18/10/09 11:35:57:057 MDT] INFO client.HBaseAdmin: Disabled MyTable1
[18/10/09 11:35:57:057 MDT] INFO client.HBaseAdmin: Disabled MyTable1
[18/10/09 11:35:58:058 MDT] INFO client.HBaseAdmin: Enabled table
MyTable1
[18/10/09 11:35:58:058 MDT] INFO client.HBaseAdmin: Enabled table
MyTable1
[18/10/09 11:36:10:010 MDT] INFO client.HBaseAdmin: Disabled MyTable2
[18/10/09 11:36:10:010 MDT] INFO client.HBaseAdmin: Disabled MyTable2
[18/10/09 11:36:10:010 MDT] INFO client.HBaseAdmin: Enabled table
MyTable2
[18/10/09 11:36:10:010 MDT] INFO client.HBaseAdmin: Enabled table
MyTable2
DATA IS PUT, GET and DELETEd here.....
[18/10/09 11:37:27:027 MDT] INFO client.HBaseAdmin: Disabled MyTable1
[18/10/09 11:37:27:027 MDT] INFO client.HBaseAdmin: Disabled MyTable1
[18/10/09 11:37:27:027 MDT] INFO client.HBaseAdmin: Deleted MyTable1
[18/10/09 11:37:27:027 MDT] INFO client.HBaseAdmin: Deleted MyTable1
[18/10/09 11:37:33:033 MDT] INFO client.HBaseAdmin: Disabled MyTable2
[18/10/09 11:37:33:033 MDT] INFO client.HBaseAdmin: Disabled MyTable2
[18/10/09 11:37:33:033 MDT] INFO client.HBaseAdmin: Deleted MyTable2
[18/10/09 11:37:33:033 MDT] INFO client.HBaseAdmin: Deleted MyTable2
After the process completes, I verify in Hbase shell that the tables
in fact do not exist.
-------------------
2nd run
-------------------
However when I run the same test the 2nd time, it fails on trying to
enable the first table it re-creates, with the following error.
[18/10/09 11:39:42:042 MDT] INFO zookeeper.ClientCnxn: Server
connection successful
[18/10/09 11:39:55:055 MDT] INFO client.HBaseAdmin: Disabled MyTable1
[18/10/09 11:39:55:055 MDT] INFO client.HBaseAdmin: Disabled MyTable1
At this point it seems to sit there, and fails with the following
error. When I go to Hbase shell, I see that the MyTable1 does in
fact exist. However it looks like my code fails on enabling it. What
might be the problem?
Caused by: java.io.IOException: Unable to enable table MyTable1
at
org
.apache.hadoop.hbase.client.HBaseAdmin.enableTable(HBaseAdmin.java:
356)
at
org
.apache.hadoop.hbase.client.HBaseAdmin.enableTable(HBaseAdmin.java:
315)
I really don't follow why this error is occurring. here is my code
that creates the tables and deletes them:
this.config = new HBaseConfiguration();
try {
admin = new HBaseAdmin(config);
} catch(MasterNotRunningException e) {
throw new Exception("Could not setup HBaseAdmin as no master is
running...");
}
// FOR EACH of my tables (MyTable1 and MyTable2)
...
String tableName = clazz.getSimpleName();
if (!admin.tableExists(tableName)) {
admin.createTable(new HTableDescriptor(tableName));
admin.disableTable(tableName);
String[] columns = this.getColumns(clazz);
for (String column : columns) {
admin.addColumn(tableName, new HColumnDescriptor(column));
}
}
if (!admin.isTableEnabled(tableName)) {
admin.enableTable(tableName);
}
.....
// MY CODE TO DELETE THE TABLES (for each ... MyTable1 etc..)
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}