Repository: incubator-trafodion Updated Branches: refs/heads/master 2980764ae -> a29825bf6
[TRAFODION-2129] Trafodion to avoid use of deprecated HBase APIs/Classes Avoided the caching of Hbase table instances on the client side to avoid compaction queue size build up while constantly loading the data Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/fd083da0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/fd083da0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/fd083da0 Branch: refs/heads/master Commit: fd083da016535f1b9589cf959ac60c77acbd2d46 Parents: ea6a933 Author: selvaganesang <[email protected]> Authored: Thu Sep 8 20:02:18 2016 +0000 Committer: selvaganesang <[email protected]> Committed: Thu Sep 8 20:02:18 2016 +0000 ---------------------------------------------------------------------- .../transactional/TransactionalTable.java | 5 +- core/sql/cli/Cli.cpp | 2 - core/sql/cli/Context.cpp | 7 -- core/sql/cli/Context.h | 2 - core/sql/executor/HBaseClient_JNI.cpp | 46 -------- core/sql/executor/HBaseClient_JNI.h | 3 - core/sql/exp/ExpHbaseInterface.cpp | 10 -- core/sql/exp/ExpHbaseInterface.h | 4 - core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 3 - core/sql/sqlcomp/CmpSeabaseDDLupgrade.cpp | 3 - .../java/org/trafodion/sql/HBaseClient.java | 116 +------------------ .../java/org/trafodion/sql/HTableClient.java | 1 + 12 files changed, 10 insertions(+), 192 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/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 5d11e0f..1f15403 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 @@ -98,11 +98,11 @@ 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 ExecutorService threadPool; static int retries = 15; static int delay = 1000; private String retryErrMsg = "Coprocessor result is null, retries exhausted"; + /** * @param tableName * @throws IOException @@ -116,7 +116,8 @@ public class TransactionalTable extends HTable implements TransactionalTableClie * @throws IOException */ public TransactionalTable(final byte[] tableName, Connection conn) throws IOException { - super(tableName, conn, threadPool); + //super(tableName, conn, HTable.getDefaultExecutor(conn.getConfiguration())); + super(tableName, conn, Executors.newCachedThreadPool()); this.connection = conn; } http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/core/sql/cli/Cli.cpp ---------------------------------------------------------------------- diff --git a/core/sql/cli/Cli.cpp b/core/sql/cli/Cli.cpp index 24e8c4a..8f2189b 100644 --- a/core/sql/cli/Cli.cpp +++ b/core/sql/cli/Cli.cpp @@ -2626,8 +2626,6 @@ Lng32 SQLCLI_ProcessRetryQuery( { if (type == AQRInfo::RETRY_WITH_ESP_CLEANUP) aqr->setEspCleanup(TRUE); - else if (type == AQRInfo::RETRY_DECACHE_HTABLE) - currContext->flushHtableCache(); // Before deallocating the statement, set an indication in the // master stats for this query id to indicate that AQR is being http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/core/sql/cli/Context.cpp ---------------------------------------------------------------------- diff --git a/core/sql/cli/Context.cpp b/core/sql/cli/Context.cpp index 3881fde..1833488 100644 --- a/core/sql/cli/Context.cpp +++ b/core/sql/cli/Context.cpp @@ -5838,13 +5838,6 @@ Int32 ContextCli::switchBackCmpContext(void) return 0; // success } -void ContextCli::flushHtableCache() -{ - if (hbaseClientJNI_) - hbaseClientJNI_->cleanup(); -} - - // ***************************************************************************** // * * // * Function: ContextCli::storeName * http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/core/sql/cli/Context.h ---------------------------------------------------------------------- diff --git a/core/sql/cli/Context.h b/core/sql/cli/Context.h index 4d0563d..f860820 100644 --- a/core/sql/cli/Context.h +++ b/core/sql/cli/Context.h @@ -196,8 +196,6 @@ public: { hbaseClientJNI_ = hbaseClientJNI; } HBaseClient_JNI *getHBaseClient() { return hbaseClientJNI_; } - void flushHtableCache(); - HiveClient_JNI *getHiveClient() { return hiveClientJNI_; } void setHiveClient(HiveClient_JNI *hiveClientJNI) { hiveClientJNI_ = hiveClientJNI; } http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/core/sql/executor/HBaseClient_JNI.cpp ---------------------------------------------------------------------- diff --git a/core/sql/executor/HBaseClient_JNI.cpp b/core/sql/executor/HBaseClient_JNI.cpp index 947cc1d..3022555 100644 --- a/core/sql/executor/HBaseClient_JNI.cpp +++ b/core/sql/executor/HBaseClient_JNI.cpp @@ -42,7 +42,6 @@ static const char* const hbcErrorEnumStr[] = { "Preparing parameters for initConnection()." ,"Java exception in initConnection()." - ,"Java exception in cleanup()." ,"Java exception in getHTableClient()." ,"Java exception in releaseHTableClient()." ,"Preparing parameters for create()." @@ -179,8 +178,6 @@ HBaseClient_JNI::~HBaseClient_JNI() pthread_mutex_destroy(&mutex_); pthread_cond_destroy(&workBell_); } - // Clean the Java Side - cleanup(); } ////////////////////////////////////////////////////////////////////////////// @@ -210,8 +207,6 @@ HBC_RetCode HBaseClient_JNI::init() JavaMethods_[JM_CTOR ].jm_signature = "()V"; JavaMethods_[JM_INIT ].jm_name = "init"; JavaMethods_[JM_INIT ].jm_signature = "(Ljava/lang/String;Ljava/lang/String;)Z"; - JavaMethods_[JM_CLEANUP ].jm_name = "cleanup"; - JavaMethods_[JM_CLEANUP ].jm_signature = "()Z"; JavaMethods_[JM_GET_HTC ].jm_name = "getHTableClient"; JavaMethods_[JM_GET_HTC ].jm_signature = "(JLjava/lang/String;Z)Lorg/trafodion/sql/HTableClient;"; JavaMethods_[JM_REL_HTC ].jm_name = "releaseHTableClient"; @@ -347,47 +342,6 @@ HBC_RetCode HBaseClient_JNI::initConnection(const char* zkServers, const char* z ////////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////////// -HBC_RetCode HBaseClient_JNI::cleanup() -{ - // commenting this out for now - this call causes mxosrv crash some times during mxosrv shutdown!! - //QRLogger::log(CAT_SQL_HBASE, LL_DEBUG, "HBaseClient_JNI::cleanup() called."); - - if (! (isInitialized_ && isConnected_)) - return HBC_OK; - - if (jenv_ == NULL) - if (initJVM() != JOI_OK) - return HBC_ERROR_INIT_PARAM; - if (jenv_->PushLocalFrame(jniHandleCapacity_) != 0) { - getExceptionDetails(); - return HBC_ERROR_CLEANUP_EXCEPTION; - } - // boolean cleanup(); - tsRecentJMFromJNI = JavaMethods_[JM_CLEANUP].jm_full_name; - jboolean jresult = jenv_->CallBooleanMethod(javaObj_, JavaMethods_[JM_CLEANUP].methodID); - - if (jenv_->ExceptionCheck()) - { - getExceptionDetails(); - logError(CAT_SQL_HBASE, __FILE__, __LINE__); - logError(CAT_SQL_HBASE, "HBaseClient_JNI::cleanup()", getLastError()); - jenv_->PopLocalFrame(NULL); - return HBC_ERROR_CLEANUP_EXCEPTION; - } - - if (jresult == false) - { - logError(CAT_SQL_HBASE, "HBaseClient_JNI::cleanup()", getLastError()); - jenv_->PopLocalFrame(NULL); - return HBC_ERROR_CLEANUP_EXCEPTION; - } - jenv_->PopLocalFrame(NULL); - return HBC_OK; -} - -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// HTableClient_JNI* HBaseClient_JNI::getHTableClient(NAHeap *heap, const char* tableName, bool useTRex, ExHbaseAccessStats *hbs) { QRLogger::log(CAT_SQL_HBASE, LL_DEBUG, "HBaseClient_JNI::getHTableClient(%s) called.", tableName); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/core/sql/executor/HBaseClient_JNI.h ---------------------------------------------------------------------- diff --git a/core/sql/executor/HBaseClient_JNI.h b/core/sql/executor/HBaseClient_JNI.h index a8690fb..1052fc5 100644 --- a/core/sql/executor/HBaseClient_JNI.h +++ b/core/sql/executor/HBaseClient_JNI.h @@ -341,7 +341,6 @@ typedef enum { ,HBC_DONE = HBC_FIRST ,HBC_ERROR_INIT_PARAM ,HBC_ERROR_INIT_EXCEPTION - ,HBC_ERROR_CLEANUP_EXCEPTION ,HBC_ERROR_GET_HTC_EXCEPTION ,HBC_ERROR_REL_HTC_EXCEPTION ,HBC_ERROR_CREATE_PARAM @@ -421,7 +420,6 @@ public: return isConnected_; } - HBC_RetCode cleanup(); HTableClient_JNI* getHTableClient(NAHeap *heap, const char* tableName, bool useTRex, ExHbaseAccessStats *hbs); HBulkLoadClient_JNI* getHBulkLoadClient(NAHeap *heap); @@ -515,7 +513,6 @@ private: enum JAVA_METHODS { JM_CTOR = 0 ,JM_INIT - ,JM_CLEANUP ,JM_GET_HTC ,JM_REL_HTC ,JM_CREATE http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/core/sql/exp/ExpHbaseInterface.cpp ---------------------------------------------------------------------- diff --git a/core/sql/exp/ExpHbaseInterface.cpp b/core/sql/exp/ExpHbaseInterface.cpp index 001f0f8..83fe298 100644 --- a/core/sql/exp/ExpHbaseInterface.cpp +++ b/core/sql/exp/ExpHbaseInterface.cpp @@ -388,16 +388,6 @@ Lng32 ExpHbaseInterface_JNI::cleanup() } //---------------------------------------------------------------------------- -Lng32 ExpHbaseInterface_JNI::cleanupClient() -{ - if (client_) - { - client_->cleanup(); - } - return HBASE_ACCESS_SUCCESS; -} - -//---------------------------------------------------------------------------- Lng32 ExpHbaseInterface_JNI::close() { // HBaseClient_JNI::logIt("ExpHbaseInterface_JNI::close() called."); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/core/sql/exp/ExpHbaseInterface.h ---------------------------------------------------------------------- diff --git a/core/sql/exp/ExpHbaseInterface.h b/core/sql/exp/ExpHbaseInterface.h index 67fa03b..a8903fe 100644 --- a/core/sql/exp/ExpHbaseInterface.h +++ b/core/sql/exp/ExpHbaseInterface.h @@ -81,8 +81,6 @@ class ExpHbaseInterface : public NABasicObject virtual Lng32 init(ExHbaseAccessStats *hbs = NULL) = 0; virtual Lng32 cleanup() = 0; - virtual Lng32 cleanupClient() - { return 0;} virtual Lng32 close() = 0; @@ -407,8 +405,6 @@ class ExpHbaseInterface_JNI : public ExpHbaseInterface virtual Lng32 cleanup(); - virtual Lng32 cleanupClient(); - virtual Lng32 close(); virtual Lng32 create(HbaseStr &tblName, http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp index e4020e8..32e61e7 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp @@ -7069,9 +7069,6 @@ void CmpSeabaseDDL::initSeabaseMD(NABoolean ddlXns, NABoolean minimal) } // for - // cleanup cached entries in client object. - ehi->cleanupClient(); - deallocEHI(ehi); ehi = NULL; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/core/sql/sqlcomp/CmpSeabaseDDLupgrade.cpp ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/CmpSeabaseDDLupgrade.cpp b/core/sql/sqlcomp/CmpSeabaseDDLupgrade.cpp index 48ad516..7cdc9aa 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLupgrade.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLupgrade.cpp @@ -936,9 +936,6 @@ short CmpSeabaseMDupgrade::executeSeabaseMDupgrade(CmpDDLwithStatusInfo *mdui, break; } - // cleanup cached entries in client object. - ehi->cleanupClient(); - deallocEHI(ehi); mdui->setMsg("Drop Current Metadata: done"); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java ---------------------------------------------------------------------- diff --git a/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java b/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java index b984d3a..6a1ed65 100644 --- a/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java +++ b/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java @@ -104,9 +104,6 @@ public class HBaseClient { private static Configuration config = HBaseConfiguration.create(); private RMInterface table = null; - private PoolMap<String, HTableClient> hTableClientsFree; - private PoolMap<String, HTableClient> hTableClientsInUse; - // variables used for getRegionStats() and getClusterStats() private int regionStatsEntries = 0; private int clusterStatsState = 1; @@ -143,11 +140,6 @@ public class HBaseClient { private static Connection connection; public HBaseClient() { - if (hTableClientsFree == null) - hTableClientsFree = new PoolMap<String, HTableClient> - (PoolType.Reusable, Integer.MAX_VALUE); - hTableClientsInUse = new PoolMap<String, HTableClient> - (PoolType.Reusable, Integer.MAX_VALUE); } static { @@ -183,62 +175,10 @@ public class HBaseClient { return true; } - private void cleanup(PoolMap hTableClientsPool) throws IOException - { - Collection hTableClients; - Iterator<HTableClient> iter; - HTableClient htable; - boolean clearRegionCache = false; - boolean cleanJniObject = true; - - hTableClients = hTableClientsPool.values(); - iter = hTableClients.iterator(); - while (iter.hasNext()) - { - htable = iter.next(); - htable.close(clearRegionCache, cleanJniObject); - } - hTableClientsPool.clear(); - } - - public boolean cleanup() throws IOException { - cleanup(hTableClientsInUse); - cleanup(hTableClientsFree); - return true; - } - - public void cleanupCache(Collection hTableClients) throws IOException - { - Iterator<HTableClient> iter; - HTableClient htable; - boolean clearRegionCache = true; - boolean cleanJniObject = false; - - iter = hTableClients.iterator(); - while (iter.hasNext()) - { - htable = iter.next(); - htable.close(clearRegionCache, cleanJniObject); - } - } - - public boolean cleanupCache(String tblName) throws IOException - { - Collection hTableClients; - hTableClients = hTableClientsFree.values(tblName); - cleanupCache(hTableClients); - hTableClientsFree.remove(tblName); - hTableClients = hTableClientsInUse.values(tblName); - cleanupCache(hTableClients); - hTableClientsInUse.remove(tblName); - return true; - } - public boolean create(String tblName, Object[] colFamNameList, boolean isMVCC) throws IOException, MasterNotRunningException { if (logger.isDebugEnabled()) logger.debug("HBaseClient.create(" + tblName + ") called, and MVCC is " + isMVCC + "."); - cleanupCache(tblName); HTableDescriptor desc = new HTableDescriptor(tblName); CoprocessorUtils.addCoprocessor(config.get("hbase.coprocessor.region.classes"), desc, isMVCC); for (int i = 0; i < colFamNameList.length ; i++) { @@ -490,7 +430,6 @@ public class HBaseClient { throws IOException, MasterNotRunningException { if (logger.isDebugEnabled()) logger.debug("HBaseClient.createk(" + tblName + ") called."); String trueStr = "TRUE"; - cleanupCache(tblName); HTableDescriptor desc = new HTableDescriptor(tblName); CoprocessorUtils.addCoprocessor(config.get("hbase.coprocessor.region.classes"), desc, isMVCC); int defaultVersionsValue = 0; @@ -583,7 +522,6 @@ public class HBaseClient { throws IOException, MasterNotRunningException { if (logger.isDebugEnabled()) logger.debug("HBaseClient.alter(" + tblName + ") called."); - cleanupCache(tblName); Admin admin = getConnection().getAdmin(); HTableDescriptor htblDesc = admin.getTableDescriptor(TableName.valueOf(tblName)); HColumnDescriptor[] families = htblDesc.getColumnFamilies(); @@ -647,7 +585,6 @@ public class HBaseClient { } admin.close(); } - cleanupCache(tblName); return true; } @@ -665,7 +602,6 @@ public class HBaseClient { admin.disableTable(tableName); admin.deleteTable(tableName); } - cleanupCache(tblName); } finally { admin.close(); } @@ -711,7 +647,6 @@ public class HBaseClient { ioExc.addSuppressed(e); if (logger.isDebugEnabled()) logger.debug("HbaseClient.dropAll error" + e); } - cleanupCache(tblName); } admin.close(); @@ -737,7 +672,6 @@ public class HBaseClient { } admin.close(); - cleanup(); return hbaseTables; } @@ -950,39 +884,13 @@ public class HBaseClient { { if (logger.isDebugEnabled()) logger.debug("HBaseClient.getHTableClient(" + tblName + (useTRex ? ", use TRX" : ", no TRX") + ") called."); - HTableClient htable = hTableClientsFree.get(tblName); - if (htable == null) { - htable = new HTableClient(getConnection()); - if (htable.init(tblName, useTRex) == false) { - if (logger.isDebugEnabled()) logger.debug(" ==> Error in init(), returning empty."); + HTableClient htable = new HTableClient(getConnection()); + if (htable.init(tblName, useTRex) == false) { + if (logger.isDebugEnabled()) logger.debug(" ==> Error in init(), returning empty."); return null; - } - - Admin admin = getConnection().getAdmin(); - HTableDescriptor tblDesc = admin.getTableDescriptor(TableName.valueOf(tblName)); - if (logger.isDebugEnabled()) logger.debug("check coprocessor num for tbl : "+ tblName+". coprocessor size : "+tblDesc.getCoprocessors().size()); - boolean added = CoprocessorUtils.addCoprocessor(config.get("hbase.coprocessor.region.classes"), tblDesc); - if (added) { - if (logger.isDebugEnabled()) - logger.debug(" ==> add coprocessor for table : " + tblName); - synchronized (admin) { - TableName table = TableName.valueOf(tblName); - admin.disableTable(table); - admin.modifyTable(table, tblDesc); - admin.enableTable(table); - } - } - - if (logger.isDebugEnabled()) logger.debug(" ==> Created new object."); - hTableClientsInUse.put(htable.getTableName(), htable); - htable.setJniObject(jniObject); - return htable; - } else { - if (logger.isDebugEnabled()) logger.debug(" ==> Returning existing object, removing from container."); - hTableClientsInUse.put(htable.getTableName(), htable); - htable.setJniObject(jniObject); - return htable; } + htable.setJniObject(jniObject); + return htable; } @@ -993,19 +901,7 @@ public class HBaseClient { if (logger.isDebugEnabled()) logger.debug("HBaseClient.releaseHTableClient(" + htable.getTableName() + ")."); boolean cleanJniObject = false; - if (htable.release(cleanJniObject)) - // If the thread is interrupted, then remove the table from cache - // because the table connection is retried when the table is used - // next time - - cleanupCache(htable.getTableName()); - else - { - if (hTableClientsInUse.removeValue(htable.getTableName(), htable)) - hTableClientsFree.put(htable.getTableName(), htable); - else - if (logger.isDebugEnabled()) logger.debug("Table not found in inUse Pool"); - } + htable.release(cleanJniObject); } public boolean grant(byte[] user, byte[] tblName, http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd083da0/core/sql/src/main/java/org/trafodion/sql/HTableClient.java ---------------------------------------------------------------------- diff --git a/core/sql/src/main/java/org/trafodion/sql/HTableClient.java b/core/sql/src/main/java/org/trafodion/sql/HTableClient.java index 2474663..eb4c7b4 100644 --- a/core/sql/src/main/java/org/trafodion/sql/HTableClient.java +++ b/core/sql/src/main/java/org/trafodion/sql/HTableClient.java @@ -1773,6 +1773,7 @@ public class HTableClient { } scanHelper = null; jniObject = 0; + table.close(); return retcode; }
