Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 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?
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)
> >     at
> >
> >
> org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.prePut(RegionCoprocessorHost.java:808)
> >     at
> >
> >
> org.apache.hadoop.hbase.regionserver.HRegion.doPreMutationHook(HRegion.java:2196)
> >     at
> >
> org.apache.hadoop.hbase.regionserver.HRegion.batchMutate(HRegion.java:2172)
> >     at
> >
> >
> org.apache.hadoop.hbase.regionserver.HRegionServer.multi(HRegionServer.java:3811)
> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >     at
> >
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >     at
> >
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >     at java.lang.reflect.Method.invoke(Method.java:597)
> >     at
> >
> >
> org.apache.hadoop.hbase.ipc.WritableRpcEngine$Server.call(WritableRpcEngine.java:320)
> >     at
> >
> org.apache.hadoop.hbase.ipc.HBaseServer$Handler.run(HBaseServer.java:1426)
> >
> >
> > On Tue, Oct 22, 2013 at 8:07 PM, Ted Yu <[EMAIL PROTECTED]> wrote:
> >
> > > Yong:
> > > Can you post full stack trace so that we can diagnose the problem ?
> > >
> > > Cheers
> > >
> > >
> > > On Tue, Oct 22, 2013 at 11:01 AM, yonghu <[EMAIL PROTECTED]>
> wrote:
> > >
> > > > Gray,
> > > >
> > > > Finally, I saw the error messages. ERROR:
> > > > org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException:
> > > Failed
> > > > 1 action: org.apache.hadoop.hbase.DoNotRetryIOException: Coprocessor:
> > > >
> > > >
> > >
> >
> 'org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost$RegionEnvironment@303a60
> > > > '
> > > > threw: 'java.lang.UnsupportedOperationException: Immutable
> > Configuration'
> > > > and has been removed from the active coprocessor set.
> > > >
> > > > I will try different approach as Ted mentioned.
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB