hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mesika, Asaf" <asaf.mes...@gmail.com>
Subject Using HBaseAdmin.getAlterStatus
Date Sun, 09 Dec 2012 20:34:45 GMT
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


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message