以下代码
private def deleteTable(tableName: String): Unit = {
val tableNames = admin.listTableNames()
println(s"HBase has the following tables: ${tableNames.map(_.toString).toList}")
tableNames.find(_.getNameAsString == tableName) match {
case Some(matchedTableName) =>
admin.disableTable(matchedTableName)
admin.deleteTable(matchedTableName)
println(s"Table $tableName was found in HBase and deleted.")
case None => println(s"Table $tableName was not in HBase.")
}
}
会抛出
17/10/02 20:45:22 ERROR ApplicationMaster: User class threw exception: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.hbase.TableNotFoundException): XXXX
org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.hbase.TableNotFoundException): XXXX
at org.apache.hadoop.hbase.master.procedure.DisableTableProcedure.prepareDisable(DisableTableProcedure.java:274)
at org.apache.hadoop.hbase.master.procedure.DisableTableProcedure.executeFromState(DisableTableProcedure.java:126)
at org.apache.hadoop.hbase.master.procedure.DisableTableProcedure.executeFromState(DisableTableProcedure.java:54)
at org.apache.hadoop.hbase.procedure2.StateMachineProcedure.execute(StateMachineProcedure.java:139)
at org.apache.hadoop.hbase.procedure2.Procedure.doExecute(Procedure.java:499)
at org.apache.hadoop.hbase.procedure2.ProcedureExecutor.execProcedure(ProcedureExecutor.java:1148)
at org.apache.hadoop.hbase.procedure2.ProcedureExecutor.execLoop(ProcedureExecutor.java:943)
at org.apache.hadoop.hbase.procedure2.ProcedureExecutor.execLoop(ProcedureExecutor.java:896)
at org.apache.hadoop.hbase.procedure2.ProcedureExecutor.access$400(ProcedureExecutor.java:78)
at org.apache.hadoop.hbase.procedure2.ProcedureExecutor$2.run(ProcedureExecutor.java:498)
这对我没有意义,因为可以从管理员检索表名,但是当禁用它时,突然无法找到该表。
编辑: 在HBase shell上,我试过
hbase(main):011:0> user_permission 'XXXX'
User Namespace,Table,Family,Qualifier:Permission
ERROR: DISABLED: Security features are not available