Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> How to create HTableInterface in coprocessor?


Copy link to this message
-
Re: How to create HTableInterface in coprocessor?
Hi Ted,

This is because I tried different ways to generate a HTableInterface.

One is as Gray mentioned, use RegionCoprocessorEnvironment "rce" to create
a HTableInterface "td", but it did not work. So I commented it.

Later I tried the approach which is suggested by
http://hbase.apache.org/book.html#client.connections. First create a
HConnection "hc", and then create a  HTableInterface "td". It still did not
work.

Both of them return the same error messages. Such as:

ERROR: org.apache.hadoop.hbase.
client.RetriesExhaustedWithDetailsException: Failed 1 action:
org.apache.hadoop.hbase.DoNotRetryIOException: Coprocessor:
'org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost$RegionEnvironment@9a99eb'
threw: 'java.lang.UnsupportedOperationException: Immutable Configuration'
and has been removedfrom the active coprocessor set.
    at
org.apache.hadoop.hbase.coprocessor.CoprocessorHost.handleCoprocessorThrowable(CoprocessorHost.java:740)
    at
org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.prePut(RegionCoprocessorHost.java:810)
.............................

and indicate the errors caused by rce.getTable() or hc.getTable().

regards!

Yong
On Tue, Oct 22, 2013 at 8:42 PM, Ted Yu <[EMAIL PROTECTED]> wrote:

> There're two types of exceptions. In the code below, I saw rce.getTable()
> being commented out.
>
> Can you tell us the correlation between types of exception and getTable()
> calls ?
>
> Thanks
>
>
> On Tue, Oct 22, 2013 at 11:24 AM, yonghu <[EMAIL PROTECTED]> wrote:
>
> > public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put
> > put, WALEdit edit, boolean writeToWAL){
> >         RegionCoprocessorEnvironment rce = e.getEnvironment();
> > HTableInterface td = null;
> >         HTableDescriptor htd = hr.getTableDesc();
> >         Configuration conf = rce.getConfiguration();
> >         HConnection hc = null;
> >         try {
> >             hc = HConnectionManager.createConnection(conf);
> >         } catch (ZooKeeperConnectionException e1) {
> >             // TODO Auto-generated catch block
> >             e1.printStackTrace();
> >         }
> >         try {
> >             td = hc.getTable(Bytes.toBytes(tracking));
> >         } catch (IOException e1) {
> >             // TODO Auto-generated catch block
> >             e1.printStackTrace();
> >         }
> >         try {
> >             //td = rce.getTable(Bytes.toBytes(tracking));
> >             Put p = new Put(put.getRow());
> >             p.add(Bytes.toBytes("Value"), Bytes.toBytes("Current"),
> > Bytes.toBytes(1));
> >             td.put(p);
> >         } catch (IOException e2) {
> >             // TODO Auto-generated catch block
> >             e2.printStackTrace();
> >         }
> > }
> >
> >
> > On Tue, Oct 22, 2013 at 8:20 PM, Ted Yu <[EMAIL PROTECTED]> wrote:
> >
> > > Can you show us your code around the following line ?
> > >
> CDCTrigger.TriggerForModification.prePut(TriggerForModification.java:51)
> > >
> > > The error was due to:
> > >
> > >     public HTableInterface getTable(byte[] tableName, ExecutorService
> > pool)
> > > throws IOException {
> > >       if (managed) {
> > >         throw new IOException("The connection has to be unmanaged.");
> > >       }
> > >
> > > Cheers
> > >
> > >
> > > On Tue, Oct 22, 2013 at 11:14 AM, yonghu <[EMAIL PROTECTED]>
> wrote:
> > >
> > > > Ted,
> > > >
> > > > Can you tell me how to dump the stack trace of HBase? By the way, I
> > check
> > > > the log of RegionServer. It has following error messages:
> > > >
> > > > java.io.IOException: The connection has to be unmanaged.
> > > >     at
> > > >
> > > >
> > >
> >
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getTable(HConnectionManager.java:669)
> > > >     at
> > > >
> > > >
> > >
> >
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getTable(HConnectionManager.java:658)
> > > >     at
> > > >
> > CDCTrigger.TriggerForModification.prePut(TriggerForModification.java:51)