hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Baranau <alex.barano...@gmail.com>
Subject Retry HTable.put() on client-side to handle temp connectivity problem
Date Mon, 27 Jun 2011 20:08:29 GMT
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