On Fri, Mar 14, 2014 at 2:55 PM, Wei Tan <[email protected]> wrote:

> Hi All, we seem to have overcome this occasional exception by changing
> HTable from being called through ConnectionManager vs. directly
> instantiating  HTable.
>
> OLD BAD:
> connection = HConnectionManager.createConnection(config);
>
> protected HTableInterface getHTable(String tableName) throws IOException
> {
>                  //Connection might have been closed since we acquired
> it...create a
>                  //new one if this is the case
>                  if (connection == null || connection.isClosed())
>                  {
>                                  log.info("HConnection null or
> closed...reopening");
>                                  connection =
> HConnectionManager.createConnection(config);
>                  }
>
>                  return connection.getTable(tableName);
> }
>
>
> NEW GOOD:
> public HTableInterface getHTable(byte[] tableName) throws IOException
> {
>                  return new HTable(conf, tableName);
> }
>
> Comment on this link [0] is why they opted down the initial - BAD path:
> ". Instances of this class can be constructed directly but it is
> encouraged that users get instances via HConnection and HConnectionManager
> . See HConnectionManager class comment for an example. "
>
>
I made it a blocker to change the wording (HBASE-10757).  We want folks to
go via HCM ALWAYs from here on out.

Thanks for reporting back Wei Tan,
St.Ack

Reply via email to