You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by 神之疯神 <77...@qq.com> on 2014/07/03 03:22:08 UTC
Timeout processing put inside observer with over 10 threads.
In my observer prePut method, I intercept the origin put then modify rowkey and copy everything else. I tried different way to get HTableInterface to find out the most efficient one.
These codes are the one went wrong.
private Configuration conf=null;
private HConnection connection = null;
@Override
public void postOpen(ObserverContext<RegionCoprocessorEnvironment> e) {
if(conf==null) conf=e.getEnvironment().getConfiguration();
try {
if(connection==null) connection=HConnectionManager.createConnection(conf);
} catch (Exception e1) {
e1.printStackTrace();
}
}
@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> e,Put put, WALEdit edit, boolean writeToWAL) throws IOException {
String tn=e.getEnvironment().getRegion().getTableDesc().getNameAsString();
l.debug("puttable:"+tn);
String rowkey = Bytes.toString(put.getRow());
l.debug("rowkey="+rowkey); ...
HTableInterface tableA = connection.getTable("tablename");
log.debug("put start at+"+time);
tableA.put(dataput);
log.debug("put stop at+"+System.currentTimeMillis());
tableA.close();
...
}
The log says all thread simply stopped after excuted put method, till timeout.
Can anyone tell me what have happened?
The same style works perfectly as client. 9 threads is ok when each thread performs less than 100 puts ,and same thing happens when I pushed further.
------------------
Michael.Calvin.Shi
Re: Timeout processing put inside observer with over 10 threads.
Posted by Ted Yu <yu...@gmail.com>.
bq. then modify rowkey and copy everything else
The new Put is likely to end up on another region server, right ?
Cheers
On Wed, Jul 2, 2014 at 6:22 PM, 神之疯神 <77...@qq.com> wrote:
> In my observer prePut method, I intercept the origin put then modify
> rowkey and copy everything else. I tried different way to get
> HTableInterface to find out the most efficient one.
> These codes are the one went wrong.
>
> private Configuration conf=null;
> private HConnection connection = null;
> @Override
> public void postOpen(ObserverContext<RegionCoprocessorEnvironment> e) {
> if(conf==null) conf=e.getEnvironment().getConfiguration();
> try {
>
> if(connection==null) connection=HConnectionManager.createConnection(conf);
> } catch (Exception e1) {
> e1.printStackTrace();
> }
> }
> @Override
> public void prePut(ObserverContext<RegionCoprocessorEnvironment> e,Put
> put, WALEdit edit, boolean writeToWAL) throws IOException {
> String
> tn=e.getEnvironment().getRegion().getTableDesc().getNameAsString();
> l.debug("puttable:"+tn);
> String rowkey = Bytes.toString(put.getRow());
> l.debug("rowkey="+rowkey);
> ...
> HTableInterface tableA = connection.getTable("tablename");
> log.debug("put start at+"+time);
> tableA.put(dataput);
> log.debug("put stop at+"+System.currentTimeMillis());
> tableA.close();
> ...
> }
>
> The log says all thread simply stopped after excuted put method, till
> timeout.
> Can anyone tell me what have happened?
>
> The same style works perfectly as client. 9 threads is ok when each thread
> performs less than 100 puts ,and same thing happens when I pushed further.
>
>
> ------------------
> Michael.Calvin.Shi
>
>