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:22 UTC
[3/4] incubator-trafodion git commit: [TRAFODION-1988] Better java
exception handling in the java/JNI layer of Trafodion - Part3
[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(¤t_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