Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
HBase, mail # user - Using HBaseAdmin.getAlterStatus


+
Mesika, Asaf 2012-12-09, 20:34
+
Harsh J 2012-12-09, 20:53
+
Mesika, Asaf 2012-12-09, 21:02
Copy link to this message
-
Re: Using HBaseAdmin.getAlterStatus
Harsh J 2012-12-09, 22:43
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