You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by li...@apache.org on 2018/05/04 15:47:19 UTC

[1/4] trafodion git commit: [Trafodion-3041] Support watchdog query cache to improvement performance when every query executed needs to be written into repository. The time when the queries cached will be published into repository is determined by cache

Repository: trafodion
Updated Branches:
  refs/heads/master 2477de30d -> fe62cce78


[Trafodion-3041] Support watchdog query cache to improvement performance when every query executed needs to be written into repository.
The time when the queries cached will be published into repository is determined by cache time or number of queries. You can configure it in the file
conf/dcs-site.xml.


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

Branch: refs/heads/master
Commit: c9570e33d1ebbc5d92bc8868be3f53f8ad10f318
Parents: b06e0dc
Author: Haolin.song <40...@qq.com>
Authored: Tue Apr 24 03:11:07 2018 +0000
Committer: Haolin.song <40...@qq.com>
Committed: Tue Apr 24 03:17:38 2018 +0000

----------------------------------------------------------------------
 core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp | 327 +++++++++++++++----
 core/conn/odbc/src/odbc/nsksrvr/SrvrMain.cpp    |  23 ++
 .../main/java/org/trafodion/dcs/Constants.java  |   7 +-
 .../org/trafodion/dcs/server/ServerManager.java |   6 +
 dcs/src/main/resources/dcs-default.xml          |   8 +
 5 files changed, 302 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/c9570e33/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp b/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
index 7f24ef7..d5879e0 100644
--- a/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
+++ b/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
@@ -119,6 +119,7 @@ extern int sdconn;
 extern int clientConnTimeOut;
 extern short stopOnDisconnect;
 extern int aggrInterval;
+extern int statisticsCacheSize;
 extern int queryPubThreshold;
 extern statistics_type statisticsPubType;
 extern bool bStatisticsEnabled;
@@ -342,11 +343,22 @@ public:
     {
         return my_queue.size();
     }
+
+    bool isEmpty(){
+        return my_queue.empty();
+    }
 };
 
 static Repos_Queue<REPOS_STATS> repos_queue;
 static bool record_session_done = true;
 
+//0:None 1:update 2:insert/upsert cache limit 3:achieve timeline
+
+#define REPOS_EXECUTE_NONE       0
+#define REPOS_EXECUTE_UPDATE     1
+#define REPOS_EXECUTE_CACHELIMIT 2
+#define REPOS_EXECUTE_TIMELINE   3
+
 static void* SessionWatchDog(void* arg)
 {
 	record_session_done = false;
@@ -530,11 +542,39 @@ static void* SessionWatchDog(void* arg)
                 okToGo = false;
             }
         }
-
-
-		while(!record_session_done && okToGo)
-		{
-			REPOS_STATS repos_stats = repos_queue.get_task();
+        vector< vector<string> > query_list;
+        vector<string> session_start;
+        vector<string> statement_new_query;
+        vector<string> session_stat_aggregation;
+
+        session_start.push_back("upsert into Trafodion.\"_REPOS_\".metric_session_table values");
+        statement_new_query.push_back("insert into Trafodion.\"_REPOS_\".metric_query_table values");
+        session_stat_aggregation.push_back("insert into Trafodion.\"_REPOS_\".metric_query_aggr_table values");
+
+        query_list.push_back(session_start);
+        query_list.push_back(statement_new_query);
+        query_list.push_back(session_stat_aggregation);
+
+        int query_limit = statisticsCacheSize;
+        int time_limit = aggrInterval;
+        //0:None 1:update 2:insert/upsert cache limit 3:achieve timeline
+        int execute_flag = REPOS_EXECUTE_NONE;
+        clock_t time_start = clock();
+        clock_t time_end= clock();
+
+        REPOS_STATS repos_stats;
+        while(!record_session_done && okToGo)
+        {
+            time_start = clock();
+            while(repos_queue.isEmpty() && (((time_end = clock()) - time_start) / 1000000 < time_limit));
+
+            if(!repos_queue.isEmpty()){
+                repos_stats = repos_queue.get_task();
+            }else{
+                // go to executeDirect
+                execute_flag = REPOS_EXECUTE_TIMELINE;
+                goto execute;
+            }
 
 			ss.str("");
 			ss.clear();
@@ -550,7 +590,8 @@ static void* SessionWatchDog(void* arg)
 					break;
 				}
 
-				ss << "upsert into Trafodion.\"_REPOS_\".metric_session_table values(";
+				//upsert into Trafodion.\"_REPOS_\".metric_session_table values
+				ss << "(";
 				ss << pSessionInfo->m_instance_id << ",";
 				ss << pSessionInfo->m_tenant_id << ",";
 				ss << pSessionInfo->m_component_id << ",";
@@ -599,6 +640,24 @@ static void* SessionWatchDog(void* arg)
 				ss << pSessionInfo->m_authentication_connection_elapsed_time_mcsec << ",";
 				ss << pSessionInfo->m_authentication_elapsed_time_mcsec << ")";
 
+                execute_flag = REPOS_EXECUTE_NONE;
+                vector<string> *tmp = &query_list.at(0);
+                (*tmp).push_back(ss.str());
+                if ((*tmp).size() > query_limit)
+                {
+                    //go executeDirect
+                    execute_flag = REPOS_EXECUTE_CACHELIMIT;
+                    execStr ="";
+                    vector<string>::iterator it = (*tmp).begin();
+                    execStr += *it +  *(it + 1);
+                    it += 2;
+                    for(; it != (*tmp).end(); it++)
+                    {
+                        execStr+= "," + *it;
+                    }
+                    (*tmp).erase((*tmp).begin() + 1, (*tmp).end());
+                }
+
 			}
 			else if (repos_stats.m_pub_type == PUB_TYPE_STATEMENT_NEW_QUERYEXECUTION)
 			{
@@ -612,7 +671,8 @@ static void* SessionWatchDog(void* arg)
 				}
                                 lastUpdatedTime = JULIANTIMESTAMP();
 
-				ss << "insert into Trafodion.\"_REPOS_\".metric_query_table values(";
+				//ss << "insert into Trafodion.\"_REPOS_\".metric_query_table values(";
+                                ss << "(";
 				ss << pQueryAdd->m_instance_id << ",";
 				ss << pQueryAdd->m_tenant_id << ",";
 				ss << pQueryAdd->m_component_id << ",";
@@ -761,6 +821,25 @@ static void* SessionWatchDog(void* arg)
 
                                 ss <<")";
 
+                                execute_flag = REPOS_EXECUTE_NONE;
+                                vector<string> *tmp = &query_list.at(1);
+                                (*tmp).push_back(ss.str());
+                                if ((*tmp).size() > query_limit)
+                                {
+                                    //go executeDirect
+                                    execute_flag = REPOS_EXECUTE_CACHELIMIT;
+                                    execStr ="";
+                                    vector<string>::iterator it = (*tmp).begin();
+                                    execStr += *it;
+                                    execStr += *(it + 1);
+                                    it += 2;
+                                    for(; it != (*tmp).end(); it++)
+                                    {
+                                        execStr+= "," + *it;
+                                    }
+                                    (*tmp).erase((*tmp).begin() + 1, (*tmp).end());
+                                }
+
 			}
 			else if (repos_stats.m_pub_type == PUB_TYPE_STATEMENT_UPDATE_QUERYEXECUTION)
 			{
@@ -833,6 +912,11 @@ static void* SessionWatchDog(void* arg)
                                 ss << "LAST_UPDATED_TIME= CONVERTTIMESTAMP(" << lastUpdatedTime << ")";
 				ss << " where QUERY_ID = '" << pQueryUpdate->m_query_id.c_str() << "'";
 				ss << " and EXEC_START_UTC_TS = CONVERTTIMESTAMP(" << pQueryUpdate->m_exec_start_utc_ts << ")";
+
+
+                                //go executeDirect
+                                execute_flag = REPOS_EXECUTE_UPDATE;
+                                execStr = ss.str();
 			}
 			else if (repos_stats.m_pub_type == PUB_TYPE_SESSION_START_AGGREGATION)
 			{
@@ -845,7 +929,7 @@ static void* SessionWatchDog(void* arg)
 					break;
 				}
 
-				ss << "insert into Trafodion.\"_REPOS_\".metric_query_aggr_table values(";
+				ss << "(";
 				ss << pAggrStat->m_instance_id << ",";
 				ss << pAggrStat->m_tenant_id << ",";
 				ss << pAggrStat->m_component_id << ",";
@@ -909,8 +993,27 @@ static void* SessionWatchDog(void* arg)
 				ss << pAggrStat->m_delta_catalog_errors << ",";
 				ss << pAggrStat->m_delta_other_errors << ",";
 				ss << pAggrStat->m_average_response_time << ",";
-				ss << pAggrStat->m_throughput_per_sec << ")";
-			}
+                ss << pAggrStat->m_throughput_per_sec << ")";
+
+                execute_flag = REPOS_EXECUTE_NONE;
+                vector<string> *tmp = &query_list.at(2);
+                (*tmp).push_back(ss.str());
+                if ((*tmp).size() > query_limit)
+                {
+                    //go executeDirect
+                    execute_flag = REPOS_EXECUTE_CACHELIMIT;
+                    execStr ="";
+                    vector<string>::iterator it = (*tmp).begin();
+                    execStr += *it + *(it + 1);
+                    it += 2;
+                    for(; it != (*tmp).end(); it++)
+                    {
+                        execStr+= "," + *it;
+                    }
+                    (*tmp).erase((*tmp).begin() + 1, (*tmp).end());
+                }
+
+            }
 			else if (repos_stats.m_pub_type == PUB_TYPE_SESSION_UPDATE_AGGREGATION || repos_stats.m_pub_type == PUB_TYPE_SESSION_END_AGGREGATION)
 			{
 				std::tr1::shared_ptr<SESSION_AGGREGATION> pAggrStat = repos_stats.m_pAggr_stats;
@@ -972,70 +1075,158 @@ static void* SessionWatchDog(void* arg)
 				ss << " where SESSION_START_UTC_TS = CONVERTTIMESTAMP(" << pAggrStat->m_session_start_utc_ts << ")";
 				ss << " and SESSION_ID = '" << pAggrStat->m_sessionId.c_str() << "'";
 
+                               //go executeDirect
+                               execute_flag = REPOS_EXECUTE_UPDATE;
+                               execStr = ss.str();
 			}
 			else
 			{
 				break;
 			}
-			execStr = ss.str();
-			retcode = pSrvrStmt->ExecDirect(NULL, execStr.c_str(), INTERNAL_STMT, TYPE_UNKNOWN, SQL_ASYNC_ENABLE_OFF, 0);
-			if (retcode < 0)
-			{
-				errMsg.str("");
-				if(pSrvrStmt->sqlError.errorList._length > 0)
-					p_buffer = pSrvrStmt->sqlError.errorList._buffer;
-				else if(pSrvrStmt->sqlWarning._length > 0)
-					p_buffer = pSrvrStmt->sqlWarning._buffer;
-				if(p_buffer != NULL && p_buffer->errorText)
-					errMsg << "Failed to write statistics: " << execStr.c_str() << "----Error detail - " << p_buffer->errorText;
-				else
-					errMsg << "Failed to write statistics: " << execStr.c_str() << "----Error detail - " << " no additional information";
-				errStr = errMsg.str();
-				SendEventMsg(MSG_ODBC_NSK_ERROR, EVENTLOG_ERROR_TYPE,
-										0, ODBCMX_SERVER, srvrGlobal->srvrObjRef,
-										1, errStr.c_str());
-			}
-			else {
-				// Update QUERY_TABLE with explain plan if needed
-				if (repos_stats.m_pub_type == PUB_TYPE_STATEMENT_NEW_QUERYEXECUTION && TRUE == srvrGlobal->sqlPlan)
-				{
-					std::tr1::shared_ptr<STATEMENT_QUERYEXECUTION> pQueryAdd = repos_stats.m_pQuery_stats;
-					if(NULL == pQueryAdd)
-					{
-						SendEventMsg(MSG_ODBC_NSK_ERROR, EVENTLOG_ERROR_TYPE,
-															0, ODBCMX_SERVER, srvrGlobal->srvrObjRef,
-															1, "Invalid data pointer found in SessionWatchDog(). Cannot write explain plan.");
-						break;
-					}
-                                        if (pQueryAdd->m_explain_plan && (pQueryAdd->m_explain_plan_len > 0))
-                                          {
-                                            retcode = SQL_EXEC_StoreExplainData( &(pQueryAdd->m_exec_start_utc_ts),
-                                                                                 (char *)(pQueryAdd->m_query_id.c_str()),
-                                                                                 pQueryAdd->m_explain_plan,
-                                                                                 pQueryAdd->m_explain_plan_len );
-                                            
-                                            if (retcode == -EXE_EXPLAIN_PLAN_TOO_LARGE)
-                                              {
-                                                // explain info is too big to be stored in repository.
-                                                // ignore this error and continue with query execution.
-                                                retcode = 0;
-                                              }
-                                            else if (retcode < 0)
-                                              {
-                                                char errStr[256];
-                                                sprintf( errStr, "Error updating explain data. SQL_EXEC_StoreExplainData() returned: %d", retcode );
-                                                SendEventMsg(MSG_ODBC_NSK_ERROR, EVENTLOG_ERROR_TYPE,
-                                                             0, ODBCMX_SERVER,
-                                                             srvrGlobal->srvrObjRef, 1, errStr);
-                                              }
-                                            // Clear diagnostics
-                                            SRVR::WSQL_EXEC_ClearDiagnostics(NULL);
-                                          }
-				}
-			}
+execute:
+            if(REPOS_EXECUTE_UPDATE == execute_flag || REPOS_EXECUTE_CACHELIMIT == execute_flag){
+                retcode = pSrvrStmt->ExecDirect(NULL, execStr.c_str(), INTERNAL_STMT, TYPE_UNKNOWN, SQL_ASYNC_ENABLE_OFF, 0);
+                if (retcode < 0)
+                {
+                    errMsg.str("");
+                    if(pSrvrStmt->sqlError.errorList._length > 0)
+                        p_buffer = pSrvrStmt->sqlError.errorList._buffer;
+                    else if(pSrvrStmt->sqlWarning._length > 0)
+                        p_buffer = pSrvrStmt->sqlWarning._buffer;
+                    if(p_buffer != NULL && p_buffer->errorText)
+                        errMsg << "Failed to write statistics: " << execStr.c_str() << "----Error detail - " << p_buffer->errorText;
+                    else
+                        errMsg << "Failed to write statistics: " << execStr.c_str() << "----Error detail - " << " no additional information";
+                    errStr = errMsg.str();
+                    SendEventMsg(MSG_ODBC_NSK_ERROR, EVENTLOG_ERROR_TYPE,
+                            0, ODBCMX_SERVER, srvrGlobal->srvrObjRef,
+                            1, errStr.c_str());
+                }
+                else {
+                    // Update QUERY_TABLE with explain plan if needed
+                    if (repos_stats.m_pub_type == PUB_TYPE_STATEMENT_NEW_QUERYEXECUTION && TRUE == srvrGlobal->sqlPlan)
+                    {
+                        std::tr1::shared_ptr<STATEMENT_QUERYEXECUTION> pQueryAdd = repos_stats.m_pQuery_stats;
+                        if(NULL == pQueryAdd)
+                        {
+                            SendEventMsg(MSG_ODBC_NSK_ERROR, EVENTLOG_ERROR_TYPE,
+                                    0, ODBCMX_SERVER, srvrGlobal->srvrObjRef,
+                                    1, "Invalid data pointer found in SessionWatchDog(). Cannot write explain plan.");
+                            break;
+                        }
+                        if (pQueryAdd->m_explain_plan && (pQueryAdd->m_explain_plan_len > 0))
+                        {
+                            retcode = SQL_EXEC_StoreExplainData( &(pQueryAdd->m_exec_start_utc_ts),
+                                    (char *)(pQueryAdd->m_query_id.c_str()),
+                                    pQueryAdd->m_explain_plan,
+                                    pQueryAdd->m_explain_plan_len );
+
+                            if (retcode == -EXE_EXPLAIN_PLAN_TOO_LARGE)
+                            {
+                                // explain info is too big to be stored in repository.
+                                // ignore this error and continue with query execution.
+                                retcode = 0;
+                            }
+                            else if (retcode < 0)
+                            {
+                                char errStr[256];
+                                sprintf( errStr, "Error updating explain data. SQL_EXEC_StoreExplainData() returned: %d", retcode );
+                                SendEventMsg(MSG_ODBC_NSK_ERROR, EVENTLOG_ERROR_TYPE,
+                                        0, ODBCMX_SERVER,
+                                        srvrGlobal->srvrObjRef, 1, errStr);
+                            }
+                            // Clear diagnostics
+                            SRVR::WSQL_EXEC_ClearDiagnostics(NULL);
+                        }
+                    }
+                }
+                if (pSrvrStmt != NULL){
+                    pSrvrStmt->cleanupAll();
+                    REALLOCSQLMXHDLS(pSrvrStmt);
+                }
+            
+            }else if (REPOS_EXECUTE_TIMELINE == execute_flag)
+            {
+                for(int i = 0;i < 3;i++)
+                {
+                    vector<string> *tmp = &query_list.at(i);
 
-			pSrvrStmt->cleanupAll();
-			REALLOCSQLMXHDLS(pSrvrStmt);
+                    if( (*tmp).size() < 2)
+                    {
+                        continue;
+                    }
+                    execStr ="";
+                    vector<string>::iterator it = (*tmp).begin();
+                    execStr += *it + *(it + 1);
+                    it += 2;
+                    for(; it != (*tmp).end(); it++)
+                    {
+                        execStr+= "," + *it;
+                    }
+                    (*tmp).erase((*tmp).begin() + 1, (*tmp).end());
+
+                    retcode = pSrvrStmt->ExecDirect(NULL, execStr.c_str(), INTERNAL_STMT, TYPE_UNKNOWN, SQL_ASYNC_ENABLE_OFF, 0);
+                    if (retcode < 0)
+                    {
+                        errMsg.str("");
+                        if(pSrvrStmt->sqlError.errorList._length > 0)
+                            p_buffer = pSrvrStmt->sqlError.errorList._buffer;
+                        else if(pSrvrStmt->sqlWarning._length > 0)
+                            p_buffer = pSrvrStmt->sqlWarning._buffer;
+                        if(p_buffer != NULL && p_buffer->errorText)
+                            errMsg << "Failed to write statistics: " << execStr.c_str() << "----Error detail - " << p_buffer->errorText;
+                        else
+                            errMsg << "Failed to write statistics: " << execStr.c_str() << "----Error detail - " << " no additional information";
+                        errStr = errMsg.str();
+                        SendEventMsg(MSG_ODBC_NSK_ERROR, EVENTLOG_ERROR_TYPE,
+                                0, ODBCMX_SERVER, srvrGlobal->srvrObjRef,
+                                1, errStr.c_str());
+                    }
+                    else {
+                        // Update QUERY_TABLE with explain plan if needed
+                        if (repos_stats.m_pub_type == PUB_TYPE_STATEMENT_NEW_QUERYEXECUTION && TRUE == srvrGlobal->sqlPlan)
+                        {
+                            std::tr1::shared_ptr<STATEMENT_QUERYEXECUTION> pQueryAdd = repos_stats.m_pQuery_stats;
+                            if(NULL == pQueryAdd)
+                            {
+                                SendEventMsg(MSG_ODBC_NSK_ERROR, EVENTLOG_ERROR_TYPE,
+                                        0, ODBCMX_SERVER, srvrGlobal->srvrObjRef,
+                                        1, "Invalid data pointer found in SessionWatchDog(). Cannot write explain plan.");
+                                break;
+                            }
+                            if (pQueryAdd->m_explain_plan && (pQueryAdd->m_explain_plan_len > 0))
+                            {
+                                retcode = SQL_EXEC_StoreExplainData( &(pQueryAdd->m_exec_start_utc_ts),
+                                        (char *)(pQueryAdd->m_query_id.c_str()),
+                                        pQueryAdd->m_explain_plan,
+                                        pQueryAdd->m_explain_plan_len );
+
+                                if (retcode == -EXE_EXPLAIN_PLAN_TOO_LARGE)
+                                {
+                                    // explain info is too big to be stored in repository.
+                                    // ignore this error and continue with query execution.
+                                    retcode = 0;
+                                }
+                                else if (retcode < 0)
+                                {
+                                    char errStr[256];
+                                    sprintf( errStr, "Error updating explain data. SQL_EXEC_StoreExplainData() returned: %d", retcode );
+                                    SendEventMsg(MSG_ODBC_NSK_ERROR, EVENTLOG_ERROR_TYPE,
+                                            0, ODBCMX_SERVER,
+                                            srvrGlobal->srvrObjRef, 1, errStr);
+                                }
+                                // Clear diagnostics
+                                SRVR::WSQL_EXEC_ClearDiagnostics(NULL);
+                            }
+                        }
+                    }
+	                
+                    if (pSrvrStmt != NULL){
+			            pSrvrStmt->cleanupAll();
+			            REALLOCSQLMXHDLS(pSrvrStmt);
+                    }
+                }//End for
+            }//end else
 		}//End while
 
 	}

http://git-wip-us.apache.org/repos/asf/trafodion/blob/c9570e33/core/conn/odbc/src/odbc/nsksrvr/SrvrMain.cpp
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvr/SrvrMain.cpp b/core/conn/odbc/src/odbc/nsksrvr/SrvrMain.cpp
index 132a0a4..72350ec 100644
--- a/core/conn/odbc/src/odbc/nsksrvr/SrvrMain.cpp
+++ b/core/conn/odbc/src/odbc/nsksrvr/SrvrMain.cpp
@@ -87,6 +87,7 @@ int zkSessionTimeout;
 short stopOnDisconnect;
 char trafIPAddr[20];
 int aggrInterval;
+int statisticsCacheSize;
 int queryPubThreshold;
 statistics_type statisticsPubType;
 bool bStatisticsEnabled;
@@ -1085,6 +1086,7 @@ BOOL getInitParamSrvr(int argc, char *argv[], SRVR_INIT_PARAM_Def &initParam, ch
 	memset(trafIPAddr,0,sizeof(trafIPAddr));
 	memset(hostname,0,sizeof(hostname));
 	aggrInterval = 60;
+    statisticsCacheSize = 60;
 	queryPubThreshold = 60;
 	statisticsPubType = STATISTICS_AGGREGATED;
 	bStatisticsEnabled = false;
@@ -1314,6 +1316,27 @@ BOOL getInitParamSrvr(int argc, char *argv[], SRVR_INIT_PARAM_Def &initParam, ch
 			}
 		}
 		else
+		if (strcmp(arg, "-STATISTICSCACHESIZE") == 0)
+		{
+			if (++count < argc )
+			{
+                            if(strspn(argv[count], "0123456789")==strlen(argv[count])){
+                                number=atoi(argv[count]);
+                                if(number > 0)
+                                    statisticsCacheSize = number;
+                            }
+                            else
+                            {
+                                argWrong = TRUE;
+                            }
+			}
+			else
+			{
+				argEmpty = TRUE;
+				break;
+			}
+		}
+               else
 		if (strcmp(arg, "-STATISTICSLIMIT") == 0)
 		{
 			if (++count < argc)

http://git-wip-us.apache.org/repos/asf/trafodion/blob/c9570e33/dcs/src/main/java/org/trafodion/dcs/Constants.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/Constants.java b/dcs/src/main/java/org/trafodion/dcs/Constants.java
index b3e5f38..ace9e69 100644
--- a/dcs/src/main/java/org/trafodion/dcs/Constants.java
+++ b/dcs/src/main/java/org/trafodion/dcs/Constants.java
@@ -92,7 +92,7 @@ public final class Constants {
     public static final String DCS_SERVER_USER_PROGRAM_COMMAND = "dcs.server.user.program.command";
 
     /** Default value for DCS server user program command */
-    public static final String DEFAULT_DCS_SERVER_USER_PROGRAM_COMMAND = "cd ${dcs.user.program.home};. ./sqenv.sh;mxosrvr -ZKHOST -RZ -ZKPNODE -CNGTO -ZKSTO -EADSCO -TCPADD -MAXHEAPPCT -STATISTICSINTERVAL -STATISTICSLIMIT -STATISTICSTYPE -STATISTICSENABLE -SQLPLAN -PORTMAPTOSECS -PORTBINDTOSECS -TCPKEEPALIVESTATUS -TCPKEEPALIVEIDLETIME -TCPKEEPALIVEINTERVAL -TCPKEEPALIVERETRYCOUNT";
+    public static final String DEFAULT_DCS_SERVER_USER_PROGRAM_COMMAND = "cd ${dcs.user.program.home};. ./sqenv.sh;mxosrvr -ZKHOST -RZ -ZKPNODE -CNGTO -ZKSTO -EADSCO -TCPADD -MAXHEAPPCT -STATISTICSINTERVAL -STATISTICSLIMIT -STATISTICSTYPE -STATISTICSCACHESIZE -STATISTICSENABLE -SQLPLAN -PORTMAPTOSECS -PORTBINDTOSECS -TCPKEEPALIVESTATUS -TCPKEEPALIVEIDLETIME -TCPKEEPALIVEINTERVAL -TCPKEEPALIVERETRYCOUNT";
 
     /** Configuration key for DCS server user program connecting timeout */
     public static final String DCS_SERVER_USER_PROGRAM_CONNECTING_TIMEOUT = "dcs.server.user.program.connecting.timeout";
@@ -146,6 +146,11 @@ public final class Constants {
      * large
      */
     public static final int DEFAULT_DCS_SERVER_USER_PROGRAM_MAX_HEAP_PCT_EXIT = 0;
+/** Configuration key for DCS server user program statistics cache size */
+    public static final String DCS_SERVER_USER_PROGRAM_STATISTICS_CACHE_SIZE = "dcs.server.user.program.statistics.cache.size";
+
+    /** Default value for DCS server user program statistics cache size */
+    public static final int DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_CACHE_SIZE = 60;
 
     /** Configuration key for DCS server user program statistics interval time */
     public static final String DCS_SERVER_USER_PROGRAM_STATISTICS_INTERVAL_TIME = "dcs.server.user.program.statistics.interval.time";

http://git-wip-us.apache.org/repos/asf/trafodion/blob/c9570e33/dcs/src/main/java/org/trafodion/dcs/server/ServerManager.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/server/ServerManager.java b/dcs/src/main/java/org/trafodion/dcs/server/ServerManager.java
index e9dc98c..aa7e0ad 100644
--- a/dcs/src/main/java/org/trafodion/dcs/server/ServerManager.java
+++ b/dcs/src/main/java/org/trafodion/dcs/server/ServerManager.java
@@ -74,6 +74,7 @@ public final class ServerManager implements Callable {
     private int maxHeapPctExit;
     private int statisticsIntervalTime;
     private int statisticsLimitTime;
+    private int statisticsCacheSize;
     private String statisticsType;
     private String statisticsEnable;
     private String sqlplanEnable;
@@ -200,6 +201,8 @@ public final class ServerManager implements Callable {
                                     + " ")
                     .replace("-STATISTICSLIMIT",
                             "-STATISTICSLIMIT " + statisticsLimitTime + " ")
+                    .replace("-STATISTICSCACHESIZE",
+                            "-STATISTICSCACHESIZE " + statisticsCacheSize + " ")
                     .replace("-STATISTICSTYPE",
                             "-STATISTICSTYPE " + statisticsType + " ")
                     .replace("-STATISTICSENABLE",
@@ -339,6 +342,9 @@ public final class ServerManager implements Callable {
         this.statisticsLimitTime = this.conf
                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_LIMIT_TIME,
                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_LIMIT_TIME);
+        this.statisticsCacheSize = this.conf
+                .getInt(Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_CACHE_SIZE,
+                        Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_CACHE_SIZE);
         this.statisticsType = this.conf.get(
                 Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_TYPE,
                 Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_TYPE);

http://git-wip-us.apache.org/repos/asf/trafodion/blob/c9570e33/dcs/src/main/resources/dcs-default.xml
----------------------------------------------------------------------
diff --git a/dcs/src/main/resources/dcs-default.xml b/dcs/src/main/resources/dcs-default.xml
index b568d99..13a6125 100644
--- a/dcs/src/main/resources/dcs-default.xml
+++ b/dcs/src/main/resources/dcs-default.xml
@@ -334,6 +334,14 @@
     </description>
   </property>
   <property>
+    <name>dcs.server.user.program.statistics.cache.size</name>
+    <value>60</value>
+    <description>
+        Size of cache data to be published.
+        The default is 60.
+    </description>
+  </property>
+  <property>
     <name>dcs.server.user.program.statistics.limit.time</name>
     <value>60</value>
     <description>


[3/4] trafodion git commit: [TRAFODION-3041] Addressed review comment, set default cache size to 1

Posted by li...@apache.org.
[TRAFODION-3041] Addressed review comment, set default cache size to 1


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

Branch: refs/heads/master
Commit: f8c90f3b8f9551788ee87ca8f5069c70676e80e7
Parents: bffd05b
Author: Haolin.song <40...@qq.com>
Authored: Fri Apr 27 17:34:13 2018 +0000
Committer: Haolin.song <40...@qq.com>
Committed: Fri Apr 27 17:34:13 2018 +0000

----------------------------------------------------------------------
 dcs/src/main/java/org/trafodion/dcs/Constants.java | 2 +-
 dcs/src/main/resources/dcs-default.xml             | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/f8c90f3b/dcs/src/main/java/org/trafodion/dcs/Constants.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/Constants.java b/dcs/src/main/java/org/trafodion/dcs/Constants.java
index ace9e69..2fda059 100644
--- a/dcs/src/main/java/org/trafodion/dcs/Constants.java
+++ b/dcs/src/main/java/org/trafodion/dcs/Constants.java
@@ -150,7 +150,7 @@ public final class Constants {
     public static final String DCS_SERVER_USER_PROGRAM_STATISTICS_CACHE_SIZE = "dcs.server.user.program.statistics.cache.size";
 
     /** Default value for DCS server user program statistics cache size */
-    public static final int DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_CACHE_SIZE = 60;
+    public static final int DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_CACHE_SIZE = 1;
 
     /** Configuration key for DCS server user program statistics interval time */
     public static final String DCS_SERVER_USER_PROGRAM_STATISTICS_INTERVAL_TIME = "dcs.server.user.program.statistics.interval.time";

http://git-wip-us.apache.org/repos/asf/trafodion/blob/f8c90f3b/dcs/src/main/resources/dcs-default.xml
----------------------------------------------------------------------
diff --git a/dcs/src/main/resources/dcs-default.xml b/dcs/src/main/resources/dcs-default.xml
index 13a6125..d16eac7 100644
--- a/dcs/src/main/resources/dcs-default.xml
+++ b/dcs/src/main/resources/dcs-default.xml
@@ -335,7 +335,7 @@
   </property>
   <property>
     <name>dcs.server.user.program.statistics.cache.size</name>
-    <value>60</value>
+    <value>1</value>
     <description>
         Size of cache data to be published.
         The default is 60.


[4/4] trafodion git commit: merge [TRAFODION-3041] Support watchdog query cache

Posted by li...@apache.org.
merge [TRAFODION-3041] Support watchdog query cache  


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

Branch: refs/heads/master
Commit: fe62cce7871b58b1fc6e3fad258b008d84c2e903
Parents: 2477de3 f8c90f3
Author: Liu Ming <ov...@sina.com>
Authored: Fri May 4 10:33:27 2018 +0000
Committer: Liu Ming <ov...@sina.com>
Committed: Fri May 4 10:33:27 2018 +0000

----------------------------------------------------------------------
 core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp | 327 +++++++++++++++----
 core/conn/odbc/src/odbc/nsksrvr/SrvrMain.cpp    |  23 ++
 .../main/java/org/trafodion/dcs/Constants.java  |   7 +-
 .../org/trafodion/dcs/server/ServerManager.java |   6 +
 dcs/src/main/resources/dcs-default.xml          |   8 +
 5 files changed, 303 insertions(+), 68 deletions(-)
----------------------------------------------------------------------



[2/4] trafodion git commit: [TRAFODION-3041] Addressed review comment

Posted by li...@apache.org.
[TRAFODION-3041] Addressed review comment


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

Branch: refs/heads/master
Commit: bffd05bec555faea9779b1ba0d376030d9301f15
Parents: c9570e3
Author: Haolin.song <40...@qq.com>
Authored: Wed Apr 25 17:59:32 2018 +0000
Committer: Haolin.song <40...@qq.com>
Committed: Wed Apr 25 17:59:32 2018 +0000

----------------------------------------------------------------------
 core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/bffd05be/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp b/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
index d5879e0..c35659c 100644
--- a/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
+++ b/core/conn/odbc/src/odbc/nsksrvr/SrvrConnect.cpp
@@ -559,14 +559,16 @@ static void* SessionWatchDog(void* arg)
         int time_limit = aggrInterval;
         //0:None 1:update 2:insert/upsert cache limit 3:achieve timeline
         int execute_flag = REPOS_EXECUTE_NONE;
-        clock_t time_start = clock();
-        clock_t time_end= clock();
+        int sleep_count = 0;
 
         REPOS_STATS repos_stats;
         while(!record_session_done && okToGo)
         {
-            time_start = clock();
-            while(repos_queue.isEmpty() && (((time_end = clock()) - time_start) / 1000000 < time_limit));
+            sleep_count = 0;
+            while(repos_queue.isEmpty() && (sleep_count < time_limit)){
+                sleep(1);
+                sleep_count++;
+            }
 
             if(!repos_queue.isEmpty()){
                 repos_stats = repos_queue.get_task();