You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Jim the Standing Bear <st...@gmail.com> on 2013/04/10 16:56:27 UTC

class cast exception and setting operation timeout on a pooled HTable

Hi,

When I use HTablePool to perform some HBase data loading operations, I
encountered a problem where the Put operation seemed to hang forever.
A little bit of digging shows that the default client operation
timeout is something like 2 billion ms.

HTable provides a getter and setter methods on operation time out, but
that method is not exposed in HTableInterface.  In addition, the
HTablePool.getTable actually returns a PooledHTable object although
down-casted as HTableInterface, and PooledHTable extends HTable, so it
seems every piece is there for me to check or to set the operation
timeout, and all I need is just some class casting.

But when I do

HTableInterface hti = hTablePool.getTable("table1");
System.out.println(((HTable)hti).getOperationTimeout);

I get a class cast exception:

java.lang.ClassCastException:
org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast
to org.apache.hadoop.hbase.client.HTable

What am I missing?  Also how can I check or set the operation timeout?
 I know another way is to use the configuration parameter,
hbase.client.operation.timeout, but it doesn't allow me to check an
actual HTable instance to make sure the correct timeout is set.
Please help.

I am using hbase 0.94.4 with security enabled.  Thanks.

-- Jim

Re: class cast exception and setting operation timeout on a pooled HTable

Posted by Jim the Standing Bear <st...@gmail.com>.
Thanks Ted and Nicolas.  It is good to know about the more controllable way
to create connection pooling.  I will work that into the next version of
our code.

-- Jim


On Wed, Apr 10, 2013 at 12:09 PM, Nicolas Liochon <nk...@gmail.com> wrote:

> But don't forget you don't have to use pooled tables anymore. You can
> create the tables you need on the fly, see "9.3.1.1. Connection Pooling."
> IIRC, it's available in the version you're using (but I haven't checked).
>
> Cheers,
>
> Nicolas
>
>
> On Wed, Apr 10, 2013 at 5:26 PM, Jim the Standing Bear <
> standingbear@gmail.com> wrote:
>
> > Thanks Ted.  It appears the implementation has changed from v0.92 to
> > v0.94 (PooledHTable used to extend HTable in v0.92, but only
> > implements HTableInterface in v0.94).  My fault for looking at the
> > v0.92 sourcecode and assumed that it would be the same in v0.94.
> > So in other words, there is no way to directly set the operation
> > timeout on a pooled table, correct?  Thanks.
> >
> > -- Jim
> >
> > On Wed, Apr 10, 2013 at 11:02 AM, Ted Yu <yu...@gmail.com> wrote:
> > > PooledHTable implements HTableInterface through delegate, table.
> > > I see this method:
> > >
> > >      * Expose the wrapped HTable to tests in the same package
> > >
> > >      *
> > >
> > >      * @return wrapped htable
> > >
> > >      */
> > >
> > >     HTableInterface getWrappedTable() {
> > >
> > >       return table;
> > >
> > >     }
> > > If you just want to verify timeout, you can use (I know this is not
> > ideal):
> > >
> > >     public String toString() {
> > >
> > >       return "PooledHTable{" + ", table=" + table + '}';
> > >
> > >     }
> > >
> > > On Wed, Apr 10, 2013 at 7:56 AM, Jim the Standing Bear <
> > > standingbear@gmail.com> wrote:
> > >
> > >> Hi,
> > >>
> > >> When I use HTablePool to perform some HBase data loading operations, I
> > >> encountered a problem where the Put operation seemed to hang forever.
> > >> A little bit of digging shows that the default client operation
> > >> timeout is something like 2 billion ms.
> > >>
> > >> HTable provides a getter and setter methods on operation time out, but
> > >> that method is not exposed in HTableInterface.  In addition, the
> > >> HTablePool.getTable actually returns a PooledHTable object although
> > >> down-casted as HTableInterface, and PooledHTable extends HTable, so it
> > >> seems every piece is there for me to check or to set the operation
> > >> timeout, and all I need is just some class casting.
> > >>
> > >> But when I do
> > >>
> > >> HTableInterface hti = hTablePool.getTable("table1");
> > >> System.out.println(((HTable)hti).getOperationTimeout);
> > >>
> > >> I get a class cast exception:
> > >>
> > >> java.lang.ClassCastException:
> > >> org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast
> > >> to org.apache.hadoop.hbase.client.HTable
> > >>
> > >> What am I missing?  Also how can I check or set the operation timeout?
> > >>  I know another way is to use the configuration parameter,
> > >> hbase.client.operation.timeout, but it doesn't allow me to check an
> > >> actual HTable instance to make sure the correct timeout is set.
> > >> Please help.
> > >>
> > >> I am using hbase 0.94.4 with security enabled.  Thanks.
> > >>
> > >> -- Jim
> > >>
> >
> >
> >
> > --
> > --------------------------------------
> > Standing Bear Has Spoken
> > --------------------------------------
> >
>



-- 
--------------------------------------
Standing Bear Has Spoken
--------------------------------------

Re: class cast exception and setting operation timeout on a pooled HTable

Posted by Nicolas Liochon <nk...@gmail.com>.
But don't forget you don't have to use pooled tables anymore. You can
create the tables you need on the fly, see "9.3.1.1. Connection Pooling."
IIRC, it's available in the version you're using (but I haven't checked).

Cheers,

Nicolas


On Wed, Apr 10, 2013 at 5:26 PM, Jim the Standing Bear <
standingbear@gmail.com> wrote:

> Thanks Ted.  It appears the implementation has changed from v0.92 to
> v0.94 (PooledHTable used to extend HTable in v0.92, but only
> implements HTableInterface in v0.94).  My fault for looking at the
> v0.92 sourcecode and assumed that it would be the same in v0.94.
> So in other words, there is no way to directly set the operation
> timeout on a pooled table, correct?  Thanks.
>
> -- Jim
>
> On Wed, Apr 10, 2013 at 11:02 AM, Ted Yu <yu...@gmail.com> wrote:
> > PooledHTable implements HTableInterface through delegate, table.
> > I see this method:
> >
> >      * Expose the wrapped HTable to tests in the same package
> >
> >      *
> >
> >      * @return wrapped htable
> >
> >      */
> >
> >     HTableInterface getWrappedTable() {
> >
> >       return table;
> >
> >     }
> > If you just want to verify timeout, you can use (I know this is not
> ideal):
> >
> >     public String toString() {
> >
> >       return "PooledHTable{" + ", table=" + table + '}';
> >
> >     }
> >
> > On Wed, Apr 10, 2013 at 7:56 AM, Jim the Standing Bear <
> > standingbear@gmail.com> wrote:
> >
> >> Hi,
> >>
> >> When I use HTablePool to perform some HBase data loading operations, I
> >> encountered a problem where the Put operation seemed to hang forever.
> >> A little bit of digging shows that the default client operation
> >> timeout is something like 2 billion ms.
> >>
> >> HTable provides a getter and setter methods on operation time out, but
> >> that method is not exposed in HTableInterface.  In addition, the
> >> HTablePool.getTable actually returns a PooledHTable object although
> >> down-casted as HTableInterface, and PooledHTable extends HTable, so it
> >> seems every piece is there for me to check or to set the operation
> >> timeout, and all I need is just some class casting.
> >>
> >> But when I do
> >>
> >> HTableInterface hti = hTablePool.getTable("table1");
> >> System.out.println(((HTable)hti).getOperationTimeout);
> >>
> >> I get a class cast exception:
> >>
> >> java.lang.ClassCastException:
> >> org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast
> >> to org.apache.hadoop.hbase.client.HTable
> >>
> >> What am I missing?  Also how can I check or set the operation timeout?
> >>  I know another way is to use the configuration parameter,
> >> hbase.client.operation.timeout, but it doesn't allow me to check an
> >> actual HTable instance to make sure the correct timeout is set.
> >> Please help.
> >>
> >> I am using hbase 0.94.4 with security enabled.  Thanks.
> >>
> >> -- Jim
> >>
>
>
>
> --
> --------------------------------------
> Standing Bear Has Spoken
> --------------------------------------
>

Re: class cast exception and setting operation timeout on a pooled HTable

Posted by Ted Yu <yu...@gmail.com>.
bq. there is no way to directly set the operation timeout on a pooled table

Right.

Cheers

On Wed, Apr 10, 2013 at 8:26 AM, Jim the Standing Bear <
standingbear@gmail.com> wrote:

> Thanks Ted.  It appears the implementation has changed from v0.92 to
> v0.94 (PooledHTable used to extend HTable in v0.92, but only
> implements HTableInterface in v0.94).  My fault for looking at the
> v0.92 sourcecode and assumed that it would be the same in v0.94.
> So in other words, there is no way to directly set the operation
> timeout on a pooled table, correct?  Thanks.
>
> -- Jim
>
> On Wed, Apr 10, 2013 at 11:02 AM, Ted Yu <yu...@gmail.com> wrote:
> > PooledHTable implements HTableInterface through delegate, table.
> > I see this method:
> >
> >      * Expose the wrapped HTable to tests in the same package
> >
> >      *
> >
> >      * @return wrapped htable
> >
> >      */
> >
> >     HTableInterface getWrappedTable() {
> >
> >       return table;
> >
> >     }
> > If you just want to verify timeout, you can use (I know this is not
> ideal):
> >
> >     public String toString() {
> >
> >       return "PooledHTable{" + ", table=" + table + '}';
> >
> >     }
> >
> > On Wed, Apr 10, 2013 at 7:56 AM, Jim the Standing Bear <
> > standingbear@gmail.com> wrote:
> >
> >> Hi,
> >>
> >> When I use HTablePool to perform some HBase data loading operations, I
> >> encountered a problem where the Put operation seemed to hang forever.
> >> A little bit of digging shows that the default client operation
> >> timeout is something like 2 billion ms.
> >>
> >> HTable provides a getter and setter methods on operation time out, but
> >> that method is not exposed in HTableInterface.  In addition, the
> >> HTablePool.getTable actually returns a PooledHTable object although
> >> down-casted as HTableInterface, and PooledHTable extends HTable, so it
> >> seems every piece is there for me to check or to set the operation
> >> timeout, and all I need is just some class casting.
> >>
> >> But when I do
> >>
> >> HTableInterface hti = hTablePool.getTable("table1");
> >> System.out.println(((HTable)hti).getOperationTimeout);
> >>
> >> I get a class cast exception:
> >>
> >> java.lang.ClassCastException:
> >> org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast
> >> to org.apache.hadoop.hbase.client.HTable
> >>
> >> What am I missing?  Also how can I check or set the operation timeout?
> >>  I know another way is to use the configuration parameter,
> >> hbase.client.operation.timeout, but it doesn't allow me to check an
> >> actual HTable instance to make sure the correct timeout is set.
> >> Please help.
> >>
> >> I am using hbase 0.94.4 with security enabled.  Thanks.
> >>
> >> -- Jim
> >>
>
>
>
> --
> --------------------------------------
> Standing Bear Has Spoken
> --------------------------------------
>

Re: class cast exception and setting operation timeout on a pooled HTable

Posted by Jim the Standing Bear <st...@gmail.com>.
Thanks Ted.  It appears the implementation has changed from v0.92 to
v0.94 (PooledHTable used to extend HTable in v0.92, but only
implements HTableInterface in v0.94).  My fault for looking at the
v0.92 sourcecode and assumed that it would be the same in v0.94.
So in other words, there is no way to directly set the operation
timeout on a pooled table, correct?  Thanks.

-- Jim

On Wed, Apr 10, 2013 at 11:02 AM, Ted Yu <yu...@gmail.com> wrote:
> PooledHTable implements HTableInterface through delegate, table.
> I see this method:
>
>      * Expose the wrapped HTable to tests in the same package
>
>      *
>
>      * @return wrapped htable
>
>      */
>
>     HTableInterface getWrappedTable() {
>
>       return table;
>
>     }
> If you just want to verify timeout, you can use (I know this is not ideal):
>
>     public String toString() {
>
>       return "PooledHTable{" + ", table=" + table + '}';
>
>     }
>
> On Wed, Apr 10, 2013 at 7:56 AM, Jim the Standing Bear <
> standingbear@gmail.com> wrote:
>
>> Hi,
>>
>> When I use HTablePool to perform some HBase data loading operations, I
>> encountered a problem where the Put operation seemed to hang forever.
>> A little bit of digging shows that the default client operation
>> timeout is something like 2 billion ms.
>>
>> HTable provides a getter and setter methods on operation time out, but
>> that method is not exposed in HTableInterface.  In addition, the
>> HTablePool.getTable actually returns a PooledHTable object although
>> down-casted as HTableInterface, and PooledHTable extends HTable, so it
>> seems every piece is there for me to check or to set the operation
>> timeout, and all I need is just some class casting.
>>
>> But when I do
>>
>> HTableInterface hti = hTablePool.getTable("table1");
>> System.out.println(((HTable)hti).getOperationTimeout);
>>
>> I get a class cast exception:
>>
>> java.lang.ClassCastException:
>> org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast
>> to org.apache.hadoop.hbase.client.HTable
>>
>> What am I missing?  Also how can I check or set the operation timeout?
>>  I know another way is to use the configuration parameter,
>> hbase.client.operation.timeout, but it doesn't allow me to check an
>> actual HTable instance to make sure the correct timeout is set.
>> Please help.
>>
>> I am using hbase 0.94.4 with security enabled.  Thanks.
>>
>> -- Jim
>>



-- 
--------------------------------------
Standing Bear Has Spoken
--------------------------------------

Re: class cast exception and setting operation timeout on a pooled HTable

Posted by Ted Yu <yu...@gmail.com>.
PooledHTable implements HTableInterface through delegate, table.
I see this method:

     * Expose the wrapped HTable to tests in the same package

     *

     * @return wrapped htable

     */

    HTableInterface getWrappedTable() {

      return table;

    }
If you just want to verify timeout, you can use (I know this is not ideal):

    public String toString() {

      return "PooledHTable{" + ", table=" + table + '}';

    }

On Wed, Apr 10, 2013 at 7:56 AM, Jim the Standing Bear <
standingbear@gmail.com> wrote:

> Hi,
>
> When I use HTablePool to perform some HBase data loading operations, I
> encountered a problem where the Put operation seemed to hang forever.
> A little bit of digging shows that the default client operation
> timeout is something like 2 billion ms.
>
> HTable provides a getter and setter methods on operation time out, but
> that method is not exposed in HTableInterface.  In addition, the
> HTablePool.getTable actually returns a PooledHTable object although
> down-casted as HTableInterface, and PooledHTable extends HTable, so it
> seems every piece is there for me to check or to set the operation
> timeout, and all I need is just some class casting.
>
> But when I do
>
> HTableInterface hti = hTablePool.getTable("table1");
> System.out.println(((HTable)hti).getOperationTimeout);
>
> I get a class cast exception:
>
> java.lang.ClassCastException:
> org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast
> to org.apache.hadoop.hbase.client.HTable
>
> What am I missing?  Also how can I check or set the operation timeout?
>  I know another way is to use the configuration parameter,
> hbase.client.operation.timeout, but it doesn't allow me to check an
> actual HTable instance to make sure the correct timeout is set.
> Please help.
>
> I am using hbase 0.94.4 with security enabled.  Thanks.
>
> -- Jim
>