I am experiencing an unexpected behaviour using the Java API to truncate an HBase table. In detail, I am doing the following operations:
- Disable the table
- Truncate the table
- Enable the table
The code corresponding to these operations is the following:
Configuration conf = HBaseConfiguration.create();
// ...
// Setting properly the configuration information
// ...
try (HBaseAdmin admin = new HBaseAdmin(conf)) {
if (admin.isTableEnabled(TABLE_NAME)) {
admin.disableTable(TABLE_NAME);
}
admin.truncateTable(TableName.valueOf(TABLE_NAME), false);
// Enabling the table after having truncated
admin.enableTable(TABLE_NAME);
} catch (MasterNotRunningException e) {
e.printStackTrace();
} catch (ZooKeeperConnectionException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Now, the statement admin.enableTable(TABLE_NAME)
after the truncate operation throws an org.apache.hadoop.hbase.TableNotDisabledException
. Is it correct? Truncating a table via Java API re-enables it automagically?
I have checked the API and I did not find any reference to this behaviuor.
I am using HBase, version 1.0.0-cdh5.5.0.