Hi,
I've tried using HBaseAdmin.getAlterStatus to check on a HBaseAdmin.modifyTable
command I've issued, but it doesn't work.
Sample Code:
Modifying Table
tableDescriptor = admin.getTableDescriptor(tableNameBytes);
if (tableDescriptor.hasCoprocessor(observerClassname)) {
logger.info("Coprocessor installed already. Removing to
update jar location in any case");
tableDescriptor.removeCoprocessor(observerClassname);
}
tableDescriptor.addCoprocessor(observerClassname, hdfsJarPath,
RegionObserver.PRIORITY_USER, null);
logger.info("Disabling table "+tableName);
admin.disableTable(tableNameBytes);
logger.info("Modifying table "+tableName);
admin.modifyTable(Bytes.toBytes(tableName), tableDescriptor);
logger.info("Enabling table "+tableName);
admin.enableTable(tableNameBytes);
Using alterStatus
byte[] tableName = it.next();
try {
Pair<Integer,Integer> alterStatus =
admin.getAlterStatus(tableName);
if (alterStatus.getFirst() == alterStatus.getSecond()) {
it.remove();
logger.info("Table "+Bytes.toString(tableName)+" was
altered successfully. "+notLoadedTables.size()+" tables remaining...");
} else {
if (logger.isDebugEnabled()) {
logger.debug("Table "+Bytes.toString(tableName)+"
was not yet altered. Alter Status: "+
alterStatus.getFirst()+" regions altered,
"+alterStatus.getSecond()+" total regions on table");
}
}
} catch (IOException e) {
throw new RuntimeException("Failed getting alter status for
table name: "+Bytes.toString(tableName));
}
Does anyone know how to use it?
Asaf