Yes, checked in-between or monitored in parallel. On Mon, Dec 10, 2012 at 2:32 AM, Mesika, Asaf <[email protected]> wrote: > Yeah, I forgot to mention that important bit: > the pair returned is always 0 on the firstKey and never changes. > > So if I understand you correctly, I need to use get AlterStatus between the > modifyTable and enableTable ? > > On Dec 9, 2012, at 10:53 PM, Harsh J wrote: > >> Can you clarify on what "doesn't work" a bit more? >> >> Do you get an exception or are you not receiving some data that you >> are expecting? >> >> AFAICT, this API is helpful for a parallel monitoring of an issued >> schema update. In your code bits, which I will assume is serial, you >> already disable-update-enable table and complete the alter transaction >> before querying it (such that there isn't any pending operation to >> report). If the querying is done in a parallel process/monitor thread, >> then you may see in-flight results. >> >> On Mon, Dec 10, 2012 at 2:04 AM, Mesika, Asaf <[email protected]> wrote: >>> 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 >>> >> >> >> >> -- >> Harsh J >
-- Harsh J
