[TRAFODION-2129] Trafodion to avoid use of deprecated HBase APIs/Classes Fix to efficiently use the thread pool in TransactionalTable
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/451eb96e Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/451eb96e Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/451eb96e Branch: refs/heads/master Commit: 451eb96e3c86aa912414b7f19fcddcf7d308c411 Parents: fd083da Author: selvaganesang <[email protected]> Authored: Thu Sep 8 23:07:18 2016 +0000 Committer: selvaganesang <[email protected]> Committed: Thu Sep 8 23:07:18 2016 +0000 ---------------------------------------------------------------------- .../hbase/client/transactional/TransactionalTable.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/451eb96e/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java ---------------------------------------------------------------------- diff --git a/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java b/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java index 1f15403..3bd299d 100644 --- a/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java +++ b/core/sqf/src/seatrans/hbase-trx/src/main/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java @@ -45,6 +45,7 @@ import org.apache.commons.codec.binary.Hex; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.HRegionLocation; @@ -91,6 +92,8 @@ import com.google.protobuf.ByteString; import com.google.protobuf.HBaseZeroCopyByteString; import com.google.protobuf.ServiceException; +import java.util.concurrent.ThreadPoolExecutor; + /** * Table with transactional support. @@ -98,10 +101,15 @@ import com.google.protobuf.ServiceException; public class TransactionalTable extends HTable implements TransactionalTableClient { static final Log LOG = LogFactory.getLog(RMInterface.class); static private Connection connection = null; + static ThreadPoolExecutor threadPool = null; static int retries = 15; static int delay = 1000; private String retryErrMsg = "Coprocessor result is null, retries exhausted"; + static { + Configuration config = HBaseConfiguration.create(); + threadPool = HTable.getDefaultExecutor(config); + } /** * @param tableName @@ -116,8 +124,7 @@ public class TransactionalTable extends HTable implements TransactionalTableClie * @throws IOException */ public TransactionalTable(final byte[] tableName, Connection conn) throws IOException { - //super(tableName, conn, HTable.getDefaultExecutor(conn.getConfiguration())); - super(tableName, conn, Executors.newCachedThreadPool()); + super(tableName, conn, threadPool); this.connection = conn; }
