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 |