hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Baranau <alex.barano...@gmail.com>
Subject Re: How is reconnection handled?
Date Tue, 01 May 2012 13:36:10 GMT
Unfortunately HTable instance creation fails (in ctor) when HBase cannot be
reached. Even if HBase was there before and ZK is still running (and holds
all the info about regions locations). During htable initialization client
tries to locate the first region of this table. This info has to be fetched
from "system" tables (-ROOT- and .META.), which are unaccessible since
HBase is down.

The only thing you can do I *think* is to use lazy initialization [1].

Also not sure, but using asynchbase lib might help handling accessing HBase
issues (due to downtime). But it has different from HBase native API, which
might be OK or not OK in your case.

Alex Baranau
------
Sematext :: http://blog.sematext.com/

[1]

(Note: HTable is not thread-safe by itself, so this code isn't going to be
accessed from multiple threads and hence no synchronization is here)

  private HTable hTable;

  private HTable getTable() throws IOException {
    if (hTable == null) {
      try {
        hTable = new HTable("myTable");
      } catch (IOException e) {
        // log/handle attempt failure
      }
    }

    return hTable;
  }

  public void yourCode() {
    HTable hTable = getTable();
    if (hTable != null) { /* ... */}
    // ...
  }

On Sat, Apr 28, 2012 at 9:32 PM, Marco Villalobos <mvillalobos@kineteque.com
> wrote:

> I have this particular use case:
>
> 1) HBase not started.
> 2) A server application that will use HBase stores a configuration a
> field, such as:
>
> Configuration configuration = HBaseConfiguration.create();
> configuration.set("hbase.zookeeper.quorum", "localhost");
>
> 2) The server application is asked to put its data in hbase:
>
> HTable serverAggregationTable = new HTable(configuration, "footable");
>
> 3) Connection fails (as expected).
> 4) start HBase.
> 5) The server application is asked to put its data in hbase, but fails
> because it cannot seem to reconnect.
>
> Error I get is:
>
>
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@5235b5e8
> closed
>        at
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:794)
>        at
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:782)
>        at
> org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:249)
>        at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:213)
>
> How am I supposed to get this to reconnect?  It should be
> automatically handled for me in my humble opinion.
>

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