hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Yu <yuzhih...@gmail.com>
Subject Re: Retry HTable.put() on client-side to handle temp connectivity problem
Date Mon, 27 Jun 2011 20:16:44 GMT
This would retry indefinitely, right ?
Normally maximum retry duration would govern how long the retry is
attempted.

On Mon, Jun 27, 2011 at 1:08 PM, Alex Baranau <alex.baranov.v@gmail.com>wrote:

> Hello,
>
> Just wanted to confirm that I'm doing things in a proper way here. How
> about
> this code to handle the temp cluster connectivity problems (or cluster down
> time) on client-side?
>
> +    // HTable.put() will fail with exception if connection to cluster is
> temporarily broken or
> +    // cluster is temporarily down. To be sure data is written we retry
> writing.
> +    boolean dataWritten = false;
> +    do {
> +      try {
> +        table.put(p);
> +        dataWritten = true;
> +      } catch (IOException ioe) { // indicates cluster connectivity
> problem
> (also thrown when cluster is down)
> +        LOG.error("Writing data to HBase failed, will try again in " +
> RETRY_INTERVAL_ON_WRITE_FAIL + " sec", ioe);
> +        Thread.currentThread().wait(RETRY_INTERVAL_ON_WRITE_FAIL * 1000);
> +      }
> +    } while (!dataWritten);
>
> Thank you in advance,
> Alex Baranau
> ----
> Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - Hadoop - HBase
>

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