You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2016/07/25 16:34:20 UTC

[1/4] incubator-trafodion git commit: [TRAFODION-1988] Better java exception handling in the java/JNI layer of Trafodion - Part3

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master a82b4e323 -> c397bbe10


[TRAFODION-1988] Better java exception handling in the java/JNI layer of Trafodion
- Part3

The focus is to ensure that the execption seen at the JNI of TM libs are logged
via log4cxx.

These exceptions should be visible in tm_<node_id>.log files. These messages are also
visible in stdout_dtm_<node_id> at $MY_SQROOT/sql/scripts directory.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/8bd91508
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/8bd91508
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/8bd91508

Branch: refs/heads/master
Commit: 8bd915084179a3c6f4a79bf0e0cbca3686479979
Parents: 9305332
Author: selvaganesang <se...@esgyn.com>
Authored: Mon Jul 18 23:12:16 2016 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Mon Jul 18 23:12:16 2016 +0000

----------------------------------------------------------------------
 .../export/include/common/evl_sqlog_eventnum.h  |   1 +
 .../sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp | 222 ++++++-------------
 .../tm/hbasetmlib2/javaobjectinterfacetm.cpp    | 125 ++++++++++-
 .../tm/hbasetmlib2/javaobjectinterfacetm.h      |   7 +
 core/sqf/src/tm/tminfo.cpp                      |   1 -
 core/sqf/src/tm/tmlogging.cpp                   |   5 +-
 core/sqf/src/tm/tools/Makefile                  |  10 +-
 7 files changed, 208 insertions(+), 163 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8bd91508/core/sqf/export/include/common/evl_sqlog_eventnum.h
----------------------------------------------------------------------
diff --git a/core/sqf/export/include/common/evl_sqlog_eventnum.h b/core/sqf/export/include/common/evl_sqlog_eventnum.h
index 324c981..3130e15 100644
--- a/core/sqf/export/include/common/evl_sqlog_eventnum.h
+++ b/core/sqf/export/include/common/evl_sqlog_eventnum.h
@@ -1004,6 +1004,7 @@
 #define DTM_BEGINTX_PROC_NOTEXIST 103005308
 #define DTM_ROLLOVER_CP_ERROR 103005309
 #define DTM_TMRESTARTED 103005310
+#define DTM_TM_JNI_ERROR  103005311
 
 /**********************************************/
 /**********************************************/

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8bd91508/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp b/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
index a689ee7..e21ab1f 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
@@ -32,6 +32,7 @@
 #include "tmtxkey.h"
 #include "tmlogging.h"
 #include "hbasetm.h"
+#include "javaobjectinterfacetm.h"
 
 // Externals
 using namespace std;
@@ -265,17 +266,12 @@ int CHbaseTM::initJVM()
 //////////////////////////////////////////////
 short CHbaseTM::initConnection(short pv_nid)
 {
-  jthrowable exc;
-
   jshort   jdtmid = pv_nid;
   jboolean jresult = _tlp_jenv->CallBooleanMethod(javaObj_, JavaMethods_[JM_INIT1].methodID, jdtmid);
-  exc = _tlp_jenv->ExceptionOccurred();
-  if(exc) {
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_SEA_SOFT_FAULT, SQ_LOG_CRIT, (char *) _tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
-
   if (jresult == false)
   {
     return RET_LAST;
@@ -285,7 +281,6 @@ short CHbaseTM::initConnection(short pv_nid)
 }
 
 short CHbaseTM::addControlPoint(){
-  jthrowable exc;
   JOI_RetCode lv_joi_retcode = JOI_OK;
   lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
   if (lv_joi_retcode != JOI_OK) {
@@ -295,13 +290,9 @@ short CHbaseTM::addControlPoint(){
   }
 
   jlong jresult = _tlp_jenv->CallLongMethod(javaObj_, JavaMethods_[JM_CNTPOINT].methodID);
-  exc = _tlp_jenv->ExceptionOccurred();
-  if(exc) {
-    printf("JavaObjectInterfaceTM::JavaMethods_[JM_CNTPOINT].methodID returned Exception\n");
-    fflush(stdout);
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_SEA_SOFT_FAULT, SQ_LOG_CRIT, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
   if (jresult == 0L) {
     return RET_EXCEPTION;
@@ -310,7 +301,6 @@ short CHbaseTM::addControlPoint(){
 }
 
 short CHbaseTM::beginTransaction(int64 *pp_transid) {
-  jthrowable exc;
   jlong  jlv_transid = *pp_transid;
   JOI_RetCode lv_joi_retcode = JOI_OK;
   lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
@@ -321,11 +311,9 @@ short CHbaseTM::beginTransaction(int64 *pp_transid) {
   }
 
   jlong jresult = _tlp_jenv->CallLongMethod(javaObj_, JavaMethods_[JM_BEGIN].methodID, jlv_transid);
-  exc = _tlp_jenv->ExceptionOccurred();
-  if(exc) {
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
   *pp_transid = (long)jresult;
 
@@ -343,12 +331,10 @@ short CHbaseTM::abortTransaction(int64 pv_transid) {
   }
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_ABORT].methodID, jlv_transid);
-  if(_tlp_jenv->ExceptionOccurred()){
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
-
   //  RET_NOTX means the transaction wasn't found by the HBase client code (trx).  This is ok here, it
   //  simply means the transaction hasn't been seen by the HBase client code, so no work was done on it.
   if (jresult == RET_NOTX)
@@ -371,10 +357,9 @@ short CHbaseTM::prepareCommit(int64 pv_transid) {
   }
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_PRECOMMIT].methodID, jlv_transid);
-  if(_tlp_jenv->ExceptionOccurred()){
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
 
   if (jresult <= RET_LAST)
@@ -399,10 +384,9 @@ short CHbaseTM::doCommit(int64 pv_transid) {
   }
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_DOCOMMIT].methodID, jlv_transid);
-  if(_tlp_jenv->ExceptionOccurred()){
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
 
   if (jresult == 1)
@@ -431,10 +415,9 @@ short CHbaseTM::tryCommit(int64 pv_transid) {
   }
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_TRYCOMMIT].methodID, jlv_transid);
-  if(_tlp_jenv->ExceptionOccurred()){
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
 
   //  RET_NOTX means the transaction wasn't found by the HBase client code (trx).  This is ok here, it
@@ -459,10 +442,9 @@ short CHbaseTM::completeRequest(int64 pv_transid) {
   }
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_COMPLETEREQUEST].methodID, jlv_transid);
-  if(_tlp_jenv->ExceptionOccurred()){
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
 
   if (jresult == 1)
@@ -641,7 +623,6 @@ int CHbaseTM::registerRegion(int64 pv_transid,
    CTmTxKey lv_tid(pv_transid);
    HBASETrace(HBASETM_TraceAPI, (HDR "CHbaseTM::registerRegion : Txn ID (%d,%d), startid %ld, hostname: %s.\n",
 				 lv_tid.node(), lv_tid.seqnum(), jlv_startid, pa_hostname));
-  jthrowable exc;
   JOI_RetCode lv_joi_retcode = JOI_OK;
   lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
   if (lv_joi_retcode != JOI_OK) {
@@ -670,13 +651,10 @@ int CHbaseTM::registerRegion(int64 pv_transid,
 					jba_hostname,
 					pv_startcode,
 					jba_regionInfo);
-  exc = _tlp_jenv->ExceptionOccurred();
-  if(exc) {
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    lv_error = RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
-
   _tlp_jenv->DeleteLocalRef(jba_hostname);
   _tlp_jenv->DeleteLocalRef(jba_regionInfo);
 
@@ -745,8 +723,6 @@ int CHbaseTM::participatingRegions(int64 pv_transid)
    CTmTxKey lv_transid(pv_transid);
    HBASETrace(HBASETM_TraceAPI, (HDR "CHbaseTM::participatingRegions : Txn ID (%d,%d).\n", lv_transid.node(), lv_transid.seqnum()));
 
-   jthrowable exc;
-
    JOI_RetCode lv_joi_retcode = JOI_OK;
    lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
   if (lv_joi_retcode != JOI_OK) {
@@ -756,12 +732,10 @@ int CHbaseTM::participatingRegions(int64 pv_transid)
   }
 
    lv_participating = _tlp_jenv->CallIntMethod(javaObj_, JavaMethods_[JM_PARREGION].methodID, lv_transid_j);
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-     _tlp_jenv->ExceptionDescribe();
-     _tlp_jenv->ExceptionClear();
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
      lv_participatingCount = -1;
-   }
+  }
    lv_participatingCount = lv_participating;
 
    HBASETrace(HBASETM_TraceExit, (HDR "CHbaseTM::participatingRegions : Count %d.\n", lv_participatingCount));
@@ -786,7 +760,6 @@ int CHbaseTM::unresolvedRegions(int64 pv_transid)
 } //CHbaseTM::unresolvedRegions
 
 short CHbaseTM::stall(int where){
-  jthrowable exc;
   jint jiv_where = where;
   JOI_RetCode lv_joi_retcode = JOI_OK;
   lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
@@ -798,17 +771,14 @@ short CHbaseTM::stall(int where){
 
   cout << "CHbaseTM::stall called with: " << jiv_where << "\n";
   _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_STALL].methodID, jiv_where);
-  exc = _tlp_jenv->ExceptionOccurred();
-  if(exc) {
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
   return RET_OK;
 }
 
 short CHbaseTM::nodeDown(int32 nid){
-  jthrowable exc;
   jint jiv_nid = nid;
   JOI_RetCode lv_joi_retcode = JOI_OK;
   lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
@@ -820,18 +790,15 @@ short CHbaseTM::nodeDown(int32 nid){
 
   cout << "CHbaseTM::nodeDown called with nodeId " << jiv_nid << "\n";
   _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_NODEDOWN].methodID, jiv_nid);
-  exc = _tlp_jenv->ExceptionOccurred();
-  if(exc) {
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
   return RET_OK;
 }
 
 
 short CHbaseTM::nodeUp(int32 nid){
-  jthrowable exc;
   jint jiv_nid = nid;
   JOI_RetCode lv_joi_retcode = JOI_OK;
   lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
@@ -843,11 +810,9 @@ short CHbaseTM::nodeUp(int32 nid){
 
   cout << "CHbaseTM::nodeUp called with: " << jiv_nid << "\n";
   _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_NODEUP].methodID, jiv_nid);
-  exc = _tlp_jenv->ExceptionOccurred();
-  if(exc) {
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
   }
   return RET_OK;
 }
@@ -870,7 +835,6 @@ int CHbaseTM::createTable(int64 pv_transid,
    HBASETrace(HBASETM_TraceExitError,
               (HDR "CHbaseTM::createTable returning %d.\n", lv_error));
 
-   jthrowable exc;
    JOI_RetCode lv_joi_retcode = JOI_OK;
    lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
    if (lv_joi_retcode != JOI_OK) {
@@ -895,12 +859,10 @@ int CHbaseTM::createTable(int64 pv_transid,
                     jlv_transid,
                     jba_tbldesc,
                     j_keys);
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
-      lv_error = RET_EXCEPTION;
-   }
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     return RET_EXCEPTION;
+  }
 
    _tlp_jenv->DeleteLocalRef(jba_tbldesc);
    _tlp_jenv->DeleteLocalRef(j_keys);
@@ -929,7 +891,6 @@ int CHbaseTM::alterTable(int64 pv_transid,
    HBASETrace(HBASETM_TraceExitError,
               (HDR "CHbaseTM::createTable returning %d.\n", lv_error));
 
-   jthrowable exc;
    JOI_RetCode lv_joi_retcode = JOI_OK;
    lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
    if (lv_joi_retcode != JOI_OK) {
@@ -951,11 +912,9 @@ int CHbaseTM::alterTable(int64 pv_transid,
                     jlv_transid,
                     jba_tblname,
                     j_tblopts);
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
-      lv_error = RET_EXCEPTION;
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      return RET_EXCEPTION;
    }
 
    _tlp_jenv->DeleteLocalRef(jba_tblname);
@@ -983,7 +942,6 @@ int CHbaseTM::regTruncateOnAbort(int64 pv_transid,
    HBASETrace(HBASETM_TraceExitError,
               (HDR "CHbaseTM::regTruncateOnAbort returning %d.\n", lv_error));
 
-   jthrowable exc;
    JOI_RetCode lv_joi_retcode = JOI_OK;
    lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
    if (lv_joi_retcode != JOI_OK) {
@@ -1001,13 +959,10 @@ int CHbaseTM::regTruncateOnAbort(int64 pv_transid,
                     JavaMethods_[JM_REGTRUNCABORT].methodID,
                     jlv_transid,
                     jba_tblname);
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
-      lv_error = RET_EXCEPTION;
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      return RET_EXCEPTION;
    }
-
    _tlp_jenv->DeleteLocalRef(jba_tblname);
 
    HBASETrace(HBASETM_TraceExit, (HDR "CHbaseTM::regTruncateOnAbort : Error %d, Txn ID (%d,%d), hostname %s.\n",
@@ -1032,7 +987,6 @@ int CHbaseTM::dropTable(int64 pv_transid,
    HBASETrace(HBASETM_TraceExitError,
               (HDR "CHbaseTM::dropTable returning %d.\n", lv_error));
 
-   jthrowable exc;
    JOI_RetCode lv_joi_retcode = JOI_OK;
    lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
    if (lv_joi_retcode != JOI_OK) {
@@ -1050,11 +1004,9 @@ int CHbaseTM::dropTable(int64 pv_transid,
                     JavaMethods_[JM_DROPTABLE].methodID,
                     jlv_transid,
                     jba_tblname);
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
-      lv_error = RET_EXCEPTION;
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      return RET_EXCEPTION;
    }
 
    _tlp_jenv->DeleteLocalRef(jba_tblname);
@@ -1146,7 +1098,6 @@ void CHbaseTM::shutdown()
 // Purpose: request region information to the hbase regions api's via hbase-trx client
 //------------------------------------------------------------------------------------
 HashMapArray* CHbaseTM::requestRegionInfo(){
-   jthrowable exc;
 
    JOI_RetCode lv_joi_retcode = JOI_OK;
    lv_joi_retcode = JavaObjectInterfaceTM::initJVM();
@@ -1156,10 +1107,8 @@ HashMapArray* CHbaseTM::requestRegionInfo(){
       abort();
    }
    jobject jHashMapArray = _tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_RQREGINFO].methodID);
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
       return NULL;
    }
 
@@ -1222,12 +1171,9 @@ HMN_RetCode HashMapArray::init()
 
 char* HashMapArray::get(int tid)
 {
-   jthrowable exc;
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET].methodID, tid));
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
       return NULL;
    }
    if(js_val == NULL){
@@ -1242,15 +1188,11 @@ char* HashMapArray::get(int tid)
 
 char* HashMapArray::getTableName(int tid)
 {
-   jthrowable exc;
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_TNAME].methodID, tid));
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
       return NULL;
    }
-
    if(js_val == NULL){
         printf("hbasetm::HashMapArray::getTableName - js_val is NULL");
        return NULL;
@@ -1263,15 +1205,11 @@ char* HashMapArray::getTableName(int tid)
 
 char* HashMapArray::getEncodedRegionName(int tid)
 {
-   jthrowable exc;
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_ENCREGNAME].methodID, tid));
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
       return NULL;
    }
-
    if(js_val == NULL){
        printf("hbasetm.cpp::HashMapArray::getEncodedRegionName - js_val is NULL");
        return NULL;
@@ -1284,12 +1222,9 @@ char* HashMapArray::getEncodedRegionName(int tid)
 
 char* HashMapArray::getRegionName(int tid)
 {
-   jthrowable exc;
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_REGNAME].methodID, tid));
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
       return NULL;
    }
 
@@ -1305,15 +1240,11 @@ char* HashMapArray::getRegionName(int tid)
 
 char* HashMapArray::getRegionOfflineStatus(int tid)
 {
-   jthrowable exc;
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_OFFLINE].methodID, tid));
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
       return NULL;
    }
-
    if(js_val == NULL){
        printf("hbasetm.cpp::HashMapArray::getRegionOfflineStatus - js_val is NULL");
        return NULL;
@@ -1326,15 +1257,11 @@ char* HashMapArray::getRegionOfflineStatus(int tid)
 
 char* HashMapArray::getRegionId(int tid)
 {
-   jthrowable exc;
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_REGID].methodID, tid));
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
       return NULL;
    }
-
    if(js_val == NULL){
        printf("hbasetm.cpp::HashMapArray::getRegionId - js_val is NULL");
        return NULL;
@@ -1347,15 +1274,11 @@ char* HashMapArray::getRegionId(int tid)
 
 char* HashMapArray::getHostName(int tid)
 {
-   jthrowable exc;
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_HOSTNAME].methodID, tid));
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
       return NULL;
    }
-
    if(js_val == NULL){
        printf("hbasetm.cpp::HashMapArray::getHostName - js_val is NULL");
        return NULL;
@@ -1368,12 +1291,9 @@ char* HashMapArray::getHostName(int tid)
 
 char* HashMapArray::getPort(int tid)
 {
-   jthrowable exc;
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_PORT].methodID, tid));
-   exc = _tlp_jenv->ExceptionOccurred();
-   if(exc) {
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
+   if (getExceptionDetails(NULL)) {
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
       return NULL;
    }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8bd91508/core/sqf/src/seatrans/tm/hbasetmlib2/javaobjectinterfacetm.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/javaobjectinterfacetm.cpp b/core/sqf/src/seatrans/tm/hbasetmlib2/javaobjectinterfacetm.cpp
index 2293969..e6b926a 100755
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/javaobjectinterfacetm.cpp
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/javaobjectinterfacetm.cpp
@@ -47,6 +47,13 @@ static const char* const joiErrorEnumStr[] =
 
 __thread JNIEnv* _tlp_jenv = 0;
 __thread bool  _tlv_jenv_set = false;
+__thread std::string *_tlp_error_msg = NULL;
+
+jclass JavaObjectInterfaceTM::gThrowableClass = NULL;
+jclass JavaObjectInterfaceTM::gStackTraceClass = NULL;
+jmethodID JavaObjectInterfaceTM::gGetStackTraceMethodID = NULL;
+jmethodID JavaObjectInterfaceTM::gThrowableToStringMethodID = NULL;
+jmethodID JavaObjectInterfaceTM::gStackFrameToStringMethodID = NULL;
 
 //////////////////////////////////////////////////////////////////////////////
 // 
@@ -213,13 +220,11 @@ JOI_RetCode JavaObjectInterfaceTM::initJVM()
       result = createJVM();
       if (result != JNI_OK)
         return JOI_ERROR_CREATE_JVM;
-        
       needToDetach_ = false;
         
-      return JOI_OK;
     }
   }
-  
+  if (_tlp_jenv == NULL) {
   // We found a JVM, can we use it?
   result = jvm_->GetEnv((void**) &_tlp_jenv, JNI_VERSION_1_6);
   switch (result)
@@ -247,8 +252,36 @@ JOI_RetCode JavaObjectInterfaceTM::initJVM()
       return JOI_ERROR_ATTACH_JVM;
       break;
   }
-
   _tlv_jenv_set = true;
+  }
+  jclass lJavaClass;
+  if (gThrowableClass == NULL)
+  {
+     lJavaClass = _tlp_jenv->FindClass("java/lang/Throwable");
+     if (lJavaClass != NULL)
+     {
+        gThrowableClass  = (jclass)_tlp_jenv->NewGlobalRef(lJavaClass);
+        _tlp_jenv->DeleteLocalRef(lJavaClass);
+        gGetStackTraceMethodID  = _tlp_jenv->GetMethodID(gThrowableClass,
+                      "getStackTrace",
+                      "()[Ljava/lang/StackTraceElement;");
+        gThrowableToStringMethodID = _tlp_jenv->GetMethodID(gThrowableClass,
+                      "toString",
+                      "()Ljava/lang/String;");
+     }
+  }
+  if (gStackTraceClass == NULL)
+  {
+     lJavaClass =  (jclass)_tlp_jenv->FindClass("java/lang/StackTraceElement");
+     if (lJavaClass != NULL)
+     {
+        gStackTraceClass = (jclass)_tlp_jenv->NewGlobalRef(lJavaClass);
+        _tlp_jenv->DeleteLocalRef(lJavaClass);
+        gStackFrameToStringMethodID  = _tlp_jenv->GetMethodID(gStackTraceClass,
+                      "toString",
+                      "()Ljava/lang/String;");
+     }
+  }  
   return JOI_OK;
 }
  
@@ -353,3 +386,87 @@ void JavaObjectInterfaceTM::logError(const char* cat, const char* file, int line
 {
 }
 
+
+bool  JavaObjectInterfaceTM::getExceptionDetails(JNIEnv *jenv)
+{
+   std::string *error_msg;
+
+   if (_tlp_error_msg != NULL)
+   {
+      delete _tlp_error_msg;
+      _tlp_error_msg = NULL;
+   }
+
+   if (jenv == NULL)
+       jenv = _tlp_jenv;
+   if (jenv == NULL)
+   {
+      error_msg = new std::string("Internal Error - Unable to obtain jenv");
+      _tlp_error_msg = error_msg;
+      return false;
+   }
+   if (gThrowableClass == NULL)
+   {
+      jenv->ExceptionDescribe();
+      error_msg = new std::string("Internal Error - Unable to find Throwable class");
+      _tlp_error_msg = error_msg;
+      return false;
+   }
+   jthrowable a_exception = jenv->ExceptionOccurred();
+   if (a_exception != NULL)
+       jenv->ExceptionClear();
+   else
+   {
+       error_msg = new std::string("No java exception was thrown");
+       _tlp_error_msg = error_msg;
+       return false;
+   }
+    jstring msg_obj =
+       (jstring) jenv->CallObjectMethod(a_exception,
+                                         gThrowableToStringMethodID);
+    const char *msg_str;
+    if (msg_obj != NULL)
+    {
+       msg_str = jenv->GetStringUTFChars(msg_obj, 0);
+       jenv->ReleaseStringUTFChars(msg_obj, msg_str);
+       jenv->DeleteLocalRef(msg_obj);
+    }
+    else
+       msg_str = "Exception is thrown, but tostring is null";
+
+    error_msg = new std::string("");
+    *error_msg += msg_str;
+
+    // Get the stack trace
+    jobjectArray frames =
+        (jobjectArray) jenv->CallObjectMethod(
+                                        a_exception,
+                                        gGetStackTraceMethodID);
+    if (frames == NULL)
+    {
+       _tlp_error_msg = error_msg;
+       return true;
+    }
+    jsize frames_length = jenv->GetArrayLength(frames);
+
+    jsize i = 0;
+    for (i = 0; i < frames_length; i++)
+    {
+       jobject frame = jenv->GetObjectArrayElement(frames, i);
+       msg_obj = (jstring) jenv->CallObjectMethod(frame,
+                                            gStackFrameToStringMethodID);
+       if (msg_obj != NULL)
+       {
+          msg_str = jenv->GetStringUTFChars(msg_obj, 0);
+          *error_msg += "\n";
+          *error_msg += msg_str;
+          jenv->ReleaseStringUTFChars(msg_obj, msg_str);
+          jenv->DeleteLocalRef(msg_obj);
+          jenv->DeleteLocalRef(frame);
+       }
+    }
+    *error_msg += "\n";
+    _tlp_error_msg = error_msg;
+    return true;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8bd91508/core/sqf/src/seatrans/tm/hbasetmlib2/javaobjectinterfacetm.h
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/javaobjectinterfacetm.h b/core/sqf/src/seatrans/tm/hbasetmlib2/javaobjectinterfacetm.h
index 4ebca0c..3f8d41b 100755
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/javaobjectinterfacetm.h
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/javaobjectinterfacetm.h
@@ -32,6 +32,7 @@
 #include "dtm/tm_util.h"
 
 extern __thread JNIEnv* _tlp_jenv;
+extern __thread std::string *_tlp_error_msg;
 
 // This structure defines the information needed for each java method used.
 struct JavaMethodInit {
@@ -140,6 +141,7 @@ public:
   {
     return isInitialized_;
   }
+  bool getExceptionDetails(JNIEnv *jenv);
   
 protected:
   static JavaVM*   jvm_;
@@ -149,6 +151,11 @@ protected:
   bool      isHBaseCompatibilityMode_;
   int       debugPort_;
   int       debugTimeout_;
+  static jclass gThrowableClass;
+  static jclass gStackTraceClass;
+  static jmethodID gGetStackTraceMethodID;
+  static jmethodID gThrowableToStringMethodID;
+  static jmethodID gStackFrameToStringMethodID;
 };
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8bd91508/core/sqf/src/tm/tminfo.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/tminfo.cpp b/core/sqf/src/tm/tminfo.cpp
index 8755e81..4c5574d 100644
--- a/core/sqf/src/tm/tminfo.cpp
+++ b/core/sqf/src/tm/tminfo.cpp
@@ -922,7 +922,6 @@ void TM_Info::initialize()
 
     if (lv_error == 0)
        lv_test_pause_state = atoi(la_value);
-     }
 
      switch (lv_test_pause_state)
      {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8bd91508/core/sqf/src/tm/tmlogging.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/tmlogging.cpp b/core/sqf/src/tm/tmlogging.cpp
index e79d4ff..9892d3e 100644
--- a/core/sqf/src/tm/tmlogging.cpp
+++ b/core/sqf/src/tm/tmlogging.cpp
@@ -48,6 +48,7 @@ int tm_init_logging()
 int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string)
 {
     int    lv_err = 0;
+    lv_err = tm_log_stdout(pv_event_type, pv_severity, pp_string);
     return lv_err;
 }
 
@@ -284,8 +285,8 @@ int tm_log_stdout(int event_id,
        printf(", data4=%u",data4);
     printf("\n");
 
-	// Log4cxx logging
-	CommonLogger::log(TM_COMPONENT, ll_severity, "Node Number: %u, CPU: %u, PIN: %u , Process Name: %s,,, Message: %s", my_nid, my_nid, my_pid, my_name, temp_string);
+    // Log4cxx logging
+    CommonLogger::log(TM_COMPONENT, ll_severity, "Node Number: %u, PIN: %u , Process Name: %s, Message: %s ", my_nid, my_pid, my_name, temp_string);
 
     return error;
 } 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8bd91508/core/sqf/src/tm/tools/Makefile
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/tools/Makefile b/core/sqf/src/tm/tools/Makefile
index 93aa948..4875eca 100644
--- a/core/sqf/src/tm/tools/Makefile
+++ b/core/sqf/src/tm/tools/Makefile
@@ -43,7 +43,7 @@ endif
 
 CFILES		= `ls *.c`
 ifeq ($(USE_LOGGING),1)
-LIBSX		= -L$(LIBEXPDIR) -levlsq
+LIBSX		= -L$(LIBEXPDIR) -levlsq -lshbasetmlib
 endif
 
 #TESTAROBJS        = adp_read_test.o \
@@ -56,12 +56,12 @@ PROGS = dtmci \
 
 all:   $(PROGS)
 
-dtmci: $(OUTDIR)/dtmci.o $(OUTDIR)/versdtmci.o
-	$(CXX) $(CXXFLAGS) -o $@ $(OUTDIR)/dtmci.o $(OUTDIR)/versdtmci.o $(LIBSTM)
+dtmci: $(OUTDIR)/dtmci.o $(OUTDIR)/versdtmci.o $(LIBEXPDIR)/libshbasetmlib.so
+	$(CXX) $(CXXFLAGS) -o $@ $(OUTDIR)/dtmci.o $(OUTDIR)/versdtmci.o $(LIBSTM) -lshbasetmlib 
 	cp -fup dtmci $(BINEXPDIR)
 
-tmshutdown: $(OUTDIR)/tmshutdown.o $(OUTDIR)/verstmshutdown.o
-	$(CXX) $(CXXFLAGS) -o $@ $(OUTDIR)/tmshutdown.o $(OUTDIR)/verstmshutdown.o $(LIBSTM) 
+tmshutdown: $(OUTDIR)/tmshutdown.o $(OUTDIR)/verstmshutdown.o $(LIBEXPDIR)/libshbasetmlib.so
+	$(CXX) $(CXXFLAGS) -o $@ $(OUTDIR)/tmshutdown.o $(OUTDIR)/verstmshutdown.o $(LIBSTM)  -lshbasetmlib
 	cp -fup tmshutdown $(BINEXPDIR)
 
 


[4/4] incubator-trafodion git commit: Merge [TRAFODION-1988] PR 604 Better java exception handling, part 3

Posted by db...@apache.org.
Merge [TRAFODION-1988] PR 604 Better java exception handling, part 3


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/c397bbe1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/c397bbe1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/c397bbe1

Branch: refs/heads/master
Commit: c397bbe10fca744d2cf1fbc115227e560883bce3
Parents: a82b4e3 97294fe
Author: Dave Birdsall <db...@apache.org>
Authored: Mon Jul 25 16:33:18 2016 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Mon Jul 25 16:33:18 2016 +0000

----------------------------------------------------------------------
 .../export/include/common/evl_sqlog_eventnum.h  |   1 +
 core/sqf/src/seatrans/tm/hbasetmlib2/Makefile   |   2 +-
 .../sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp | 222 ++++--------
 .../src/seatrans/tm/hbasetmlib2/hbasetmglob.h   |   2 +-
 .../seatrans/tm/hbasetmlib2/hbasetmlogging.h    |  33 --
 .../tm/hbasetmlib2/javaobjectinterfacetm.cpp    | 125 ++++++-
 .../tm/hbasetmlib2/javaobjectinterfacetm.h      |   7 +
 .../sqf/src/seatrans/tm/hbasetmlib2/testrun.cpp |   4 +-
 core/sqf/src/seatrans/tm/macros.gmk             |   2 +-
 core/sqf/src/tm/Makefile                        |  11 +-
 core/sqf/src/tm/javaobjectinterfacetm.cpp       | 355 -------------------
 core/sqf/src/tm/javaobjectinterfacetm.h         | 154 --------
 core/sqf/src/tm/tminfo.cpp                      |   1 -
 core/sqf/src/tm/tmlib.cpp                       |  34 +-
 core/sqf/src/tm/tmlogging.cpp                   | 108 ++++--
 core/sqf/src/tm/tmlogging.h                     |   8 +-
 core/sqf/src/tm/tmlogginglib.cpp                |  55 ---
 core/sqf/src/tm/tools/Makefile                  |  10 +-
 core/sqf/src/tm/xarmlogging.cpp                 | 261 --------------
 19 files changed, 313 insertions(+), 1082 deletions(-)
----------------------------------------------------------------------



[2/4] incubator-trafodion git commit: [TRAFODION-1988] Better java exception handling in the java/JNI layer of Trafodion - Part3

Posted by db...@apache.org.
[TRAFODION-1988] Better java exception handling in the java/JNI
layer of Trafodion - Part3

Changes as per the review comments. Removed and cleanup the redundant
logging programs that was preventing the log4cxx to work properly.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/59cd8319
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/59cd8319
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/59cd8319

Branch: refs/heads/master
Commit: 59cd8319eca75486171dc7fc6f6c883dbace0fba
Parents: 8bd9150
Author: selvaganesang <se...@esgyn.com>
Authored: Fri Jul 22 02:24:00 2016 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Fri Jul 22 02:24:00 2016 +0000

----------------------------------------------------------------------
 core/sqf/src/seatrans/tm/hbasetmlib2/Makefile   |   2 +-
 .../sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp |  52 ++--
 .../src/seatrans/tm/hbasetmlib2/hbasetmglob.h   |   2 +-
 .../seatrans/tm/hbasetmlib2/hbasetmlogging.h    |  33 ---
 .../sqf/src/seatrans/tm/hbasetmlib2/testrun.cpp |   4 +-
 core/sqf/src/tm/Makefile                        |   8 +-
 core/sqf/src/tm/tmlogging.cpp                   |  12 +-
 core/sqf/src/tm/tmlogging.h                     |   5 +-
 core/sqf/src/tm/tmlogginglib.cpp                |  55 ----
 core/sqf/src/tm/xarmlogging.cpp                 | 261 -------------------
 10 files changed, 49 insertions(+), 385 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/59cd8319/core/sqf/src/seatrans/tm/hbasetmlib2/Makefile
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/Makefile b/core/sqf/src/seatrans/tm/hbasetmlib2/Makefile
index d4b220a..9dd0cd7 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/Makefile
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/Makefile
@@ -84,7 +84,7 @@ $(OUTDIR)/idtm.o: idtm.cpp
 test:   testrun
 
 testrun: testrun.cpp $(LIBEXPDIR)/libshbasetmlib.so
-	$(CXX) -g -o $@ -Wall $(LIBSTESTRUN) $(LIBJVM) $(LIBTMB) $(INCLUDES) testrun.cpp
+	$(CXX) -g -o $@ -Wall $(LIBSTESTRUN) $(LIBJVM) $(LIBTMB) -lstmlib $(INCLUDES) testrun.cpp
 
 setup:
 	@echo "OUTDIR =" $(OUTDIR)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/59cd8319/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp b/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
index e21ab1f..4f3039d 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
@@ -269,7 +269,7 @@ short CHbaseTM::initConnection(short pv_nid)
   jshort   jdtmid = pv_nid;
   jboolean jresult = _tlp_jenv->CallBooleanMethod(javaObj_, JavaMethods_[JM_INIT1].methodID, jdtmid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_SEA_SOFT_FAULT, SQ_LOG_CRIT, (char *) _tlp_error_msg->c_str());
+     tm_log_write(DTM_SEA_SOFT_FAULT, SQ_LOG_CRIT, (char *) _tlp_error_msg->c_str(), -1LL);
      return RET_EXCEPTION;
   }
   if (jresult == false)
@@ -291,7 +291,7 @@ short CHbaseTM::addControlPoint(){
 
   jlong jresult = _tlp_jenv->CallLongMethod(javaObj_, JavaMethods_[JM_CNTPOINT].methodID);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_SEA_SOFT_FAULT, SQ_LOG_CRIT, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_SEA_SOFT_FAULT, SQ_LOG_CRIT, (char *)_tlp_error_msg->c_str(), -1LL);
      return RET_EXCEPTION;
   }
   if (jresult == 0L) {
@@ -312,7 +312,7 @@ short CHbaseTM::beginTransaction(int64 *pp_transid) {
 
   jlong jresult = _tlp_jenv->CallLongMethod(javaObj_, JavaMethods_[JM_BEGIN].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), *pp_transid);
      return RET_EXCEPTION;
   }
   *pp_transid = (long)jresult;
@@ -332,7 +332,7 @@ short CHbaseTM::abortTransaction(int64 pv_transid) {
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_ABORT].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
   //  RET_NOTX means the transaction wasn't found by the HBase client code (trx).  This is ok here, it
@@ -358,7 +358,7 @@ short CHbaseTM::prepareCommit(int64 pv_transid) {
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_PRECOMMIT].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
 
@@ -385,7 +385,7 @@ short CHbaseTM::doCommit(int64 pv_transid) {
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_DOCOMMIT].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
 
@@ -416,7 +416,7 @@ short CHbaseTM::tryCommit(int64 pv_transid) {
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_TRYCOMMIT].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
 
@@ -443,7 +443,7 @@ short CHbaseTM::completeRequest(int64 pv_transid) {
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_COMPLETEREQUEST].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
 
@@ -652,7 +652,7 @@ int CHbaseTM::registerRegion(int64 pv_transid,
 					pv_startcode,
 					jba_regionInfo);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
   _tlp_jenv->DeleteLocalRef(jba_hostname);
@@ -733,7 +733,7 @@ int CHbaseTM::participatingRegions(int64 pv_transid)
 
    lv_participating = _tlp_jenv->CallIntMethod(javaObj_, JavaMethods_[JM_PARREGION].methodID, lv_transid_j);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
      lv_participatingCount = -1;
   }
    lv_participatingCount = lv_participating;
@@ -772,7 +772,7 @@ short CHbaseTM::stall(int where){
   cout << "CHbaseTM::stall called with: " << jiv_where << "\n";
   _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_STALL].methodID, jiv_where);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
      return RET_EXCEPTION;
   }
   return RET_OK;
@@ -791,7 +791,7 @@ short CHbaseTM::nodeDown(int32 nid){
   cout << "CHbaseTM::nodeDown called with nodeId " << jiv_nid << "\n";
   _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_NODEDOWN].methodID, jiv_nid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
      return RET_EXCEPTION;
   }
   return RET_OK;
@@ -811,7 +811,7 @@ short CHbaseTM::nodeUp(int32 nid){
   cout << "CHbaseTM::nodeUp called with: " << jiv_nid << "\n";
   _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_NODEUP].methodID, jiv_nid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
      return RET_EXCEPTION;
   }
   return RET_OK;
@@ -860,7 +860,7 @@ int CHbaseTM::createTable(int64 pv_transid,
                     jba_tbldesc,
                     j_keys);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
 
@@ -913,7 +913,7 @@ int CHbaseTM::alterTable(int64 pv_transid,
                     jba_tblname,
                     j_tblopts);
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
       return RET_EXCEPTION;
    }
 
@@ -960,7 +960,7 @@ int CHbaseTM::regTruncateOnAbort(int64 pv_transid,
                     jlv_transid,
                     jba_tblname);
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
       return RET_EXCEPTION;
    }
    _tlp_jenv->DeleteLocalRef(jba_tblname);
@@ -1005,7 +1005,7 @@ int CHbaseTM::dropTable(int64 pv_transid,
                     jlv_transid,
                     jba_tblname);
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
       return RET_EXCEPTION;
    }
 
@@ -1108,7 +1108,7 @@ HashMapArray* CHbaseTM::requestRegionInfo(){
    }
    jobject jHashMapArray = _tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_RQREGINFO].methodID);
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
 
@@ -1173,7 +1173,7 @@ char* HashMapArray::get(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1190,7 +1190,7 @@ char* HashMapArray::getTableName(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_TNAME].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1207,7 +1207,7 @@ char* HashMapArray::getEncodedRegionName(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_ENCREGNAME].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1224,7 +1224,7 @@ char* HashMapArray::getRegionName(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_REGNAME].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
 
@@ -1242,7 +1242,7 @@ char* HashMapArray::getRegionOfflineStatus(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_OFFLINE].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1259,7 +1259,7 @@ char* HashMapArray::getRegionId(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_REGID].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1276,7 +1276,7 @@ char* HashMapArray::getHostName(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_HOSTNAME].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1293,7 +1293,7 @@ char* HashMapArray::getPort(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_PORT].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str());
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/59cd8319/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetmglob.h
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetmglob.h b/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetmglob.h
index 9dcf89b..26dda8e 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetmglob.h
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetmglob.h
@@ -61,5 +61,5 @@ enum HBASETM_TraceMask
 //extern timeval gv_startTime;
 
 extern HBASETM_TraceMask gv_HBASETM_traceMask;  // HBase TM tracing Mask.  0 = no tracing (default)
-//extern int tm_log_write(int, int, char*);
+
 #endif //HBASETMGLOB_H_

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/59cd8319/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetmlogging.h
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetmlogging.h b/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetmlogging.h
deleted file mode 100644
index 1149811..0000000
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetmlogging.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-#ifndef __HBASETMLOGGING_H
-#define __HBASETMLOGGING_H
-
-// Empty shell for now.
-
-int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string) {return 0;}
-
-
-#endif
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/59cd8319/core/sqf/src/seatrans/tm/hbasetmlib2/testrun.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/testrun.cpp b/core/sqf/src/seatrans/tm/hbasetmlib2/testrun.cpp
index 38a11e1..2b3e6bd 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/testrun.cpp
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/testrun.cpp
@@ -24,7 +24,9 @@
 #include <sys/time.h>
 
 #include "hbasetm.h"
-#include "hbasetmlogging.h"
+
+// To avoid pulling in other .so
+int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string) {return 0;}
 
 // Define here because we don't have the TM.
 timeval gv_startTime;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/59cd8319/core/sqf/src/tm/Makefile
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/Makefile b/core/sqf/src/tm/Makefile
index 734653f..e12004f 100644
--- a/core/sqf/src/tm/Makefile
+++ b/core/sqf/src/tm/Makefile
@@ -51,13 +51,14 @@ LIBSTMOBJS = $(OUTDIR)/tmtransid.o \
 			 $(OUTDIR)/tmtransaction.o \
 			 $(OUTDIR)/tmlibtxn.o \
 			 $(OUTDIR)/tmlib.o \
-			 $(OUTDIR)/tmlogginglib.o \
+			 $(OUTDIR)/tmlogging.o \
 			 $(OUTDIR)/tmmap.o \
 			 $(OUTDIR)/tmmutex.o \
 			 $(OUTDIR)/tmregisterregion.o \
              $(OUTDIR)/tmddlrequests.o\
-		 	 $(OUTDIR)/javaobjectinterfacetm.o \
-			 $(OUTDIR)/versstmlib.o 
+ 			 $(OUTDIR)/javaobjectinterfacetm.o \
+			 $(OUTDIR)/versstmlib.o \
+		         $(OUTDIR)/CommonLogger.o 
 LIBSXATMOBJS  = $(OUTDIR)/tmmap.o \
 				$(OUTDIR)/tmmmap.o \
                 $(OUTDIR)/tmmutex.o \
@@ -83,7 +84,6 @@ LIBXARMOBJS	= $(OUTDIR)/tmmap.o \
 		      $(OUTDIR)/xatmmsg.o \
 		      $(OUTDIR)/xarmapi.o \
 			  $(OUTDIR)/xatmapi.o \
-		      $(OUTDIR)/xarmlogging.o \
 		      $(OUTDIR)/tmregistry.o \
               $(OUTDIR)/tmtimer.o \
 		      $(OUTDIR)/verssxarmlib.o

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/59cd8319/core/sqf/src/tm/tmlogging.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/tmlogging.cpp b/core/sqf/src/tm/tmlogging.cpp
index 9892d3e..ebd524c 100644
--- a/core/sqf/src/tm/tmlogging.cpp
+++ b/core/sqf/src/tm/tmlogging.cpp
@@ -45,6 +45,13 @@ int tm_init_logging()
     return gv_dual_logging; 
 }
 
+int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string, long transid)
+{
+    int    lv_err = 0;
+    lv_err = tm_log_stdout(pv_event_type, pv_severity, pp_string, -1, transid);
+    return lv_err;
+}
+
 int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string)
 {
     int    lv_err = 0;
@@ -142,7 +149,7 @@ int tm_log_event(int event_id,
     {   
         char la_buf[DTM_STRING_BUF_SIZE];
         strncpy (la_buf, temp_string, DTM_STRING_BUF_SIZE - 1);
-        tm_log_stdout(event_id, severity, la_buf, error_code, rmid, dtmid, seq_num, msgid, xa_error,
+        tm_log_stdout(event_id, severity, la_buf, error_code, -1, rmid, dtmid, seq_num, msgid, xa_error,
                       pool_size, pool_elems, msg_retries, pool_high, pool_low, pool_max, tx_state,
                       data, data1, data2, string1, node, msgid2, offset, tm_event_msg, data4);
     }
@@ -155,6 +162,7 @@ int tm_log_stdout(int event_id,
                  posix_sqlog_severity_t severity, 
                  const char *temp_string,
                  int error_code,
+                 int64 transid,
                  int rmid,
                  int dtmid,
                  int seq_num,
@@ -286,7 +294,7 @@ int tm_log_stdout(int event_id,
     printf("\n");
 
     // Log4cxx logging
-    CommonLogger::log(TM_COMPONENT, ll_severity, "Node Number: %u, PIN: %u , Process Name: %s, Message: %s ", my_nid, my_pid, my_name, temp_string);
+    CommonLogger::log(TM_COMPONENT, ll_severity, "Node Number: %u, PIN: %u , Process Name: %s, TMID: %Ld Message: %s ", my_nid, my_pid, my_name, transid, temp_string);
 
     return error;
 } 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/59cd8319/core/sqf/src/tm/tmlogging.h
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/tmlogging.h b/core/sqf/src/tm/tmlogging.h
index b354516..954e5af 100644
--- a/core/sqf/src/tm/tmlogging.h
+++ b/core/sqf/src/tm/tmlogging.h
@@ -33,6 +33,8 @@ int tm_init_logging();
 
 int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string);
 
+int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string, long transid);
+
 int tm_alt_log_write(int eventType, posix_sqlog_severity_t severity, char *msg);
 
 int tm_log_event(int event_type, 
@@ -65,7 +67,8 @@ int tm_log_stdout
                 (int event_type, 
                  posix_sqlog_severity_t severity,
                  const char *temp_string, 
-                 int error_code = -1, // 1
+                 int error_code = -1, // 0
+                 int64 transid = -1,  // 1
                  int rmid = -1,       // 2
                  int dtmid = -1,      // 3
                  int seq_num = -1,    // 4

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/59cd8319/core/sqf/src/tm/tmlogginglib.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/tmlogginglib.cpp b/core/sqf/src/tm/tmlogginglib.cpp
deleted file mode 100644
index ff9b37e..0000000
--- a/core/sqf/src/tm/tmlogginglib.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-#include "tminfo.h"
-#include "tmlogging.h"
-
-
-
-int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string)
-{
-    size_t lv_buf_size = DTM_EVENT_BUF_SIZE;
-    int    lv_err;
-    char   lp_event_buf[DTM_EVENT_BUF_SIZE];
-    char  *lp_pbuf = lp_event_buf;
-  
-    // init log buffer
-    lv_err = evl_sqlog_init(lp_pbuf, lv_buf_size);
-    if (lv_err)
-        return lv_err;      
-
-    // add our string
-    lv_err = evl_sqlog_add_token(lp_pbuf, TY_STRING, pp_string);
-
-    if (!lv_err)
-    { 
-        // ok to log buffer.
-        // we need to translate category to sql_evl severity
-        // facility is common for sql.
-
-        lv_err = evl_sqlog_write((posix_sqlog_facility_t)SQ_LOG_SEAQUEST, pv_event_type, 
-                                  pv_severity, lp_event_buf);
-    }
-
-    return lv_err;
-}
-
-

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/59cd8319/core/sqf/src/tm/xarmlogging.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/xarmlogging.cpp b/core/sqf/src/tm/xarmlogging.cpp
deleted file mode 100644
index c76aadc..0000000
--- a/core/sqf/src/tm/xarmlogging.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-//------------------------------------------------------------------
-//
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-#include <sys/time.h>
-#include "common/evl_sqlog_eventnum.h"
-
-#include "tminfo.h"
-#include "tmlogging.h"
-#include "seabed/logalt.h"
-
-int gv_dual_logging =1; // Write to both SeaLog and stdout by default
-
-int tm_init_logging()
-{
-    ms_getenv_int ("TM_DUAL_LOGGING", &gv_dual_logging);
-    return gv_dual_logging; 
-}
-
-int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string)
-{
-    int    lv_err = 0;
-    return lv_err;
-}
-
-int tm_alt_log_write(int eventType, posix_sqlog_severity_t severity, char *msg) {
-    static int logFileType = SBX_LOG_TYPE_LOGFILE;
-    static char startTimeFmt[20] = "";
-
-    char   logFileDir[PATH_MAX];
-    char  *logFileDirPtr;
-    char   logFilePrefix[25];
-    char  *rootDir;
-
-    struct timeval startTime;
-    struct tm * ltime;
-
-    if ((logFileType&SBX_LOG_TYPE_LOGFILE_PERSIST) != SBX_LOG_TYPE_LOGFILE_PERSIST)
-    {
-        // getting date time for log file name
-        gettimeofday(&startTime, NULL);
-        ltime = localtime(&startTime.tv_sec);
-        sprintf(startTimeFmt, "%02d%02d%02d.%02d.%02d.%02d", ltime->tm_mon+1, ltime->tm_mday, ltime->tm_year-100, ltime->tm_hour, ltime->tm_min, ltime->tm_sec);
-    }
-
-    // directory to write log file
-    rootDir = getenv("MY_SQROOT");
-    if (rootDir == NULL)
-    {
-        logFileDirPtr = NULL;
-    }
-    else
-    {
-        sprintf(logFileDir, "%s/logs", rootDir);
-        logFileDirPtr = logFileDir;
-    }
-
-    // log file prefix will be tm.<date>.hh.mm.ss
-    sprintf(logFilePrefix, "tm.%s", (char *)&startTimeFmt);
-
-    SBX_log_write(logFileType,             // log_type
-                  logFileDirPtr,           // log_file_dir
-                  logFilePrefix,           // log_file_prefix
-                  SQEVL_DTM,               // component id
-                  eventType,               // event id
-                  SQ_LOG_SEAQUEST,         // facility
-                  severity,                // severity
-                  "TM",                    // name
-                  NULL,                    // msg_prefix
-                  msg,                     // msg
-                  NULL,                    // snmptrap_cmd
-                  NULL,                    // msg_snmptrap
-                  NULL,                    // msg_ret
-                  0);                      // msg_ret size
-
-    // write to the same file in future without opening and closing it.
-    if (logFileType == SBX_LOG_TYPE_LOGFILE)
-    {
-        logFileType |= SBX_LOG_TYPE_LOGFILE_PERSIST;
-    }
-    return 0;
-}
-
-int tm_log_event(int event_id, 
-                 posix_sqlog_severity_t severity, 
-                 const char *temp_string,
-                 int error_code,
-                 int rmid,
-                 int dtmid,
-                 int seq_num,
-                 int msgid,
-                 int xa_error,
-                 int pool_size,
-                 int pool_elems,
-                 int msg_retries,
-                 int pool_high,
-                 int pool_low,
-                 int pool_max,
-                 int tx_state,
-                 int data,
-                 int data1, 
-                 int64 data2,
-                 const char *string1,   
-                 int node,
-                 int msgid2,
-                 int offset,
-                 int tm_event_msg,
-                 uint data4)
-
-{
-    int rc = 0;
-    if (gv_dual_logging)
-    {   
-        char la_buf[DTM_STRING_BUF_SIZE];
-        strncpy (la_buf, temp_string, DTM_STRING_BUF_SIZE - 1);
-        tm_log_stdout(event_id, severity, la_buf, error_code, rmid, dtmid, seq_num, msgid, xa_error,
-                      pool_size, pool_elems, msg_retries, pool_high, pool_low, pool_max, tx_state,
-                      data, data1, data2, string1, node, msgid2, offset, tm_event_msg, data4);
-    }
-   return rc;
-}
-
-
-int tm_log_stdout(int event_id, 
-                 posix_sqlog_severity_t severity, 
-                 const char *temp_string,
-                 int error_code,
-                 int rmid,
-                 int dtmid,
-                 int seq_num,
-                 int msgid,
-                 int xa_error,
-                 int pool_size,
-                 int pool_elems,
-                 int msg_retries,
-                 int pool_high,
-                 int pool_low,
-                 int pool_max,
-                 int tx_state,
-                 int data,
-                 int data1, 
-                 int64 data2,
-                 const char *string1,   
-                 int node,
-                 int msgid2,
-                 int offset,
-                 int tm_event_msg,
-                 uint data4)
-
-{
-    time_t    current_time;
-    char      timestamp[50];
-
-    char      my_name[MS_MON_MAX_PROCESS_NAME];
-    int       my_nid,my_pid;
-    int       error;
-
-    current_time = time(NULL);
-    ctime_r(&current_time,timestamp);
-    timestamp[strlen(timestamp)-1] = '\0';
-
-    printf("%s  ", timestamp);
-
-    error = msg_mon_get_my_process_name( my_name, sizeof(my_name) );
-    if (!error)
-    {
-      error = msg_mon_get_process_info( my_name, &my_nid, &my_pid );
-      if (!error)
-         printf("(%s,%u,%u) ",my_name,my_nid,my_pid);
-      else
-      {
-         my_nid = -1; 
-         my_pid = -1;
-      }
-    }
-    else
-      strcpy(my_name, "UNKNOWN");
-
-
-    printf("Event %s(%d), Sev ", temp_string, event_id);
-    switch (severity)
-    {
-    case SQ_LOG_EMERG: printf("EMERGENCY"); break;
-    case SQ_LOG_ALERT: printf("ALERT"); break;
-    case SQ_LOG_CRIT: printf("CRITICAL"); break;
-    case SQ_LOG_ERR: printf("ERROR"); break;
-    case SQ_LOG_WARNING: printf("WARNING"); break;
-    case SQ_LOG_NOTICE: printf("NOTICE"); break;
-    case SQ_LOG_INFO: printf("INFO"); break;
-    case SQ_LOG_DEBUG: printf("DEBUG"); break;
-    default: printf("%d Unknown", severity);
-    }
-    printf(", ");
-
-    if (error_code != -1)
-       printf(", Error=%d",error_code);
-    if (rmid != -1)
-       printf(", rmid=%d",rmid);
-    if (dtmid != -1)
-       printf(", dtmid=%d",dtmid);
-    if (seq_num != -1)
-       printf(", seqnum=%d",seq_num);
-    if (msgid != -1)
-       printf(", msgid=%d",msgid);
-    if (xa_error != -1)
-       printf(", XAERR=%d",xa_error);
-    if (pool_size != -1)
-       printf(", pool_size=%d",pool_size);
-    if (pool_elems != -1)
-       printf(", elements in pool=%d",pool_elems);
-    if (msg_retries != -1)
-       printf(", msg retries=%d",msg_retries);
-    if (pool_high != -1)
-       printf(", pool_high_ss=%d",pool_high);
-    if (pool_low != -1)
-       printf(", pool_low_ss=%d",pool_low);
-    if (pool_max != -1)
-       printf(", pool_max_size=%d",pool_max);
-    if (tx_state != -1)
-       printf(", Txn State=%d",tx_state);
-    if (data != -1)
-       printf(", data=%d",data);
-    if (data1 != -1)
-       printf(", data1=%d",data1);
-    if (data2 != -1)
-       printf(", data2=" PFLL,data2);
-    if (string1 != NULL)
-       printf(", string1=%s",string1);
-    if (node != -1)
-       printf(", node=%d",node);
-    if (msgid2 != -1)
-       printf(", msgid2=%d",msgid2);
-    if (offset != -1)
-       printf(", offset=%d",offset);
-    if (tm_event_msg != -1)
-       printf(", tm_event_msg=%d",tm_event_msg);
-    if (data4 != 0)
-       printf(", data4=%u",data4);
-    printf("\n");
-
-    return error;
-} 


[3/4] incubator-trafodion git commit: [TRAFODION-1988] Better java exception handling in the java/JNI layer of Trafodion - Part3

Posted by db...@apache.org.
[TRAFODION-1988] Better java exception handling in the java/JNI
    layer of Trafodion - Part3

More cleanup of the TM libraries and log4cxx is now enabled
correctly in TM process.

Java exceptions reaching the TM process will be logged via log4cxx
into tm_<nid>.log files.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/97294fe0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/97294fe0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/97294fe0

Branch: refs/heads/master
Commit: 97294fe08f5636b3f57b4d0decb4845872f45585
Parents: 59cd831
Author: selvaganesang <se...@esgyn.com>
Authored: Fri Jul 22 20:40:55 2016 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Fri Jul 22 20:40:55 2016 +0000

----------------------------------------------------------------------
 .../sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp |  52 +--
 core/sqf/src/seatrans/tm/macros.gmk             |   2 +-
 core/sqf/src/tm/Makefile                        |   3 +
 core/sqf/src/tm/javaobjectinterfacetm.cpp       | 355 -------------------
 core/sqf/src/tm/javaobjectinterfacetm.h         | 154 --------
 core/sqf/src/tm/tmlib.cpp                       |  34 +-
 core/sqf/src/tm/tmlogging.cpp                   | 111 ++++--
 core/sqf/src/tm/tmlogging.h                     |   7 +-
 8 files changed, 120 insertions(+), 598 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/97294fe0/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp b/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
index 4f3039d..89d117c 100644
--- a/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
+++ b/core/sqf/src/seatrans/tm/hbasetmlib2/hbasetm.cpp
@@ -269,7 +269,7 @@ short CHbaseTM::initConnection(short pv_nid)
   jshort   jdtmid = pv_nid;
   jboolean jresult = _tlp_jenv->CallBooleanMethod(javaObj_, JavaMethods_[JM_INIT1].methodID, jdtmid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_SEA_SOFT_FAULT, SQ_LOG_CRIT, (char *) _tlp_error_msg->c_str(), -1LL);
+     tm_log_write(DTM_SEA_SOFT_FAULT, SQ_LOG_CRIT, (char *)"CHbaseTM::initConnection()", (char *) _tlp_error_msg->c_str(), -1LL);
      return RET_EXCEPTION;
   }
   if (jresult == false)
@@ -291,7 +291,7 @@ short CHbaseTM::addControlPoint(){
 
   jlong jresult = _tlp_jenv->CallLongMethod(javaObj_, JavaMethods_[JM_CNTPOINT].methodID);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_SEA_SOFT_FAULT, SQ_LOG_CRIT, (char *)_tlp_error_msg->c_str(), -1LL);
+     tm_log_write(DTM_SEA_SOFT_FAULT, SQ_LOG_CRIT, (char *)"CHbaseTM::addControlPoint()", (char *)_tlp_error_msg->c_str(), -1LL);
      return RET_EXCEPTION;
   }
   if (jresult == 0L) {
@@ -312,7 +312,7 @@ short CHbaseTM::beginTransaction(int64 *pp_transid) {
 
   jlong jresult = _tlp_jenv->CallLongMethod(javaObj_, JavaMethods_[JM_BEGIN].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), *pp_transid);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::beginTransaction()", (char *)_tlp_error_msg->c_str(), *pp_transid);
      return RET_EXCEPTION;
   }
   *pp_transid = (long)jresult;
@@ -332,7 +332,7 @@ short CHbaseTM::abortTransaction(int64 pv_transid) {
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_ABORT].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::abortTransaction()", (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
   //  RET_NOTX means the transaction wasn't found by the HBase client code (trx).  This is ok here, it
@@ -358,7 +358,7 @@ short CHbaseTM::prepareCommit(int64 pv_transid) {
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_PRECOMMIT].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::prepareCommit()", (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
 
@@ -385,7 +385,7 @@ short CHbaseTM::doCommit(int64 pv_transid) {
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_DOCOMMIT].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::doCommit()", (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
 
@@ -416,7 +416,7 @@ short CHbaseTM::tryCommit(int64 pv_transid) {
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_TRYCOMMIT].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::tryCommit()", (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
 
@@ -443,7 +443,7 @@ short CHbaseTM::completeRequest(int64 pv_transid) {
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_COMPLETEREQUEST].methodID, jlv_transid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::completeRequest()", (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
 
@@ -652,7 +652,7 @@ int CHbaseTM::registerRegion(int64 pv_transid,
 					pv_startcode,
 					jba_regionInfo);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::registerRegion()", (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
   _tlp_jenv->DeleteLocalRef(jba_hostname);
@@ -733,7 +733,7 @@ int CHbaseTM::participatingRegions(int64 pv_transid)
 
    lv_participating = _tlp_jenv->CallIntMethod(javaObj_, JavaMethods_[JM_PARREGION].methodID, lv_transid_j);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::participatingRegions()", (char *)_tlp_error_msg->c_str(), pv_transid);
      lv_participatingCount = -1;
   }
    lv_participatingCount = lv_participating;
@@ -772,7 +772,7 @@ short CHbaseTM::stall(int where){
   cout << "CHbaseTM::stall called with: " << jiv_where << "\n";
   _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_STALL].methodID, jiv_where);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::stall()", (char *)_tlp_error_msg->c_str(), -1LL);
      return RET_EXCEPTION;
   }
   return RET_OK;
@@ -791,7 +791,7 @@ short CHbaseTM::nodeDown(int32 nid){
   cout << "CHbaseTM::nodeDown called with nodeId " << jiv_nid << "\n";
   _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_NODEDOWN].methodID, jiv_nid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::nodeDown()", (char *)_tlp_error_msg->c_str(), -1LL);
      return RET_EXCEPTION;
   }
   return RET_OK;
@@ -811,7 +811,7 @@ short CHbaseTM::nodeUp(int32 nid){
   cout << "CHbaseTM::nodeUp called with: " << jiv_nid << "\n";
   _tlp_jenv->CallShortMethod(javaObj_, JavaMethods_[JM_NODEUP].methodID, jiv_nid);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::nodeUp()", (char *)_tlp_error_msg->c_str(), -1LL);
      return RET_EXCEPTION;
   }
   return RET_OK;
@@ -860,7 +860,7 @@ int CHbaseTM::createTable(int64 pv_transid,
                     jba_tbldesc,
                     j_keys);
   if (getExceptionDetails(NULL)) {
-     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::createTable()", (char *)_tlp_error_msg->c_str(), pv_transid);
      return RET_EXCEPTION;
   }
 
@@ -913,7 +913,7 @@ int CHbaseTM::alterTable(int64 pv_transid,
                     jba_tblname,
                     j_tblopts);
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::alterTable()", (char *)_tlp_error_msg->c_str(), pv_transid);
       return RET_EXCEPTION;
    }
 
@@ -960,7 +960,7 @@ int CHbaseTM::regTruncateOnAbort(int64 pv_transid,
                     jlv_transid,
                     jba_tblname);
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::regTruncateOnAbort()", (char *)_tlp_error_msg->c_str(), pv_transid);
       return RET_EXCEPTION;
    }
    _tlp_jenv->DeleteLocalRef(jba_tblname);
@@ -1005,7 +1005,7 @@ int CHbaseTM::dropTable(int64 pv_transid,
                     jlv_transid,
                     jba_tblname);
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), pv_transid);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::dropTable()", (char *)_tlp_error_msg->c_str(), pv_transid);
       return RET_EXCEPTION;
    }
 
@@ -1108,7 +1108,7 @@ HashMapArray* CHbaseTM::requestRegionInfo(){
    }
    jobject jHashMapArray = _tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_RQREGINFO].methodID);
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"CHbaseTM::requestRegionInfo()", (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
 
@@ -1173,7 +1173,7 @@ char* HashMapArray::get(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"HashMapArray::get()", (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1190,7 +1190,7 @@ char* HashMapArray::getTableName(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_TNAME].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"HashMapArray::getTableName()", (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1207,7 +1207,7 @@ char* HashMapArray::getEncodedRegionName(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_ENCREGNAME].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"HashMapArray::getEncodedRegionName()", (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1224,7 +1224,7 @@ char* HashMapArray::getRegionName(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_REGNAME].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"HashMapArray::getRegionName()", (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
 
@@ -1242,7 +1242,7 @@ char* HashMapArray::getRegionOfflineStatus(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_OFFLINE].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"HashMapArray::getRegionOfflineStatus()", (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1259,7 +1259,7 @@ char* HashMapArray::getRegionId(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_REGID].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"HashMaparray::getRegionId()", (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1276,7 +1276,7 @@ char* HashMapArray::getHostName(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_HOSTNAME].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"HashMapArray::getHostName()", (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
    if(js_val == NULL){
@@ -1293,7 +1293,7 @@ char* HashMapArray::getPort(int tid)
 {
    jstring js_val = (jstring)(_tlp_jenv->CallObjectMethod(javaObj_, JavaMethods_[JM_GET_PORT].methodID, tid));
    if (getExceptionDetails(NULL)) {
-      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)_tlp_error_msg->c_str(), -1LL);
+      tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"HashMapArrray::getPort()", (char *)_tlp_error_msg->c_str(), -1LL);
       return NULL;
    }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/97294fe0/core/sqf/src/seatrans/tm/macros.gmk
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/tm/macros.gmk b/core/sqf/src/seatrans/tm/macros.gmk
index 6c67c8d..746323c 100644
--- a/core/sqf/src/seatrans/tm/macros.gmk
+++ b/core/sqf/src/seatrans/tm/macros.gmk
@@ -86,7 +86,7 @@ ifeq ($(SQ_USE_INTC),0)
 HPCWARN		= -Wno-unused-parameter
 HPCXXWARN	= -Wno-unused-parameter -Wno-non-virtual-dtor
 endif
-INCLUDES	= -I$(INCEXPDIR) -I$(INCMONDIR) -I$(TMINC) -I$(MY_SQROOT)/export/include -I$(MY_SPROOT)/export/include -I$(MY_SPROOT)/source/publications -I$(PROTOBUFS_INC) -I$(INC_JAVA) -I$(INC_JAVALINUX)
+INCLUDES	= -I$(INCEXPDIR) -I$(INCMONDIR) -I$(TMINC) -I$(MY_SQROOT)/export/include -I$(MY_SPROOT)/export/include -I$(MY_SPROOT)/source/publications -I$(PROTOBUFS_INC) -I$(INC_JAVA) -I$(INC_JAVALINUX) -I$(MY_SQROOT)/commonLogger
 
 LIBSSB         = -L$(JAVA_HOME)/jre/lib/i386/client -L$(JAVA_HOME)/jre/lib/amd64/server -L$(LIBEXPDIR) -ltmjni -ljvm
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/97294fe0/core/sqf/src/tm/Makefile
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/Makefile b/core/sqf/src/tm/Makefile
index e12004f..266af25 100644
--- a/core/sqf/src/tm/Makefile
+++ b/core/sqf/src/tm/Makefile
@@ -176,6 +176,9 @@ $(LIBEXPDIR)/libxarm.so: $(LIBXARMOBJS)
 $(OUTDIR)/CommonLogger.o: $(MY_SQROOT)/commonLogger/CommonLogger.cpp
 	$(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $<
 
+$(OUTDIR)/javaobjectinterfacetm.o: $(MY_SQROOT)/src/seatrans/tm/hbasetmlib2/javaobjectinterfacetm.cpp
+	$(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $<
+
 hbasetmlib:
 	cd $(HBASETMLIB); $(MAKE)
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/97294fe0/core/sqf/src/tm/javaobjectinterfacetm.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/javaobjectinterfacetm.cpp b/core/sqf/src/tm/javaobjectinterfacetm.cpp
deleted file mode 100644
index 2293969..0000000
--- a/core/sqf/src/tm/javaobjectinterfacetm.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-// **********************************************************************
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-// **********************************************************************
-
-#include "javaobjectinterfacetm.h"
-
-// ===========================================================================
-// ===== Class JavaObjectInterfaceTM
-// ===========================================================================
-
-JavaVM* JavaObjectInterfaceTM::jvm_  = NULL;
-
-#define DEFAULT_MAX_TM_HEAP_SIZE "2048" 
-#define USE_JVM_DEFAULT_MAX_HEAP_SIZE 0
-  
-static const char* const joiErrorEnumStr[] = 
-{
-  "All is well."
- ,"Error checking for existing JVMs"
- ,"Error attaching to a JVM of the wrong version"
- ,"Error attaching to an existing JVM"
- ,"Error creating a new JVM"
- ,"JNI FindClass() failed"
- ,"JNI GetMethodID() failed"
- ,"JNI NewObject() failed"
- ,"Error Unknown"
-};
-
-__thread JNIEnv* _tlp_jenv = 0;
-__thread bool  _tlv_jenv_set = false;
-
-//////////////////////////////////////////////////////////////////////////////
-// 
-//////////////////////////////////////////////////////////////////////////////
-char* JavaObjectInterfaceTM::getErrorText(JOI_RetCode errEnum)
-{
-   if (errEnum >= JOI_LAST) {
-      fprintf(stderr,"getErrorText called with out of bounds index %d.\n",errEnum);
-      fflush(stderr);
-      abort();
-      //return (char*)joiErrorEnumStr[JOI_LAST];
-   }
-   else
-      return (char*)joiErrorEnumStr[errEnum];
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// 
-//////////////////////////////////////////////////////////////////////////////
-JavaObjectInterfaceTM::~JavaObjectInterfaceTM()
-{
-   if (_tlp_jenv && javaObj_)
-      _tlp_jenv->DeleteGlobalRef(javaObj_);
-}
- 
-//////////////////////////////////////////////////////////////////////////////
-// 
-//////////////////////////////////////////////////////////////////////////////
-char* JavaObjectInterfaceTM::buildClassPath()
-{
-  char* classPath = getenv("CLASSPATH");
-  int32 size = strlen(classPath) + 1024;
-  char* classPathBuffer = (char*)malloc(size);
-  
-  strcpy(classPathBuffer, "-Djava.class.path=");
-  strcat(classPathBuffer, classPath);
-
-  return classPathBuffer;
-}
-
-int JavaObjectInterfaceTM::attachThread() {
-  
-      jint result = jvm_->AttachCurrentThread((void**) &_tlp_jenv, NULL);   
-      if (result != JNI_OK)
-        return JOI_ERROR_ATTACH_JVM;
-      
-//      needToDetach_ = true;
-      _tlv_jenv_set = true;
-      return JNI_OK;
-}
-
-int JavaObjectInterfaceTM::detachThread() {
-      jint result = jvm_->DetachCurrentThread();   
-      if (result != JNI_OK)
-        return JOI_ERROR_ATTACH_JVM;
-
-      _tlv_jenv_set = false;
-      _tlp_jenv = 0;
-      return JNI_OK;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// Create a new JVM instance.
-//////////////////////////////////////////////////////////////////////////////
-int JavaObjectInterfaceTM::createJVM()
-{
-  JavaVMInitArgs jvm_args;
-  JavaVMOption jvm_options[10];
-
-  char* classPathArg = buildClassPath();
-  char debugOptions[300];
-  int numJVMOptions = 0;
-
-  //printf("In JavaObjectInterfaceTM::createJVM\n");
-
-  const char *maxHeapSize = getenv("DTM_JVM_MAX_HEAP_SIZE_MB");  
-  char heapOptions[100];  
-  int heapSize;  
-  if (maxHeapSize == NULL) {  
-     maxHeapSize = DEFAULT_MAX_TM_HEAP_SIZE;  
-  }  
-  heapSize = atoi(maxHeapSize);  
-  if (heapSize != USE_JVM_DEFAULT_MAX_HEAP_SIZE) {  
-      sprintf(heapOptions, "-Xmx%sm", maxHeapSize);  
-      jvm_options[numJVMOptions++].optionString = heapOptions;  
-  }  
-
-  jvm_options[numJVMOptions++].optionString = classPathArg;
-  jvm_options[numJVMOptions++].optionString = (char *) "-XX:-LoopUnswitching";
-  //  jvm_options[numJVMOptions++].optionString = (char *) "-Xcheck:jni";
-
-  if (debugPort_ > 0)
-    {
-      sprintf(debugOptions,"-agentlib:jdwp=transport=dt_socket,address=%d,server=y,timeout=%d,suspend=y",
-                                                                       debugPort_,         debugTimeout_);
-      jvm_options[numJVMOptions++].optionString = debugOptions;
-    }
-  
-  jvm_args.version            = JNI_VERSION_1_6;
-  jvm_args.options            = jvm_options;
-  jvm_args.nOptions           = numJVMOptions;
-  jvm_args.ignoreUnrecognized = true;
-
-  int ret = JNI_CreateJavaVM(&jvm_, (void**)&_tlp_jenv, &jvm_args);
-  if (ret != 0) {
-    abort();
-  }
-  _tlv_jenv_set = true;
-  fflush(stdout);
-  free(classPathArg);
-  return ret;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// Create a new JVM instance, ready for attaching a debugger.
-//////////////////////////////////////////////////////////////////////////////
-int JavaObjectInterfaceTM::createJVM4Debug()
-{
-  JavaVMInitArgs jvm_args;
-  JavaVMOption jvm_options[3];
-
-  char* classPathArg = buildClassPath();
-  
-  jvm_options[0].optionString = classPathArg;
-  jvm_options[1].optionString = (char*)"-Xdebug";
-  jvm_options[2].optionString = (char*)"-Xrunjdwp:transport=dt_socket,address=8998,server=y";
-  
-  jvm_args.version            = JNI_VERSION_1_6;
-  jvm_args.options            = jvm_options;
-  jvm_args.nOptions           = 3;
-  jvm_args.ignoreUnrecognized = 1;
-
-  int ret = JNI_CreateJavaVM(&jvm_, (void**)&_tlp_jenv, &jvm_args);
-  if (ret != 0) {
-    abort();
-  }
-  _tlv_jenv_set = true;
-  free(classPathArg);
-  return ret;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// 
-//////////////////////////////////////////////////////////////////////////////
-JOI_RetCode JavaObjectInterfaceTM::initJVM()
-{
-  jint result;
-
-  if ((_tlp_jenv != 0) && (_tlv_jenv_set)) {
-    return JOI_OK;
-  }
-
-  if (jvm_ == NULL)
-  {
-    jsize jvm_count = 0;
-    // Is there an existing JVM already created?
-    result = JNI_GetCreatedJavaVMs (&jvm_, 1, &jvm_count);
-    if (result != JNI_OK)
-      return JOI_ERROR_CHECK_JVM;      
-      
-    if (jvm_count == 0)
-    {
-      // No - create a new one.
-      result = createJVM();
-      if (result != JNI_OK)
-        return JOI_ERROR_CREATE_JVM;
-        
-      needToDetach_ = false;
-        
-      return JOI_OK;
-    }
-  }
-  
-  // We found a JVM, can we use it?
-  result = jvm_->GetEnv((void**) &_tlp_jenv, JNI_VERSION_1_6);
-  switch (result)
-  {
-    case JNI_OK:
-      break;
-    
-    case JNI_EDETACHED:
-      fprintf(stderr,"initJVM: Detached, Try 2 attach\n");
-      result = jvm_->AttachCurrentThread((void**) &_tlp_jenv, NULL);   
-      if (result != JNI_OK)
-      {
-        fprintf(stderr,"initJVM: Error in attaching\n");
-        return JOI_ERROR_ATTACH_JVM;
-      }
-      
-      needToDetach_ = true;
-      break;
-       
-    case JNI_EVERSION:
-      return JOI_ERROR_JVM_VERSION;
-      break;
-      
-    default:
-      return JOI_ERROR_ATTACH_JVM;
-      break;
-  }
-
-  _tlv_jenv_set = true;
-  return JOI_OK;
-}
- 
-
-//////////////////////////////////////////////////////////////////////////////
-// 
-//////////////////////////////////////////////////////////////////////////////
-JOI_RetCode JavaObjectInterfaceTM::init(char*           className, 
-                                      jclass          &javaClass,
-                                      JavaMethodInit* JavaMethods, 
-                                      int32           howManyMethods,
-                                      bool            methodsInitialized)
-{
-  if (isInitialized_)
-    return JOI_OK;
-  
-  JOI_RetCode retCode = JOI_OK;
-    
-  // Make sure the JVM environment is set up correctly.
-  retCode = initJVM();
-  if (retCode != JOI_OK)
-    return retCode;
-        
-  if (methodsInitialized == false || javaObj_ == NULL)
-  {
-    // Initialize the class pointer
-    jclass javaClass = _tlp_jenv->FindClass(className); 
-    if (_tlp_jenv->ExceptionCheck()) 
-    {
-      fprintf(stderr,"FindClass failed. javaClass %p.\n", javaClass);
-      _tlp_jenv->ExceptionDescribe();
-      _tlp_jenv->ExceptionClear();
-      return JOI_ERROR_FINDCLASS;
-    }
-    
-    if (javaClass == 0) 
-    {
-      return JOI_ERROR_FINDCLASS;
-    }
-    
-    // Initialize the method pointers.
-    if (!methodsInitialized)
-    {
-      for (int i=0; i<howManyMethods; i++)
-      {
-        JavaMethods[i].methodID = _tlp_jenv->GetMethodID(javaClass, 
-                                                     JavaMethods[i].jm_name.data(), 
-                                                     JavaMethods[i].jm_signature.data());
-        if (JavaMethods[i].methodID == 0 || _tlp_jenv->ExceptionCheck())
-        { 
-          fprintf(stderr,"GetMethodID failed returning error. javaClass %p, i %d, "
-                 "name %s, signature %s.\n", javaClass, i, 
-                 JavaMethods[i].jm_name.data(), JavaMethods[i].jm_signature.data());
-          _tlp_jenv->ExceptionDescribe();
-          _tlp_jenv->ExceptionClear();
-          _tlp_jenv->DeleteLocalRef(javaClass);  
-          return JOI_ERROR_GETMETHOD;
-        }      
-      }
-    }
-    
-    if (javaObj_ == NULL)
-    {
-      // Allocate an object of the Java class, and call its constructor.
-      // The constructor must be the first entry in the methods array.
-      javaObj_ = _tlp_jenv->NewObject(javaClass, JavaMethods[0].methodID);
-      if (javaObj_ == 0 || _tlp_jenv->ExceptionCheck())
-      { 
-        _tlp_jenv->ExceptionDescribe();
-        _tlp_jenv->ExceptionClear();
-        _tlp_jenv->DeleteLocalRef(javaClass);  
-        return JOI_ERROR_NEWOBJ;
-      }
-      javaObj_ = _tlp_jenv->NewGlobalRef(javaObj_);
-    }
-       
-    _tlp_jenv->DeleteLocalRef(javaClass);  
-  }  
-  
-  isInitialized_ = true;
-  return JOI_OK;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// 
-//////////////////////////////////////////////////////////////////////////////
-void JavaObjectInterfaceTM::logError(const char* cat, const char* methodName, jstring jresult)
-{
-  if (jresult == NULL) {}
-  else
-  {
-    const char* char_result = _tlp_jenv->GetStringUTFChars(jresult, 0);
-    _tlp_jenv->ReleaseStringUTFChars(jresult, char_result);
-    _tlp_jenv->DeleteLocalRef(jresult);  
-  }
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// 
-//////////////////////////////////////////////////////////////////////////////
-void JavaObjectInterfaceTM::logError(const char* cat, const char* file, int line)
-{
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/97294fe0/core/sqf/src/tm/javaobjectinterfacetm.h
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/javaobjectinterfacetm.h b/core/sqf/src/tm/javaobjectinterfacetm.h
deleted file mode 100644
index 4ebca0c..0000000
--- a/core/sqf/src/tm/javaobjectinterfacetm.h
+++ /dev/null
@@ -1,154 +0,0 @@
-// **********************************************************************
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-// **********************************************************************
-#ifndef JNI_H
-#define JNI_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h> 
-#include <iostream>
-
-#include "jni.h"
-#include "dtm/tm_util.h"
-
-extern __thread JNIEnv* _tlp_jenv;
-
-// This structure defines the information needed for each java method used.
-struct JavaMethodInit {
-    std::string   jm_name;       // The method name.
-    std::string   jm_signature;  // The method signature.
-    jmethodID     methodID;      // The JNI methodID
-  };
-
-typedef enum {
-  JOI_OK = 0
- ,JOI_ERROR_CHECK_JVM           // Cannot check existing JVMs
- ,JOI_ERROR_JVM_VERSION         // Attaching to JVM of wrong version.
- ,JOI_ERROR_ATTACH_JVM          // Cannot attach to an existing JVM
- ,JOI_ERROR_CREATE_JVM          // Cannot create JVM
- ,JOI_ERROR_FINDCLASS           // JNI FindClass() failed
- ,JOI_ERROR_GETMETHOD           // JNI GetMethodID() failed
- ,JOI_ERROR_NEWOBJ              // JNI NewObject() failed
- ,JOI_LAST
-} JOI_RetCode;
-
-// ===========================================================================
-// ===== The JavaObjectInterfaceTM class defines an interface for using Java 
-// ===== objects.
-// ===== For each Java class, a new subclass of JavaObjectInterfaceTM should 
-// ===== be created.
-// ===========================================================================
-class JavaObjectInterfaceTM
-{
-protected:
-
-  // Default constructor - for creating a new JVM		
-  JavaObjectInterfaceTM(int debugPort = 0, int debugTimeout = 0)
-    : javaObj_(NULL)
-      ,needToDetach_(false)
-      ,isInitialized_(false)
-      ,isHBaseCompatibilityMode_(true)
-      ,debugPort_(debugPort)
-      ,debugTimeout_(debugTimeout)
-  {}
-
-#if 1 
-  // Constructor for reusing an existing JVM.
-  JavaObjectInterfaceTM(JavaVM *jvm, JNIEnv *jenv, jobject jObj = NULL)
-    : javaObj_(NULL)
-      ,needToDetach_(false)
-      ,isInitialized_(false)
-      ,isHBaseCompatibilityMode_(true)
-      ,debugPort_(0)
-      ,debugTimeout_(0)
-  {
-    _tlp_jenv = jenv;
-
-    if(jObj != NULL)
-       javaObj_ = _tlp_jenv->NewGlobalRef(jObj);
-    else
-       javaObj_ = jObj;
-  }
-#endif
-
-  // Destructor
-  virtual ~JavaObjectInterfaceTM();
-  
-  // Create a new JVM
-  int createJVM();
-  
-  // Create a new JVM for debugging the Java code
-  int createJVM4Debug();
-
-  
-  // Initialize the JVM.
-  JOI_RetCode    initJVM();
-  
-  // Initialize JVM and all the JNI configuration.
-  // Must be called.
-  JOI_RetCode    init(char* className, jclass &javaclass,  JavaMethodInit* JavaMethods, int32 howManyMethods, bool methodsInitialized);
-
-  // Get the error description.
-  virtual char* getErrorText(JOI_RetCode errEnum);
-
-  // Write the description of a Java error to the log file.
-  void logError(const char* cat, const char* methodName, jstring jresult);
-  void logError(const char* cat, const char* file, int line);
-
-  void setHBaseCompatibilityMode(bool val)
-  {
-    isHBaseCompatibilityMode_ = val;
-  }
-
-  bool isHBaseCompatibilityMode()
-  {
-    return isHBaseCompatibilityMode_;
-  }
-
-  char* buildClassPath();
-
-public:
-  int attachThread();
-  int detachThread();
-
-  jobject getJavaObject()
-  {
-    return javaObj_;
-  }
-  
-  bool isInitialized()
-  {
-    return isInitialized_;
-  }
-  
-protected:
-  static JavaVM*   jvm_;
-  jobject   javaObj_;
-  bool      needToDetach_;
-  bool      isInitialized_;
-  bool      isHBaseCompatibilityMode_;
-  int       debugPort_;
-  int       debugTimeout_;
-};
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/97294fe0/core/sqf/src/tm/tmlib.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/tmlib.cpp b/core/sqf/src/tm/tmlib.cpp
index cd6d434..b9ca476 100644
--- a/core/sqf/src/tm/tmlib.cpp
+++ b/core/sqf/src/tm/tmlib.cpp
@@ -3141,15 +3141,12 @@ short TMLIB::setupJNI()
 ///////////////////////////////////////////////
 short TMLIB::initConnection(short pv_nid)
 {
-  jthrowable exc;
   jshort   jdtmid = pv_nid;
   //sleep(30);
   _tlp_jenv->CallBooleanMethod(javaObj_, TMLibJavaMethods_[JM_INIT1].methodID, jdtmid);
-  exc = _tlp_jenv->ExceptionOccurred();
-  if(exc) {
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"TMLIB::initConnection()", (char *)_tlp_error_msg->c_str(), -1);
+     return RET_EXCEPTION;
   }
   // Ignore result and return JOI_OK
   return JOI_OK;
@@ -3172,12 +3169,11 @@ void TMLIB::cleanupTransactionLocal(long transactionID)
   }
 
   _tlp_jenv->CallStaticVoidMethod(iv_RMInterface_class, TMLibJavaMethods_[JM_CLEARTRANSACTIONSTATES].methodID, jlv_transid);
-  if(_tlp_jenv->ExceptionOccurred()){
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    fprintf(stderr,"clearTransactionStates raised an exception!\n");
-    fflush(stderr);
-    abort();
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"TMLIB::cleanupTransactionLocal()", (char *)_tlp_error_msg->c_str(), -1);
+     fprintf(stderr, "clearTransactionStates raised an exception!\n");
+     fflush(stderr);
+     abort();
   }
   return;
 } //cleanupTransactionLocal
@@ -3195,10 +3191,9 @@ short TMLIB::endTransactionLocal(long transactionID)
   }
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, TMLibJavaMethods_[JM_TRYCOMMIT].methodID, jlv_transid);
-  if(_tlp_jenv->ExceptionOccurred()){
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"TMLIB::endTransaction()", (char *)_tlp_error_msg->c_str(), -1);
+     return RET_EXCEPTION;
   }
 
   //  RET_NOTX means the transaction wasn't found by the HBase client code (trx).  This is ok here, it
@@ -3225,10 +3220,9 @@ short TMLIB::abortTransactionLocal(long transactionID)
   }
 
   jshort jresult = _tlp_jenv->CallShortMethod(javaObj_, TMLibJavaMethods_[JM_ABORT].methodID, jlv_transid);
-  if(_tlp_jenv->ExceptionOccurred()){
-    _tlp_jenv->ExceptionDescribe();
-    _tlp_jenv->ExceptionClear();
-    return RET_EXCEPTION;
+  if (getExceptionDetails(NULL)) {
+     tm_log_write(DTM_TM_JNI_ERROR, SQ_LOG_ERR, (char *)"TMLIB::abortTransaction()", (char *)_tlp_error_msg->c_str(), -1);
+     return RET_EXCEPTION;
   }
 
   //  RET_NOTX means the transaction wasn't found by the HBase client code (trx).  This is ok here, it

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/97294fe0/core/sqf/src/tm/tmlogging.cpp
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/tmlogging.cpp b/core/sqf/src/tm/tmlogging.cpp
index ebd524c..0dca85e 100644
--- a/core/sqf/src/tm/tmlogging.cpp
+++ b/core/sqf/src/tm/tmlogging.cpp
@@ -45,18 +45,20 @@ int tm_init_logging()
     return gv_dual_logging; 
 }
 
-int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string, long transid)
-{
-    int    lv_err = 0;
-    lv_err = tm_log_stdout(pv_event_type, pv_severity, pp_string, -1, transid);
-    return lv_err;
-}
+int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *err_string, char *exception_stack, long transid)
+{ 
+    char      my_processName[MS_MON_MAX_PROCESS_NAME+1];
+    int       my_nid,my_pid;
+    logLevel ll_severity = LL_INFO;
 
-int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string)
-{
-    int    lv_err = 0;
-    lv_err = tm_log_stdout(pv_event_type, pv_severity, pp_string);
-    return lv_err;
+    getTMLoggingHeaderInfo(pv_severity, ll_severity, my_processName, sizeof(my_processName), my_nid, my_pid);
+    if (exception_stack == NULL) 
+       CommonLogger::log(TM_COMPONENT, ll_severity, "Node: %d Pid: %d Name: %s TransId: %Ld Event: %d Message: %s ", 
+              my_nid, my_pid, my_processName, transid, pv_event_type, err_string);
+    else
+       CommonLogger::log(TM_COMPONENT, ll_severity, "Node: %d Pid: %d Name: %s TransId: %Ld Event: %d Message: Error at %s caused by exception %s ", 
+              my_nid, my_pid, my_processName, transid, pv_event_type, err_string, exception_stack);
+    return 0;
 }
 
 int tm_alt_log_write(int eventType, posix_sqlog_severity_t severity, char *msg) {
@@ -191,9 +193,9 @@ int tm_log_stdout(int event_id,
 
     char      my_name[MS_MON_MAX_PROCESS_NAME];
     int       my_nid,my_pid;
-    int       error;
+    int       error = 0;
 
-	logLevel ll_severity = LL_INFO;
+    logLevel ll_severity = LL_INFO;
 
     current_time = time(NULL);
     ctime_r(&current_time,timestamp);
@@ -201,47 +203,26 @@ int tm_log_stdout(int event_id,
 
     printf("%s  ", timestamp);
 
-    error = msg_mon_get_my_process_name( my_name, sizeof(my_name) );
-    if (!error)
-    {
-      error = msg_mon_get_process_info( my_name, &my_nid, &my_pid );
-      if (!error)
-         printf("(%s,%u,%u) ",my_name,my_nid,my_pid);
-      else
-      {
-         my_nid = -1; 
-         my_pid = -1;
-      }
-    }
-    else
-      strcpy(my_name, "UNKNOWN");
-
+    getTMLoggingHeaderInfo(severity, ll_severity, my_name, sizeof(my_name), my_nid, my_pid);
+    printf("(%s,%u,%u) ",my_name,my_nid,my_pid);
     printf("Event %s(%d), Sev ", temp_string, event_id);
     switch (severity)
     {
     case SQ_LOG_EMERG: printf("EMERGENCY"); 
-		ll_severity = LL_FATAL;
 		break;
     case SQ_LOG_ALERT: printf("ALERT"); 
-		ll_severity = LL_WARN;
 		break;
     case SQ_LOG_CRIT: printf("CRITICAL"); 
-		ll_severity = LL_FATAL;
 		break;
     case SQ_LOG_ERR: printf("ERROR"); 
-		ll_severity = LL_ERROR;
 		break;
     case SQ_LOG_WARNING: printf("WARNING"); 
-		ll_severity = LL_WARN;
 		break;
     case SQ_LOG_NOTICE: printf("NOTICE"); 
-		ll_severity = LL_INFO;
 		break;
     case SQ_LOG_INFO: printf("INFO"); 
-		ll_severity = LL_INFO;
 		break;
     case SQ_LOG_DEBUG: printf("DEBUG"); 
-		ll_severity = LL_DEBUG;
 		break;
     default: printf("%d Unknown", severity);
     }
@@ -293,8 +274,60 @@ int tm_log_stdout(int event_id,
        printf(", data4=%u",data4);
     printf("\n");
 
-    // Log4cxx logging
-    CommonLogger::log(TM_COMPONENT, ll_severity, "Node Number: %u, PIN: %u , Process Name: %s, TMID: %Ld Message: %s ", my_nid, my_pid, my_name, transid, temp_string);
-
     return error;
 } 
+
+
+
+void getTMLoggingHeaderInfo(posix_sqlog_severity_t severity, logLevel &ll_severity, char *processName, int processNameLen, int &my_nid, int &my_pid)
+{
+
+    char      my_name[MS_MON_MAX_PROCESS_NAME+1];
+    int       error;
+
+    error = msg_mon_get_my_process_name( my_name, sizeof(my_name) );
+    if (error == 0) {
+      error = msg_mon_get_process_info( my_name, &my_nid, &my_pid );
+      if (error != 0) {
+         my_nid = -1;
+         my_pid = -1;
+      }
+    }
+    else
+      strcpy(my_name, "UNKNOWN");
+    int len = strlen(my_name);
+    if (len < processNameLen)
+        len = processNameLen-1;
+    strncpy(processName, my_name, len);
+    processName[len] = '\0';
+    switch (severity) {
+    case SQ_LOG_EMERG: 
+       ll_severity = LL_FATAL;
+       break;
+    case SQ_LOG_ALERT:
+       ll_severity = LL_WARN;
+       break;
+    case SQ_LOG_CRIT: printf("CRITICAL"); 
+       ll_severity = LL_FATAL;
+       break;
+    case SQ_LOG_ERR: printf("ERROR"); 
+       ll_severity = LL_ERROR;
+       break;
+    case SQ_LOG_WARNING: printf("WARNING"); 
+       ll_severity = LL_WARN;
+       break;
+    case SQ_LOG_NOTICE: printf("NOTICE"); 
+       ll_severity = LL_INFO;
+       break;
+    case SQ_LOG_INFO: printf("INFO"); 
+       ll_severity = LL_INFO;
+       break;
+    case SQ_LOG_DEBUG: printf("DEBUG"); 
+       ll_severity = LL_DEBUG;
+       break;
+    default:
+       ll_severity = LL_INFO;
+       break;
+   } 
+   return;
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/97294fe0/core/sqf/src/tm/tmlogging.h
----------------------------------------------------------------------
diff --git a/core/sqf/src/tm/tmlogging.h b/core/sqf/src/tm/tmlogging.h
index 954e5af..f763a0f 100644
--- a/core/sqf/src/tm/tmlogging.h
+++ b/core/sqf/src/tm/tmlogging.h
@@ -25,15 +25,14 @@
 #include "dtm/tm_util.h"
 #include "sqevlog/evl_sqlog_writer.h"
 #include "common/evl_sqlog_eventnum.h"
+#include "CommonLogger.h"
 
 #define DTM_STRING_BUF_SIZE 512
 #define DTM_EVENT_BUF_SIZE 4096
 
 int tm_init_logging();
 
-int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string);
-
-int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *pp_string, long transid);
+int tm_log_write(int pv_event_type, posix_sqlog_severity_t pv_severity, char *err_string, char *exception_stack=NULL, long transid=-1);
 
 int tm_alt_log_write(int eventType, posix_sqlog_severity_t severity, char *msg);
 
@@ -91,6 +90,8 @@ int tm_log_stdout
                  int tm_event_msg = -1, // 21
                  uint data4 = 0);          //22
 
+void getTMLoggingHeaderInfo(posix_sqlog_severity_t severity, logLevel &ll_severity, char *processName, int processNameLen, int &my_nid, int &my_pid);
+
 #endif