You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Rajgopal Vaithiyanathan <ra...@gmail.com> on 2013/01/29 01:56:03 UTC

Find the tablename in Observer

Hi all,

inside the prePut() method, Is there anyway to know the table name for
which the prePut() is running ?

-- 
Thanks and Regards,
Rajgopal Vaithiyanathan.

RE: Find the tablename in Observer

Posted by Anoop Sam John <an...@huawei.com>.
Oh sorry...
Not checked the interface...  We were doing in postOpen()...
Thaks Gary for correcting me...:)

-Anoop-

________________________________________
From: Gary Helmling [ghelmling@gmail.com]
Sent: Tuesday, January 29, 2013 11:29 AM
To: user@hbase.apache.org
Subject: Re: Find the tablename in Observer

> >Will the CoprocessorEnvironment reference in the  start() method be
> instanceof RegionCoprocessorEnvironment too
>
> No. It will be reference of RegionEnvironment . This is not a public class
> so you wont be able to do the casting.
>

Since RegionEnvionment implements RegionCoprocessorEnvironment, you should
be able to do:

((RegionCoprocessorEnvironment)env).getRegion().getRegionInfo().getTableName();

within your start() method without a problem.

Re: Find the tablename in Observer

Posted by Gary Helmling <gh...@gmail.com>.
> >Will the CoprocessorEnvironment reference in the  start() method be
> instanceof RegionCoprocessorEnvironment too
>
> No. It will be reference of RegionEnvironment . This is not a public class
> so you wont be able to do the casting.
>

Since RegionEnvionment implements RegionCoprocessorEnvironment, you should
be able to do:

((RegionCoprocessorEnvironment)env).getRegion().getRegionInfo().getTableName();

within your start() method without a problem.

RE: Find the tablename in Observer

Posted by Anoop Sam John <an...@huawei.com>.
>Will the CoprocessorEnvironment reference in the  start() method be
instanceof RegionCoprocessorEnvironment too 

No. It will be reference of RegionEnvironment . This is not a public class so you wont be able to do the casting.
As I read your need, you want to get the table name just once and store and dont want to do the operation again and again in every prePut()

yes. You can do this by getting the table name in pre/postOpen() method. There you are getting a RegionCoprocessorEnvironment  object and this method will be called once.

-Anoop-

________________________________________
From: Ted Yu [yuzhihong@gmail.com]
Sent: Tuesday, January 29, 2013 6:55 AM
To: user@hbase.apache.org
Subject: Re: Find the tablename in Observer

start() method of which class ?

If you use Eclipse, you can navigate through the classes and find out the
answer - that was what I did :-)

You can also place a breakpoint in the following method :
    public void prePut(final ObserverContext<RegionCoprocessorEnvironment>
c,
src/test//java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java

Cheers

On Mon, Jan 28, 2013 at 5:21 PM, Rajgopal Vaithiyanathan <
raja.fire@gmail.com> wrote:

> Will the CoprocessorEnvironment reference in the  start() method be
> instanceof RegionCoprocessorEnvironment too ? if so i can typecast..  (
> sorry :) i would normally check these myself :P but because i dont see
> anyway to put breakpoints and debug, i have to use sysouts to get such
> info. )
>
>
> On Mon, Jan 28, 2013 at 5:16 PM, Rajgopal Vaithiyanathan <
> raja.fire@gmail.com> wrote:
>
> > Great. Thanks..
> >
> > is there anyway that I can get it before prePut() ??
> > Like from the constructor or from the start() method too ? i followed the
> > code of CoprocessorEnvironment and didn't seem to get anything out of it.
> >
> >
> > On Mon, Jan 28, 2013 at 5:09 PM, Ted Yu <yu...@gmail.com> wrote:
> >
> >>   void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
> >>
> >>       final Put put, final WALEdit edit, final boolean writeToWAL)
> >>
> >>
> ((RegionCoprocessorEnvironment)c.getEnvironment()).getRegion().getRegionInfo().getTableName()
> >>
> >> Cheers
> >>
> >> On Mon, Jan 28, 2013 at 4:56 PM, Rajgopal Vaithiyanathan <
> >> raja.fire@gmail.com> wrote:
> >>
> >> > Hi all,
> >> >
> >> > inside the prePut() method, Is there anyway to know the table name for
> >> > which the prePut() is running ?
> >> >
> >> > --
> >> > Thanks and Regards,
> >> > Rajgopal Vaithiyanathan.
> >> >
> >>
> >
> >
> >
> > --
> > Thanks and Regards,
> > Rajgopal Vaithiyanathan.
> >
>
>
>
> --
> Thanks and Regards,
> Rajgopal Vaithiyanathan.
>

Re: Find the tablename in Observer

Posted by Ted Yu <yu...@gmail.com>.
start() method of which class ?

If you use Eclipse, you can navigate through the classes and find out the
answer - that was what I did :-)

You can also place a breakpoint in the following method :
    public void prePut(final ObserverContext<RegionCoprocessorEnvironment>
c,
src/test//java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java

Cheers

On Mon, Jan 28, 2013 at 5:21 PM, Rajgopal Vaithiyanathan <
raja.fire@gmail.com> wrote:

> Will the CoprocessorEnvironment reference in the  start() method be
> instanceof RegionCoprocessorEnvironment too ? if so i can typecast..  (
> sorry :) i would normally check these myself :P but because i dont see
> anyway to put breakpoints and debug, i have to use sysouts to get such
> info. )
>
>
> On Mon, Jan 28, 2013 at 5:16 PM, Rajgopal Vaithiyanathan <
> raja.fire@gmail.com> wrote:
>
> > Great. Thanks..
> >
> > is there anyway that I can get it before prePut() ??
> > Like from the constructor or from the start() method too ? i followed the
> > code of CoprocessorEnvironment and didn't seem to get anything out of it.
> >
> >
> > On Mon, Jan 28, 2013 at 5:09 PM, Ted Yu <yu...@gmail.com> wrote:
> >
> >>   void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
> >>
> >>       final Put put, final WALEdit edit, final boolean writeToWAL)
> >>
> >>
> ((RegionCoprocessorEnvironment)c.getEnvironment()).getRegion().getRegionInfo().getTableName()
> >>
> >> Cheers
> >>
> >> On Mon, Jan 28, 2013 at 4:56 PM, Rajgopal Vaithiyanathan <
> >> raja.fire@gmail.com> wrote:
> >>
> >> > Hi all,
> >> >
> >> > inside the prePut() method, Is there anyway to know the table name for
> >> > which the prePut() is running ?
> >> >
> >> > --
> >> > Thanks and Regards,
> >> > Rajgopal Vaithiyanathan.
> >> >
> >>
> >
> >
> >
> > --
> > Thanks and Regards,
> > Rajgopal Vaithiyanathan.
> >
>
>
>
> --
> Thanks and Regards,
> Rajgopal Vaithiyanathan.
>

Re: Find the tablename in Observer

Posted by Rajgopal Vaithiyanathan <ra...@gmail.com>.
Will the CoprocessorEnvironment reference in the  start() method be
instanceof RegionCoprocessorEnvironment too ? if so i can typecast..  (
sorry :) i would normally check these myself :P but because i dont see
anyway to put breakpoints and debug, i have to use sysouts to get such
info. )


On Mon, Jan 28, 2013 at 5:16 PM, Rajgopal Vaithiyanathan <
raja.fire@gmail.com> wrote:

> Great. Thanks..
>
> is there anyway that I can get it before prePut() ??
> Like from the constructor or from the start() method too ? i followed the
> code of CoprocessorEnvironment and didn't seem to get anything out of it.
>
>
> On Mon, Jan 28, 2013 at 5:09 PM, Ted Yu <yu...@gmail.com> wrote:
>
>>   void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
>>
>>       final Put put, final WALEdit edit, final boolean writeToWAL)
>>
>> ((RegionCoprocessorEnvironment)c.getEnvironment()).getRegion().getRegionInfo().getTableName()
>>
>> Cheers
>>
>> On Mon, Jan 28, 2013 at 4:56 PM, Rajgopal Vaithiyanathan <
>> raja.fire@gmail.com> wrote:
>>
>> > Hi all,
>> >
>> > inside the prePut() method, Is there anyway to know the table name for
>> > which the prePut() is running ?
>> >
>> > --
>> > Thanks and Regards,
>> > Rajgopal Vaithiyanathan.
>> >
>>
>
>
>
> --
> Thanks and Regards,
> Rajgopal Vaithiyanathan.
>



-- 
Thanks and Regards,
Rajgopal Vaithiyanathan.

Re: Find the tablename in Observer

Posted by Rajgopal Vaithiyanathan <ra...@gmail.com>.
Great. Thanks..

is there anyway that I can get it before prePut() ??
Like from the constructor or from the start() method too ? i followed the
code of CoprocessorEnvironment and didn't seem to get anything out of it.


On Mon, Jan 28, 2013 at 5:09 PM, Ted Yu <yu...@gmail.com> wrote:

>   void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
>
>       final Put put, final WALEdit edit, final boolean writeToWAL)
>
> ((RegionCoprocessorEnvironment)c.getEnvironment()).getRegion().getRegionInfo().getTableName()
>
> Cheers
>
> On Mon, Jan 28, 2013 at 4:56 PM, Rajgopal Vaithiyanathan <
> raja.fire@gmail.com> wrote:
>
> > Hi all,
> >
> > inside the prePut() method, Is there anyway to know the table name for
> > which the prePut() is running ?
> >
> > --
> > Thanks and Regards,
> > Rajgopal Vaithiyanathan.
> >
>



-- 
Thanks and Regards,
Rajgopal Vaithiyanathan.

Re: Find the tablename in Observer

Posted by Ted Yu <yu...@gmail.com>.
  void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,

      final Put put, final WALEdit edit, final boolean writeToWAL)
((RegionCoprocessorEnvironment)c.getEnvironment()).getRegion().getRegionInfo().getTableName()

Cheers

On Mon, Jan 28, 2013 at 4:56 PM, Rajgopal Vaithiyanathan <
raja.fire@gmail.com> wrote:

> Hi all,
>
> inside the prePut() method, Is there anyway to know the table name for
> which the prePut() is running ?
>
> --
> Thanks and Regards,
> Rajgopal Vaithiyanathan.
>