You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by su...@apache.org on 2017/05/31 18:47:35 UTC
[34/50] [abbrv] incubator-trafodion git commit: Trafodion
configuration API changes
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/config.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/config.cxx b/core/sqf/monitor/linux/config.cxx
index 7e13fbc..cb2f486 100644
--- a/core/sqf/monitor/linux/config.cxx
+++ b/core/sqf/monitor/linux/config.cxx
@@ -386,7 +386,7 @@ void CConfigGroup::SendChangeNotification (CConfigKey *key)
snprintf(buf, sizeof(buf), "[CConfigGroup::SendChangeNotification],"
" Invalid group ConfigType for %s (%p).\n", name_.c_str(),
this);
- mon_log_write(MON_CONFIGGROUP_SENDCHANGENOTICE, SQ_LOG_ERR, buf);
+ mon_log_write(MON_CONFIGGROUP_SENDCHANGENOTICE_1, SQ_LOG_ERR, buf);
delete msg;
}
TRACE_EXIT;
@@ -485,7 +485,6 @@ void CConfigGroup::Set(char *key, char *value, bool replicated, bool addToDb)
CConfigContainer::CConfigContainer(void)
: Head (NULL)
, Tail (NULL)
- , db_ (NULL)
{
const char method_name[] = "CConfigContainer::CConfigContainer";
TRACE_ENTRY;
@@ -493,10 +492,7 @@ CConfigContainer::CConfigContainer(void)
// Add eyecatcher sequence as a debugging aid
memcpy(&eyecatcher_, "CCTR", 4);
- CClusterConfig *clusterConfig = Nodes->GetClusterConfig();
- db_ = clusterConfig->GetConfigDb();
-
- cluster_ = AddGroup((char *) "CLUSTER",ConfigType_Cluster);
+ cluster_ = AddGroup( (char *)"CLUSTER", ConfigType_Cluster );
if ( ! getenv("SQ_VIRTUAL_NODES") )
{
int pnid = Nodes->GetClusterConfig()->GetPNid(Node_name);
@@ -506,7 +502,7 @@ CConfigContainer::CConfigContainer(void)
{
snprintf(localNodeName_, sizeof(localNodeName_), "NODE%d",MyPNID);
}
- node_ = AddGroup(localNodeName_,ConfigType_Node);
+ node_ = AddGroup( localNodeName_, ConfigType_Node );
TRACE_EXIT;
}
@@ -533,176 +529,119 @@ CConfigContainer::~CConfigContainer(void)
void CConfigContainer::Init(void)
{
- int rc;
-
const char method_name[] = "CConfigContainer::Init";
TRACE_ENTRY;
- if ( db_ == NULL)
- {
- if (trace_settings & TRACE_INIT)
- {
- trace_printf("%s@%d cannot initialize registry from database "
- "since database open failed.\n", method_name,
- __LINE__);
+ int rc;
+ int regClusterCount = 0;
+ int regProcessCount = 0;
+ int regClusterMax = 0;
+ int regProcessMax = 0;
+ ConfigType type;
+ registry_configuration_t *regClusterConfig;
+ registry_configuration_t *regProcessConfig;
+
+ // Get cluster scope configuration registry entries count
+ rc = tc_get_registry_cluster_set( ®ClusterCount
+ , regClusterMax
+ , NULL );
+ if ( rc )
+ {
+ char la_buf[MON_STRING_BUF_SIZE];
+ snprintf( la_buf, sizeof(la_buf)
+ , "[%s] Node configuration access failed!\n"
+ , method_name );
+ mon_log_write(MON_CONFIGCONT_INIT_1, SQ_LOG_ERR, la_buf);
+ }
+
+ regClusterMax = regClusterCount;
+ regClusterConfig = new registry_configuration_t[regClusterMax];
+ if (regClusterConfig)
+ {
+ rc = tc_get_registry_cluster_set( ®ClusterCount
+ , regClusterMax
+ , regClusterConfig );
+ if ( rc )
+ {
+ char la_buf[MON_STRING_BUF_SIZE];
+ snprintf( la_buf, sizeof(la_buf)
+ , "[%s] Cluster scope configuration registry access failed!\n"
+ , method_name );
+ mon_log_write(MON_CONFIGCONT_INIT_2, SQ_LOG_CRIT, la_buf);
}
+
+ type = ConfigType_Cluster;
- TRACE_EXIT;
- return;
- }
-
- // Read cluster configuration registry entries and populate in-memory
- // structures.
- const char *selStmt;
- selStmt = "select k.keyName, d.dataValue "
- " from monRegKeyName k, monRegClusterData d "
- " where k.keyId = d.keyId";
- sqlite3_stmt *prepStmt;
-
- rc = sqlite3_prepare_v2( db_, selStmt, strlen(selStmt)+1, &prepStmt, NULL);
- if( rc!=SQLITE_OK )
- {
- if (trace_settings & TRACE_INIT)
+ // Process cluster scope configuration registry entries
+ for (int i = 0; i < regClusterCount; i++ )
{
- trace_printf("%s@%d prepare failed, error=%s (%d)\n", method_name,
- __LINE__, sqlite3_errmsg(db_), rc);
+ Set( regClusterConfig[i].scope
+ , type
+ , regClusterConfig[i].key
+ , regClusterConfig[i].value
+ , false );
}
-
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] prepare failed, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
-
- TRACE_EXIT;
- return;
}
-
-
- ConfigType type;
- const unsigned char * group;
- const unsigned char * key;
- const unsigned char * value;
- int rowNum = 1;
-
- while ( 1 )
+ else
{
- rc = sqlite3_step(prepStmt);
- if ( rc == SQLITE_ROW )
- { // Process row
- type = ConfigType_Cluster;
- group = (const unsigned char *) "CLUSTER";
- key = sqlite3_column_text(prepStmt, 0);
- value = sqlite3_column_text(prepStmt, 1);
- if (trace_settings & TRACE_INIT)
- {
- trace_printf("%s@%d row %d: type=%d, group=%s, key=%s, "
- "value=%s\n", method_name, __LINE__, rowNum,
- type, group, key, value);
- }
- Set( (char *) group, type, (char *) key, (char *) value, false );
- ++rowNum;
- }
- else if ( rc == SQLITE_DONE )
- {
- break;
- }
- else
- {
- if (trace_settings & TRACE_INIT)
- {
- trace_printf("%s@%d step failed, retrieving cluster registry "
- "data, error=%s (%d)\n",
- method_name, __LINE__, sqlite3_errmsg(db_), rc);
- }
-
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] step failed, retrieving "
- "cluster registry data, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
-
- break;
- }
+ char la_buf[MON_STRING_BUF_SIZE];
+ snprintf( la_buf, sizeof(la_buf)
+ , "[%s] Node configuration access failed!\n"
+ , method_name );
+ mon_log_write(MON_CONFIGCONT_INIT_3, SQ_LOG_CRIT, la_buf);
}
- // Destroy prepared statement object
- if ( prepStmt != NULL )
- sqlite3_finalize(prepStmt);
-
- // Read process configuration registry entries and populate in-memory
- // structures.
- selStmt = "select p.procName, k.keyName, d.dataValue"
- " from monRegProcName p, monRegKeyName k, monRegProcData d"
- " where p.procId = d.procId"
- " and k.keyId = d.keyId";
-
- rc = sqlite3_prepare_v2( db_, selStmt, strlen(selStmt)+1, &prepStmt, NULL);
- if( rc!=SQLITE_OK )
+ // Get process scope configuration registry entries count
+ rc = tc_get_registry_cluster_set( ®ProcessCount
+ , regProcessMax
+ , NULL );
+ if ( rc )
{
- if (trace_settings & TRACE_INIT)
- {
- trace_printf("%s@%d prepare failed, error=%s (%d)\n", method_name,
- __LINE__, sqlite3_errmsg(db_), rc);
- }
-
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] prepare failed, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
-
- TRACE_EXIT;
- return;
+ char la_buf[MON_STRING_BUF_SIZE];
+ snprintf( la_buf, sizeof(la_buf)
+ , "[%s] Node configuration access failed!\n"
+ , method_name );
+ mon_log_write(MON_CONFIGCONT_INIT_4, SQ_LOG_ERR, la_buf);
}
- rowNum = 1;
-
- while ( 1 )
+ regProcessMax = regProcessCount;
+ regProcessConfig = new registry_configuration_t[regProcessMax];
+ if (regClusterConfig)
{
- rc = sqlite3_step(prepStmt);
- if ( rc == SQLITE_ROW )
- { // Process row
- type = ConfigType_Process;
- group = sqlite3_column_text(prepStmt, 0);
- key = sqlite3_column_text(prepStmt, 1);
- value = sqlite3_column_text(prepStmt, 2);
- if (trace_settings & TRACE_INIT)
- {
- trace_printf("%s@%d row %d: type=%d, group=%s, key=%s, "
- "value=%s\n", method_name, __LINE__, rowNum,
- type, group, key, value);
- }
- Set( (char *) group, type, (char *) key, (char *) value, false );
- ++rowNum;
- }
- else if ( rc == SQLITE_DONE )
+ rc = tc_get_registry_cluster_set( ®ProcessCount
+ , regProcessMax
+ , regProcessConfig );
+ if ( rc )
{
- break;
+ char la_buf[MON_STRING_BUF_SIZE];
+ snprintf( la_buf, sizeof(la_buf)
+ , "[%s] Process scope configuration registry access failed!\n"
+ , method_name );
+ mon_log_write(MON_CONFIGCONT_INIT_5, SQ_LOG_CRIT, la_buf);
}
- else
- {
- if (trace_settings & TRACE_INIT)
- {
- trace_printf("%s@%d step failed, retrieving process registry"
- " data, error=%s (%d)\n",
- method_name, __LINE__, sqlite3_errmsg(db_), rc);
- }
-
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] step failed, retrieving process"
- " registry data, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
+
+ type = ConfigType_Process;
- break;
+ // Process cluster scope configuration registry entries
+ for (int i = 0; i < regClusterCount; i++ )
+ {
+ Set( regProcessConfig[i].scope
+ , type
+ , regProcessConfig[i].key
+ , regProcessConfig[i].value
+ , false );
}
}
+ else
+ {
+ char la_buf[MON_STRING_BUF_SIZE];
+ snprintf( la_buf, sizeof(la_buf)
+ , "[%s] Node configuration access failed!\n"
+ , method_name );
+ mon_log_write(MON_CONFIGCONT_INIT_6, SQ_LOG_CRIT, la_buf);
+ }
- // Destroy prepared statement object
- if ( prepStmt != NULL )
- sqlite3_finalize(prepStmt);
-
TRACE_EXIT;
-
}
CConfigGroup *CConfigContainer::AddGroup(char *groupkey, ConfigType type,
@@ -797,64 +736,24 @@ void CConfigContainer::addDbKeyName ( const char * key )
const char method_name[] = "CConfigContainer::addDbKeyName";
TRACE_ENTRY;
- if ( db_ == NULL)
- {
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d cannot use database since database open"
- " failed.\n", method_name, __LINE__);
- }
-
- TRACE_EXIT;
- return;
- }
-
+ int rc;
+
if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
{
- trace_printf("%s@%d inserting key=%s into monRegKeyName\n",
- method_name, __LINE__, key);
+ trace_printf( "%s@%d saving registry key=%s\n"
+ , method_name, __LINE__
+ , key );
}
- int rc;
- const char * sqlStmt;
- sqlStmt = "insert into monRegKeyName (keyName) values ( :key );";
- sqlite3_stmt * prepStmt;
- rc = sqlite3_prepare_v2( db_, sqlStmt, strlen(sqlStmt)+1, &prepStmt,
- NULL);
- if ( rc != SQLITE_OK )
+ rc = tc_put_registry_key( key );
+ if ( rc )
{
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d prepare failed, error=%s (%d)\n",
- method_name, __LINE__, sqlite3_errmsg(db_), rc);
- }
-
char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] prepare failed, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
+ snprintf( buf, sizeof(buf)
+ , "[%s] tc_put_registry_key() failed, error=%d (%s)\n"
+ , method_name, rc, tc_errmsg( rc ) );
+ mon_log_write( MON_CONFIGCONT_ADDKEYNAME_1, SQ_LOG_ERR, buf );
}
- else
- {
- sqlite3_bind_text( prepStmt,
- sqlite3_bind_parameter_index( prepStmt, ":key" ),
- key, -1, SQLITE_STATIC );
-
- rc = sqlite3_step( prepStmt );
- if (( rc != SQLITE_DONE ) && ( rc != SQLITE_ROW )
- && ( rc != SQLITE_CONSTRAINT ) )
- {
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf),
- "[%s] inserting key=%s into "
- "monRegKeyName failed, error=%s (%d)\n",
- method_name, key, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
- }
- }
-
- if ( prepStmt != NULL )
- sqlite3_finalize( prepStmt );
TRACE_EXIT;
}
@@ -865,64 +764,24 @@ void CConfigContainer::addDbProcName ( const char * name )
const char method_name[] = "CConfigContainer::addDbProcName";
TRACE_ENTRY;
- if ( db_ == NULL)
- {
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d cannot use database since database open"
- " failed.\n", method_name, __LINE__);
- }
-
- TRACE_EXIT;
- return;
- }
-
+ int rc;
+
if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
{
- trace_printf("%s@%d inserting name=%s into monRegProcName\n",
- method_name, __LINE__, name);
+ trace_printf( "%s@%d saving registry process, name=%s\n"
+ , method_name, __LINE__
+ , name );
}
- int rc;
- const char * sqlStmt;
- sqlStmt = "insert into monRegProcName (procName) values ( :name );";
- sqlite3_stmt * prepStmt;
- rc = sqlite3_prepare_v2( db_, sqlStmt, strlen(sqlStmt)+1, &prepStmt,
- NULL);
- if ( rc != SQLITE_OK )
+ rc = tc_put_registry_process( name );
+ if ( rc )
{
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d prepare failed, error=%s (%d)\n",
- method_name, __LINE__, sqlite3_errmsg(db_), rc);
- }
-
char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] prepare failed, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
- }
- else
- {
- sqlite3_bind_text( prepStmt,
- sqlite3_bind_parameter_index( prepStmt, ":name" ),
- name, -1, SQLITE_STATIC );
-
- rc = sqlite3_step( prepStmt );
- if (( rc != SQLITE_DONE ) && ( rc != SQLITE_ROW )
- && ( rc != SQLITE_CONSTRAINT ) )
- {
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf),
- "[%s] inserting name=%s into "
- "monRegProcName failed, error=%s (%d)\n",
- method_name, name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
- }
+ snprintf( buf, sizeof(buf)
+ , "[%s] tc_put_registry_process() failed, error=%d (%s)\n"
+ , method_name, rc, tc_errmsg( rc ) );
+ mon_log_write( MON_CONFIGCONT_ADDPROCNAME_1, SQ_LOG_ERR, buf );
}
-
- if ( prepStmt != NULL )
- sqlite3_finalize( prepStmt );
TRACE_EXIT;
}
@@ -933,70 +792,24 @@ void CConfigContainer::addDbClusterData ( const char * key,
const char method_name[] = "CConfigContainer::addDbClusterData";
TRACE_ENTRY;
- if ( db_ == NULL)
- {
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d cannot use database since database open"
- " failed.\n", method_name, __LINE__);
- }
-
- TRACE_EXIT;
- return;
- }
-
+ int rc;
+
if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
{
- trace_printf("%s@%d inserting key=%s into monRegClusterData\n",
- method_name, __LINE__, key);
+ trace_printf( "%s@%d saving registry cluster data key=%s\n"
+ , method_name, __LINE__
+ , key);
}
- int rc;
- const char * sqlStmt;
- sqlStmt = "insert or replace into monRegClusterData (dataValue, keyId)"
- " select :dataValue,"
- " k.keyId FROM monRegKeyName k"
- " where k.keyName = :key";
- sqlite3_stmt * prepStmt;
- rc = sqlite3_prepare_v2( db_, sqlStmt, strlen(sqlStmt)+1, &prepStmt,
- NULL);
- if ( rc != SQLITE_OK )
+ rc = tc_put_registry_cluster_data( key, dataValue );
+ if ( rc )
{
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d prepare failed, error=%s (%d)\n",
- method_name, __LINE__, sqlite3_errmsg(db_), rc);
- }
-
char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] prepare failed, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
- }
- else
- {
- sqlite3_bind_text( prepStmt,
- sqlite3_bind_parameter_index( prepStmt,
- ":dataValue" ),
- dataValue, -1, SQLITE_STATIC );
- sqlite3_bind_text( prepStmt,
- sqlite3_bind_parameter_index( prepStmt, ":key" ),
- key, -1, SQLITE_STATIC );
-
- rc = sqlite3_step( prepStmt );
- if (( rc != SQLITE_DONE ) && ( rc != SQLITE_ROW )
- && ( rc != SQLITE_CONSTRAINT ) )
- {
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] inserting key=%s into "
- "monRegClusterData failed, error=%s (%d)\n",
- method_name, key, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
- }
+ snprintf( buf, sizeof(buf)
+ , "[%s] tc_put_registry_cluster_data() failed, error=%d (%s)\n"
+ , method_name, rc, tc_errmsg( rc ) );
+ mon_log_write( MON_CONFIGCONT_ADDCLUSTERDATA_1, SQ_LOG_ERR, buf );
}
-
- if ( prepStmt != NULL )
- sqlite3_finalize( prepStmt );
TRACE_EXIT;
}
@@ -1008,80 +821,26 @@ void CConfigContainer::addDbProcData ( const char * procName,
const char method_name[] = "CConfigContainer::addDbProcData";
TRACE_ENTRY;
- if ( db_ == NULL)
- {
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d cannot use database since database open"
- " failed.\n", method_name, __LINE__);
- }
-
- TRACE_EXIT;
- return;
- }
-
+ int rc;
+
if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
{
- trace_printf("%s@%d inserting key=%s into monRegProcData for "
- "proc=%s\n", method_name, __LINE__, key, procName);
+ trace_printf( "%s@%d saving registry process data procName=%s, "
+ "key=%s\n"
+ , method_name, __LINE__
+ , procName, key );
}
- int rc;
- const char * sqlStmt;
- sqlStmt = "insert or replace into monRegProcData (dataValue, procId, keyId )"
- " select :dataValue,"
- " p.procId,"
- " (SELECT k.keyId "
- " FROM monRegKeyName k"
- " WHERE k.keyName = :key)"
- " FROM monRegProcName p"
- " WHERE UPPER(p.procName) = UPPER(:procName)";
-
- sqlite3_stmt * prepStmt;
- rc = sqlite3_prepare_v2( db_, sqlStmt, strlen(sqlStmt)+1, &prepStmt,
- NULL);
- if ( rc != SQLITE_OK )
+ rc = tc_put_registry_process_data( procName, key, dataValue );
+ if ( rc )
{
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d prepare failed, error=%s (%d)\n",
- method_name, __LINE__, sqlite3_errmsg(db_), rc);
- }
-
char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] prepare failed, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
- }
- else
- {
- sqlite3_bind_text( prepStmt,
- sqlite3_bind_parameter_index( prepStmt,
- ":procName" ),
- procName, -1, SQLITE_STATIC );
- sqlite3_bind_text( prepStmt,
- sqlite3_bind_parameter_index( prepStmt,
- ":dataValue" ),
- dataValue, -1, SQLITE_STATIC );
- sqlite3_bind_text( prepStmt,
- sqlite3_bind_parameter_index( prepStmt, ":key" ),
- key, -1, SQLITE_STATIC );
-
- rc = sqlite3_step( prepStmt );
- if (( rc != SQLITE_DONE ) && ( rc != SQLITE_ROW )
- && ( rc != SQLITE_CONSTRAINT ) )
- {
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] inserting key=%s into "
- "monRegProcData for proc=%s failed, error=%s (%d)\n",
- method_name, key, procName, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
- }
+ snprintf( buf, sizeof(buf)
+ , "[%s] tc_put_registry_process_data() failed, error=%d (%s)\n"
+ , method_name, rc, tc_errmsg( rc ) );
+ mon_log_write( MON_CONFIGCONT_ADDPROCDATA_1, SQ_LOG_ERR, buf );
}
- if ( prepStmt != NULL )
- sqlite3_finalize( prepStmt );
-
TRACE_EXIT;
}
@@ -1090,145 +849,66 @@ void CConfigContainer::addUniqueString(int nid, int id, const char * uniqStr )
const char method_name[] = "CConfigContainer::addUniqueString";
TRACE_ENTRY;
- if ( db_ == NULL)
- {
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d cannot use database since database open"
- " failed.\n", method_name, __LINE__);
- }
-
- TRACE_EXIT;
- return;
- }
-
-
+ int rc;
+
if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
{
- trace_printf("%s@%d inserting unique string nid=%d id=%d into "
- "monRegUniqueStrings\n", method_name, __LINE__,
- nid, id);
+ trace_printf( "%s@%d saving unique string nid=%d id=%d\n"
+ , method_name, __LINE__
+ , nid, id );
}
- int rc;
- const char * sqlStmt;
- sqlStmt = "insert or replace into monRegUniqueStrings values (?, ?, ?)";
-
- sqlite3_stmt * prepStmt;
- rc = sqlite3_prepare_v2( db_, sqlStmt, strlen(sqlStmt)+1, &prepStmt,
- NULL);
- if ( rc != SQLITE_OK )
+ rc = tc_put_unique_string( nid, id, uniqStr );
+ if ( rc )
{
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d prepare failed, error=%s (%d)\n",
- method_name, __LINE__, sqlite3_errmsg(db_), rc);
- }
-
char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] prepare failed, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
+ snprintf( buf, sizeof(buf)
+ , "[%s] tc_put_unique_string() failed, error=%d (%s)\n"
+ , method_name, rc, tc_errmsg( rc ) );
+ mon_log_write( MON_CONFIGCONT_ADDUNIQUESTRING_1, SQ_LOG_ERR, buf );
}
- else
- {
- sqlite3_bind_int( prepStmt, 1, nid );
- sqlite3_bind_int( prepStmt, 2, id );
- sqlite3_bind_text( prepStmt, 3, uniqStr, -1, SQLITE_STATIC );
-
- rc = sqlite3_step( prepStmt );
- if ( rc != SQLITE_DONE )
- {
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf),
- "[%s] inserting into monRegUniqueStrings "
- "for nid=%d id=%d failed, error=%s (%d)\n",
- method_name, nid, id, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
- }
- }
-
- if ( prepStmt != NULL )
- sqlite3_finalize( prepStmt );
TRACE_EXIT;
}
-bool CConfigContainer::findUniqueString(int nid, const char * uniqStr,
- strId_t & id )
+bool CConfigContainer::findUniqueString( int nid
+ , const char *uniqStr
+ , strId_t &strId )
{
const char method_name[] = "CConfigContainer::findUniqueString";
TRACE_ENTRY;
- if ( db_ == NULL)
- {
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d cannot use database since database open"
- " failed.\n", method_name, __LINE__);
- }
-
- TRACE_EXIT;
- return false;
- }
-
+ bool result = false;
+ int rc;
+ int id;
if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
{
- trace_printf("%s@%d finding unique string nid=%d string=%s in "
- "monRegUniqueStrings\n", method_name, __LINE__,
- nid, uniqStr);
+ trace_printf( "%s@%d finding unique string nid=%d string=%s\n"
+ , method_name, __LINE__
+ , nid, uniqStr );
}
-
- bool result = false;
- int rc;
- const char * sqlStmt;
- sqlStmt = "select id from monRegUniqueStrings where nid = ? and dataValue = ?";
-
- sqlite3_stmt * prepStmt;
- rc = sqlite3_prepare_v2( db_, sqlStmt, strlen(sqlStmt)+1, &prepStmt,
- NULL);
-
- if ( rc != SQLITE_OK )
+ rc = tc_get_unique_string_id( nid, uniqStr, &id );
+ if ( rc )
{
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
+ if ( rc != TCDBNOEXIST )
{
- trace_printf("%s@%d prepare failed, error=%s (%d)\n",
- method_name, __LINE__, sqlite3_errmsg(db_), rc);
+ char buf[MON_STRING_BUF_SIZE];
+ snprintf( buf, sizeof(buf)
+ , "[%s] tc_get_unique_string_id() failed, ""error=%d (%s)\n"
+ , method_name, rc, tc_errmsg( rc ) );
+ mon_log_write( MON_CONFIGCONT_FINDUNIQUESTRING_1, SQ_LOG_ERR, buf );
}
-
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] prepare failed, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
}
else
{
- sqlite3_bind_int( prepStmt, 1, nid );
- sqlite3_bind_text( prepStmt, 2, uniqStr, -1, SQLITE_STATIC );
-
- rc = sqlite3_step( prepStmt );
-
- if ( rc == SQLITE_ROW )
- { // Found string in database, return id
- id.nid = nid;
- id.id = sqlite3_column_int (prepStmt, 0);
- result = true;
-
- if (trace_settings & TRACE_REQUEST)
- {
- trace_printf("%s@%d found unique string nid=%d, id=%d\n",
- method_name, __LINE__, nid, id.id);
- }
- }
+ strId.nid = nid;
+ strId.id = id;
+ result = true;
}
- if ( prepStmt != NULL )
- sqlite3_finalize( prepStmt );
-
TRACE_EXIT;
-
return result;
}
@@ -1237,81 +917,39 @@ int CConfigContainer::getMaxUniqueId( int nid )
const char method_name[] = "CConfigContainer::getMaxUniqueId";
TRACE_ENTRY;
+ int id = 0;
+ int rc;
- if ( db_ == NULL)
+ if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
{
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d cannot use database since database open"
- " failed.\n", method_name, __LINE__);
- }
-
- TRACE_EXIT;
- return false;
+ trace_printf( "%s@%d finding max unique string id for nid=%d\n"
+ , method_name, __LINE__
+ , nid );
}
-
- int result = 0;
- int rc;
- const char * sqlStmt;
- sqlStmt = "select max(id) from monRegUniqueStrings where nid=?";
-
- sqlite3_stmt * prepStmt;
- rc = sqlite3_prepare_v2( db_, sqlStmt, strlen(sqlStmt)+1, &prepStmt,
- NULL);
- if ( rc != SQLITE_OK )
+ rc = tc_get_unique_string_id_max( nid, &id );
+ if ( rc )
{
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
+ if ( rc != TCDBNOEXIST )
{
- trace_printf("%s@%d prepare failed, error=%s (%d)\n",
- method_name, __LINE__, sqlite3_errmsg(db_), rc);
+ char buf[MON_STRING_BUF_SIZE];
+ snprintf( buf, sizeof(buf)
+ , "[%s] tc_get_unique_string_id_max() failed, error=%d (%s)\n"
+ , method_name, rc, tc_errmsg( rc ) );
+ mon_log_write( MON_CONFIGCONT_GETUNIQUESTRIDMAX_1, SQ_LOG_ERR, buf );
}
-
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] prepare failed, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
}
else
{
- sqlite3_bind_int( prepStmt, 1, nid );
-
- rc = sqlite3_step( prepStmt );
-
- if ( rc == SQLITE_ROW )
- {
- result = sqlite3_column_int(prepStmt, 0);
-
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d found max(id)=%d for nid=%d in "
- "monRegUniqueStrings\n", method_name, __LINE__,
- result, nid);
- }
- }
- else
+ if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
{
- if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
- {
- trace_printf("%s@%d finding max(id) in monRegUniqueStrings "
- "for nid=%d, error=%s (%d)\n", method_name, __LINE__,
- nid, sqlite3_errmsg(db_), rc);
- }
-
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] finding max(id) in monRegUnique"
- "Strings for nid=%d, error=%s (%d)\n",
- method_name, nid, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
+ trace_printf( "%s@%d found max(id)=%d for nid=%d\n"
+ , method_name, __LINE__, id, nid);
}
}
-
- if ( prepStmt != NULL )
- sqlite3_finalize( prepStmt );
TRACE_EXIT;
-
- return result;
+ return id;
}
void CConfigContainer::strIdToString( strId_t stringId, string & value )
@@ -1320,61 +958,32 @@ void CConfigContainer::strIdToString( strId_t stringId, string & value )
TRACE_ENTRY;
int rc;
- const char * selStmt;
- sqlite3_stmt * prepStmt;
+ char uniqueString[TC_UNIQUE_STRING_VALUE_MAX] = { 0 };
- // Read process configuration registry entries and populate in-memory
- // structures.
- selStmt = "select dataValue from monRegUniqueStrings where nid = ? and id = ?";
- rc = sqlite3_prepare_v2( db_, selStmt, strlen(selStmt)+1, &prepStmt, NULL);
+ if (trace_settings & (TRACE_INIT | TRACE_REQUEST))
+ {
+ trace_printf( "%s@%d Get unique string, stringId(nid=%d, id=%d)\n"
+ , method_name, __LINE__
+ , stringId.nid, stringId.id );
+ }
- if ( rc != SQLITE_OK )
+ rc = tc_get_unique_string( stringId.nid, stringId.id, uniqueString );
+ if ( rc )
{
- if (trace_settings & TRACE_REQUEST)
+ value.assign( "" );
+ if ( rc != TCDBNOEXIST )
{
- trace_printf("%s@%d prepare failed, error=%s (%d)\n",
- method_name, __LINE__, sqlite3_errmsg(db_), rc);
+ char buf[MON_STRING_BUF_SIZE];
+ snprintf( buf, sizeof(buf)
+ , "[%s] tc_get_unique_string() failed, ""error=%d (%s)\n"
+ , method_name, rc, tc_errmsg( rc ) );
+ mon_log_write( MON_CONFIGCONT_STRINGIDTPSTRING_1, SQ_LOG_ERR, buf );
}
-
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] prepare failed, error=%s (%d)\n",
- method_name, sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
}
else
{
- sqlite3_bind_int ( prepStmt, 1, stringId.nid );
- sqlite3_bind_int ( prepStmt, 2, stringId.id );
-
- rc = sqlite3_step( prepStmt );
-
- if ( rc == SQLITE_ROW )
- {
- value.assign( (const char *) sqlite3_column_text(prepStmt, 0) );
-
- if (trace_settings & TRACE_REQUEST)
- {
- trace_printf("%s@%d retrieved unique string (%d, %d), "
- "value=%s\n", method_name, __LINE__,
- stringId.nid, stringId.id, value.c_str());
- }
- }
- else
- {
- value.assign( "" );
-
- char buf[MON_STRING_BUF_SIZE];
- snprintf( buf, sizeof(buf), "[%s] unable to retrieve unique string"
- " (%d, %d), error=%s (%d)\n",
- method_name, stringId.nid, stringId.id,
- sqlite3_errmsg(db_), rc );
- mon_log_write( MON_DATABASE_ERROR, SQ_LOG_ERR, buf );
- }
-
+ value.assign( uniqueString );
}
-
- if ( prepStmt != NULL )
- sqlite3_finalize( prepStmt );
TRACE_EXIT;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/config.h
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/config.h b/core/sqf/monitor/linux/config.h
index 3aacf86..ea606de 100644
--- a/core/sqf/monitor/linux/config.h
+++ b/core/sqf/monitor/linux/config.h
@@ -27,7 +27,7 @@
#define CONFIG_H_
#include <string>
-#include <sqlite3.h>
+//#include <sqlite3.h>
#include "msgdef.h"
#include "internal.h"
#include "clusterconf.h"
@@ -135,7 +135,7 @@ private:
char localNodeName_[MAX_KEY_NAME];
CConfigGroup *Head; // Head of process configuration group list
CConfigGroup *Tail; // Tail of process configuration group list
- sqlite3 *db_;
+ //sqlite3 *db_;
};
#endif /*CONFIG_H_*/
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/gentrap.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/gentrap.cxx b/core/sqf/monitor/linux/gentrap.cxx
index 5a6ea6a..cbf4363 100644
--- a/core/sqf/monitor/linux/gentrap.cxx
+++ b/core/sqf/monitor/linux/gentrap.cxx
@@ -40,7 +40,7 @@ void genSnmpTrap ( const char *event )
trace_printf( "%s@%d - snmptrap(%d): %s\n"
, method_name, __LINE__, genSnmpTrapEnabled, event);
- snmp_log_write( MON_GEN_SNMP_TRAP, (char *)event );
+ mon_log_write( MON_GEN_SNMP_TRAP, SQ_LOG_CRIT, (char *)event );
if ( genSnmpTrapEnabled )
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/lnodeconfig.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/lnodeconfig.cxx b/core/sqf/monitor/linux/lnodeconfig.cxx
index 34dee6d..34df543 100644
--- a/core/sqf/monitor/linux/lnodeconfig.cxx
+++ b/core/sqf/monitor/linux/lnodeconfig.cxx
@@ -47,19 +47,14 @@ using namespace std;
///////////////////////////////////////////////////////////////////////////////
CLNodeConfig::CLNodeConfig( CPNodeConfig *pnodeConfig
- , int nid
- , cpu_set_t &coreMask
- , int firstCore
- , int lastCore
- , int processors
- , ZoneType zoneType
+ , lnodeConfigInfo_t &lnodeConfigInfo
)
- : nid_(nid)
- , coreMask_(coreMask)
- , firstCore_(firstCore)
- , lastCore_(lastCore)
- , processors_(processors)
- , zoneType_(zoneType)
+ : nid_(lnodeConfigInfo.nid)
+ , coreMask_(lnodeConfigInfo.coreMask)
+ , firstCore_(lnodeConfigInfo.firstCore)
+ , lastCore_(lnodeConfigInfo.lastCore)
+ , processors_(lnodeConfigInfo.processor)
+ , zoneType_(lnodeConfigInfo.zoneType)
, pnodeConfig_(pnodeConfig)
, next_(NULL)
, prev_(NULL)
@@ -230,41 +225,32 @@ CLNodeConfig *CLNodeConfigContainer::AddLNodeConfigP( CLNodeConfig *lnodeConfig
}
CLNodeConfig *CLNodeConfigContainer::AddLNodeConfig( CPNodeConfig *pnodeConfig
- , int nid
- , cpu_set_t &coreMask
- , int firstCore
- , int lastCore
- , int processors
- , ZoneType zoneType
+ , lnodeConfigInfo_t &lnodeConfigInfo
)
{
const char method_name[] = "CLNodeConfigContainer::AddLNodeConfig";
TRACE_ENTRY;
// nid list is NOT sequential from zero
- if ( ! (nid >= 0 && nid < lnodesConfigMax_) )
+ if ( ! (lnodeConfigInfo.nid >= 0 && lnodeConfigInfo.nid < lnodesConfigMax_) )
{
char la_buf[MON_STRING_BUF_SIZE];
- sprintf(la_buf, "[%s], Error: Invalid nid=%d - should be >= 0 and < %d)\n", method_name, nid, lnodesConfigMax_);
+ sprintf( la_buf, "[%s], Error: Invalid nid=%d - should be >= 0 and < %d)\n"
+ , method_name, lnodeConfigInfo.nid, lnodesConfigMax_);
mon_log_write(MON_LNODECONF_ADD_LNODE_1, SQ_LOG_CRIT, la_buf);
return( NULL );
}
- assert( lnodesConfig_[nid] == NULL );
+ assert( lnodesConfig_[lnodeConfigInfo.nid] == NULL );
CLNodeConfig *lnodeConfig = new CLNodeConfig( pnodeConfig
- , nid
- , coreMask
- , firstCore
- , lastCore
- , processors
- , zoneType );
+ , lnodeConfigInfo );
if (lnodeConfig)
{
// Bump the logical node count
lnodesCount_++;
// Add it to the array
- lnodesConfig_[nid] = lnodeConfig;
+ lnodesConfig_[lnodeConfigInfo.nid] = lnodeConfig;
// Add it to the container list
if ( head_ == NULL )
{
@@ -278,7 +264,7 @@ CLNodeConfig *CLNodeConfigContainer::AddLNodeConfig( CPNodeConfig *pnodeConfig
}
// Set the next available nid
- nextNid_ = (nid == nextNid_) ? (nid+1) : nextNid_ ;
+ nextNid_ = (lnodeConfigInfo.nid == nextNid_) ? (lnodeConfigInfo.nid+1) : nextNid_ ;
if ( nextNid_ == lnodesConfigMax_ )
{ // We are at the limit, search for unused nid from begining
nextNid_ = -1;
@@ -311,7 +297,7 @@ CLNodeConfig *CLNodeConfigContainer::AddLNodeConfig( CPNodeConfig *pnodeConfig
" (nid=%d, pnid=%d, nextNid_=%d)\n"
" (lnodesCount_=%d,lnodesConfigMax=%d)\n"
, method_name, __LINE__
- , nid, pnodeConfig->GetPNid(), nextNid_
+ , lnodeConfigInfo.nid, pnodeConfig->GetPNid(), nextNid_
, lnodesCount_, lnodesConfigMax_);
}
}
@@ -319,7 +305,8 @@ CLNodeConfig *CLNodeConfigContainer::AddLNodeConfig( CPNodeConfig *pnodeConfig
{
int err = errno;
char la_buf[MON_STRING_BUF_SIZE];
- sprintf(la_buf, "[%s], Error: Can't allocate logical node configuration object - errno=%d (%s)\n", method_name, err, strerror(errno));
+ sprintf( la_buf, "[%s], Error: Can't allocate logical node configuration object - errno=%d (%s)\n"
+ , method_name, err, strerror(errno));
mon_log_write(MON_LNODECONF_ADD_LNODE_2, SQ_LOG_ERR, la_buf);
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/lnodeconfig.h
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/lnodeconfig.h b/core/sqf/monitor/linux/lnodeconfig.h
index abeab48..37185c8 100644
--- a/core/sqf/monitor/linux/lnodeconfig.h
+++ b/core/sqf/monitor/linux/lnodeconfig.h
@@ -26,6 +26,19 @@
#ifndef LNODECONFIG_H_
#define LNODECONFIG_H_
+typedef struct lnodeConfigInfo_s
+{
+ int nid;
+ int pnid;
+ char nodename[MPI_MAX_PROCESSOR_NAME];
+ int firstCore;
+ int lastCore;
+ cpu_set_t coreMask;
+ int processor;
+ ZoneType zoneType;
+} lnodeConfigInfo_t;
+
+
class CLNodeConfig;
class CPNodeConfig;
@@ -35,15 +48,8 @@ public:
CLNodeConfigContainer( void );
CLNodeConfigContainer( int lnodesConfigMax );
~CLNodeConfigContainer( void );
-
CLNodeConfig *AddLNodeConfig( CPNodeConfig *pnodeConfig
- , int nid
- , cpu_set_t &coreMask
- , int firstCore
- , int lastCore
- , int processors
- , ZoneType zoneType
- );
+ , lnodeConfigInfo_t &lnodeConfigInfo );
CLNodeConfig *AddLNodeConfigP( CLNodeConfig *lnodeConfig );
void Clear( void );
void DeleteLNodeConfig( CLNodeConfig *lnodeConfig );
@@ -69,24 +75,13 @@ private:
class CLNodeConfig
{
friend CLNodeConfig *CLNodeConfigContainer::AddLNodeConfig( CPNodeConfig *pnodeConfig
- , int nid
- , cpu_set_t &coreMask
- , int firstCore
- , int lastCore
- , int processors
- , ZoneType zoneType
- );
+ , lnodeConfigInfo_t &lnodeConfigInfo );
friend CLNodeConfig *CLNodeConfigContainer::AddLNodeConfigP( CLNodeConfig *lnodeConfig );
friend void CLNodeConfigContainer::DeleteLNodeConfig( CLNodeConfig *lnodeConfig );
friend void CLNodeConfigContainer::RemoveLNodeConfigP( CLNodeConfig *lnodeConfig );
public:
CLNodeConfig( CPNodeConfig *pnodeConfig
- , int nid
- , cpu_set_t &coreMask
- , int firstCore
- , int lastCore
- , int processors
- , ZoneType zoneType
+ , lnodeConfigInfo_t &lnodeConfigInfo
);
~CLNodeConfig( void );
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/makefile
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/makefile b/core/sqf/monitor/linux/makefile
index 0660414..c8660a3 100644
--- a/core/sqf/monitor/linux/makefile
+++ b/core/sqf/monitor/linux/makefile
@@ -33,7 +33,7 @@ endif
#DEBUG = -O0 -g3
DEBUG = $(CFLAGS)
-FLAGS = $(DEBUG) -Wno-deprecated -fmessage-length=0
+FLAGS = $(DEBUG) -Wno-deprecated -fmessage-length=0 -fPIC
ifeq ($(USE_DMALLOC),1)
FLAGS+= -DDMALLOC
endif
@@ -48,14 +48,14 @@ FLAGS+= -UNDEBUG
FLAGS+= -Wall -Wextra
# Flags for use in compiling Seabed trace modules
-SBFLAGS = -Wall -Wextra -pedantic -Werror -Wno-long-long $(DBG_FLGS) $(OPTIM_FLGS) -Xlinker --copy-dt-needed-entries
+SBFLAGS = -Wall -Wextra -pedantic -Werror -Wno-long-long $(DBG_FLGS) $(OPTIM_FLGS) -Xlinker --copy-dt-needed-entries -fPIC
SBDIR = ../../src/seabed/src
COMMONLOGGERDIR = ../../commonLogger
INCLUDE = monitor.h msgdef.h internal.h monlogging.h clio.h mlio.h localio.h lock.h
-LIBS = -L$(LIBEXPDIR) -L$(ZOOKEEPER_DIR)/lib -lrt -lsblogalt -lzookeeper_mt
+LIBS = -L$(LIBEXPDIR) -L$(ZOOKEEPER_DIR)/lib -lrt -lsblogalt -lzookeeper_mt -ltrafconfig
LIBS+= -lmpich
@@ -151,6 +151,7 @@ MONITORSRC += reqzoneinfo.cxx
MONITORSRC += replicate.cxx
MONITORSRC += gentrap.cxx
MONITORSRC += monrobsem.cxx
+
MONITOROBJS = $(OUTDIR)/versmon.o
MONITOROBJS += $(OUTDIR)/monitor.o
MONITOROBJS += $(OUTDIR)/cluster.o
@@ -285,6 +286,30 @@ TRACE_LOG_OBJS += $(OUTDIR)/threadtls.o
RTSIGBLOCK_SRC = rtsigblock.cxx
RTSIGBLOCK_OBJS = $(OUTDIR)/rtsigblock.o
+CONFOBJS = $(OUTDIR)/testconf.o
+CONFOBJS += $(OUTDIR)/clusterconf.o
+CONFOBJS += $(OUTDIR)/lnodeconfig.o
+CONFOBJS += $(OUTDIR)/pnodeconfig.o
+CONFOBJS += $(OUTDIR)/persistconfig.o
+
+TRAFCONFOBJS = $(OUTDIR)/trafconf.o
+TRAFCONFOBJS += $(OUTDIR)/clusterconf.o
+TRAFCONFOBJS += $(OUTDIR)/lnodeconfig.o
+TRAFCONFOBJS += $(OUTDIR)/pnodeconfig.o
+TRAFCONFOBJS += $(OUTDIR)/persistconfig.o
+
+SQLITECONFIG_SRC = sqliteconfig.cxx
+SQLITECONFIG_OBJS = $(OUTDIR)/sqliteconfig.o
+
+TRAFCONFIGLOG_SRC = trafconfiglog.cxx
+TRAFCONFIGLOG_OBJS = $(OUTDIR)/trafconfiglog.o
+
+TRAFCONFIGTRACE_SRC = trafconfigtrace.cxx
+TRAFCONFIGTRACE_OBJS = $(OUTDIR)/trafconfigtrace.o
+
+TRAFCONFIG_SRC = trafconfig.cxx
+TRAFCONFIG_OBJS = $(OUTDIR)/trafconfig.o
+
ALLOBJS = $(MONITOROBJS)
ALLOBJS += $(SHELLOBJS)
ALLOBJS += $(CLIENTOBJS)
@@ -296,16 +321,22 @@ ALLOBJS += $(TRACE_LOG_OBJS)
ALLOBJS += $(CONFOBJS)
ALLOBJS += $(MEMLOGOBJS)
ALLOBJS += $(RTSIGBLOCK_OBJS)
-ALLOBJS += $(TCONFOBJS)
ALLOBJS += $(ZOOMONOBJS)
+ALLOBJS += $(TRAFCONFOBJS)
+ALLOBJS += $(SQLITECONFIG_OBJS)
+ALLOBJS += $(TRAFCONFIG_OBJS)
+ALLOBJS += $(TRAFCONFIGLOG_OBJS)
+ALLOBJS += $(TRAFCONFIGTRACE_OBJS)
+
+SHAREDLIBS = $(LIBEXPDIR)/libtrafconfig.so
+SHAREDLIBS += $(LIBEXPDIR)/libseabasesig.so
-PGMS = $(BINEXPDIR)/monitor
+PGMS = $(BINEXPDIR)/monitor
PGMS += $(BINEXPDIR)/shell
PGMS += $(BINEXPDIR)/sqwatchdog
PGMS += $(BINEXPDIR)/monmemlog
PGMS += $(BINEXPDIR)/pstartd
PGMS += $(BINEXPDIR)/trafconf
-PGMS += $(LIBEXPDIR)/libseabasesig.so
TEST_PGMS = $(OUTDIR)/client
TEST_PGMS += $(OUTDIR)/client2
@@ -388,15 +419,19 @@ $(OUTDIR)/%.o:$(COMMONLOGGERDIR)/%.cpp $(INCLUDE)
# Targets
# Uncomment the following target to disable parallel make
-#.NOTPARALLEL: $(PGMS)
+.NOTPARALLEL:
-all: $(PGMS) example
+all: programs examples
+
+programs: sharedlibs $(PGMS)
+
+examples: $(TEST_PGMS)
+
+sharedlibs: $(SHAREDLIBS)
montim:
@$(MAKE) $(OUTDIR)/montim
-example : $(TEST_PGMS)
-
$(OUTDIR)/client : client.cxx $(CLIENTOBJS) $(TRACE_LOG_OBJS)
$(OUTDIR)/nsclient : nsclient.cxx $(CLIENTOBJS) $(TRACE_LOG_OBJS)
@@ -419,18 +454,6 @@ $(OUTDIR)/testtm : testtm.cxx $(CLIENTOBJS) $(TRACE_LOG_OBJS)
$(OUTDIR)/pingpong2 : pingpong2.cxx $(CLIENTOBJS) $(TRACE_LOG_OBJS)
-CONFOBJS = $(OUTDIR)/testconf.o \
- $(OUTDIR)/clusterconf.o \
- $(OUTDIR)/lnodeconfig.o \
- $(OUTDIR)/pnodeconfig.o \
- $(OUTDIR)/persistconfig.o
-
-TCONFOBJS = $(OUTDIR)/trafconf.o \
- $(OUTDIR)/clusterconf.o \
- $(OUTDIR)/lnodeconfig.o \
- $(OUTDIR)/pnodeconfig.o \
- $(OUTDIR)/persistconfig.o
-
$(OUTDIR)/testconf : $(CONFOBJS) $(TRACE_LOG_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: Linker'
@@ -439,7 +462,7 @@ $(OUTDIR)/testconf : $(CONFOBJS) $(TRACE_LOG_OBJS)
@echo 'Finished building target: $@'
@echo ' '
-$(BINEXPDIR)/trafconf : $(TCONFOBJS) $(TRACE_LOG_OBJS)
+$(BINEXPDIR)/trafconf : $(TRAFCONFOBJS) $(TRACE_LOG_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: Linker'
@echo $(CXX) $(CDEPFLAGS) $(FLAGS) $(OPTIONS) $(INCLUDES) -o $@ -lrt $^
@@ -506,6 +529,15 @@ $(LIBEXPDIR)/libseabasesig.so: $(RTSIGBLOCK_OBJS)
@echo 'Finished building target: $@'
@echo ' '
+$(LIBEXPDIR)/libtrafconfig.so: $(TRAFCONFIG_OBJS) $(SQLITECONFIG_OBJS) $(TRACE_LOG_OBJS) $(TRAFCONFIGLOG_OBJS) $(TRAFCONFIGTRACE_OBJS)
+ @echo 'Building target: $@'
+ @echo 'Invoking: Linker'
+ @echo $(CXX) $(LNK_FLGS) -shared -o $@ $(TRAFCONFIG_OBJS) $(SQLITECONFIG_OBJS) $(TRACE_LOG_OBJS) $(TRAFCONFIGLOG_OBJS) $(TRAFCONFIGTRACE_OBJS)
+ @$(CXX) $(LNK_FLGS) -shared -o $@ $(TRAFCONFIG_OBJS) $(SQLITECONFIG_OBJS) $(TRACE_LOG_OBJS) $(TRAFCONFIGLOG_OBJS) $(TRAFCONFIGTRACE_OBJS)
+ @echo 'Finished building target: $@'
+ @echo ' '
+
+
setup:
@# do nothing
@@ -514,6 +546,7 @@ clean:
-rm -f $(ALLOBJS)
-rm -f $(CDEP_DIR)/*.dep
-rm -f $(LIBEXPDIR)/libseabasesig.so
+ -rm -f $(LIBEXPDIR)/libtrafconfig.so
@echo ' '
cleanall: clean
@@ -522,29 +555,20 @@ cleanall: clean
cleaner: clean
-rm -f *~
-install:
- @echo 'Installing programs in $(INSTALL_DIR)'
- -cp $(PGMS) $(INSTALL_DIR)
- @echo 'Finished installing programs'
- @echo ' '
+#install:
+# @echo 'Installing programs in $(INSTALL_DIR)'
+# -cp $(PGMS) $(INSTALL_DIR)
+# @echo 'Finished installing programs'
+# @echo ' '
-uninstall:
- @echo 'Uninstalling programs from $(INSTALL_DIR)'
- -cd $(INSTALL_DIR);rm -f $(PGMS) $(TEST_PGMS)
- @echo 'Finished uninstalling programs'
- @echo ' '
+#uninstall:
+# @echo 'Uninstalling programs from $(INSTALL_DIR)'
+# -cd $(INSTALL_DIR);rm -f $(PGMS) $(TEST_PGMS)
+# @echo 'Finished uninstalling programs'
+# @echo ' '
rebuild: clean all
-@echo ' '
-$(RTSIGBLOCK_OBJS):$(RTSIGBLOCK_SRC)
- @echo 'Building target: $@'
- @echo 'Invoking: C++ Compiler'
- @echo $(CXX) $(CDEPFLAGS) $(FLAGS) -fPIC $(OPTIONS) $(INCLUDES) -c -o $@ $<
- @$(CXX) $(CDEPFLAGS) $(FLAGS) -fPIC $(OPTIONS) $(INCLUDES) -c -o $@ $<
- @echo 'Finished building target: $@'
- @echo ' '
-
-
-include $(CDEP_DIR)/*.dep
_dummy := $(shell if [ ! -d $(CDEP_DIR) ]; then mkdir -p $(CDEP_DIR); fi)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/monitor.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/monitor.cxx b/core/sqf/monitor/linux/monitor.cxx
index 0652cce..f73b972 100755
--- a/core/sqf/monitor/linux/monitor.cxx
+++ b/core/sqf/monitor/linux/monitor.cxx
@@ -121,7 +121,6 @@ CDeviceContainer *Devices = NULL;
int MyPNID = -1;
CNode *MyNode;
CMonLog *MonLog = NULL;
-CMonLog *SnmpLog = NULL;
CMonStats * MonStats = NULL;
extern CMonTrace *MonTrace;
CRedirector Redirector;
@@ -962,7 +961,6 @@ int main (int argc, char *argv[])
const char method_name[] = "main";
- SnmpLog = new CMonLog( "log4cxx.monitor.mon.snmp.config", "MON-SNMP", "alt.mon.snmp", -1, -1, getpid(), "$MONITOR" );
MonLog = new CMonLog( "log4cxx.monitor.mon.config", "MON", "alt.mon", -1, -1, getpid(), "$MONITOR" );
MonLog->setupInMemoryLog();
@@ -1082,7 +1080,6 @@ int main (int argc, char *argv[])
MPI_Comm_set_errhandler(MPI_COMM_SELF, MPI_ERRORS_RETURN);
MPI_Comm_rank (MPI_COMM_WORLD, &MyPNID);
MonLog->setPNid( MyPNID );
- SnmpLog->setPNid( MyPNID );
gethostname(Node_name, MPI_MAX_PROCESSOR_NAME);
char *tmpptr = Node_name;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/monlogging.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/monlogging.cxx b/core/sqf/monitor/linux/monlogging.cxx
index b8c7146..c441254 100755
--- a/core/sqf/monitor/linux/monlogging.cxx
+++ b/core/sqf/monitor/linux/monlogging.cxx
@@ -47,7 +47,8 @@ using namespace std;
extern int MyPNID;
extern CMonLog *MonLog;
-extern CMonLog *SnmpLog;
+
+pthread_mutex_t MonLogMutex = PTHREAD_MUTEX_INITIALIZER;
int mon_log_write(int eventType, posix_sqlog_severity_t severity, char *msg)
{
@@ -82,19 +83,6 @@ int monproc_log_write(int eventType, posix_sqlog_severity_t severity, char *msg)
return(0);
}
-int snmp_log_write(int eventType, char *msg)
-{
- if (SnmpLog->isUseAltLog())
- {
- SnmpLog->writeSnmpAltLog(eventType, msg);
- }
- else
- {
- SnmpLog->writeMonLog(eventType, SQ_LOG_CRIT, msg);
- }
- return(0);
-}
-
void mem_log_write(int eventType, int value1, int value2)
{
MonLog->memLogWrite(eventType, value1, value2);
@@ -268,60 +256,21 @@ void CMonLog::writeAltLog(int eventType, posix_sqlog_severity_t severity, char *
return;
}
-void CMonLog::writeSnmpAltLog(int eventType, const char *msg)
-{
- char logFileDir[PATH_MAX];
- char *logFileDirPtr;
- char logFilePrefix[MAX_FILE_NAME];
- char *rootDir;
-
- if ( useAltLog_ )
- {
- rootDir = getenv("MY_SQROOT");
- if (rootDir == NULL)
- {
- logFileDirPtr = NULL;
- }
- else
- {
- sprintf(logFileDir, "%s/logs", rootDir);
- logFileDirPtr = logFileDir;
- }
-
- // log file prefix will be snmp.mon.nn
- // nn is the file number. If the log file becomes too big,
- // LogFileNum can be incremented.
- sprintf( logFilePrefix, "%s.%s.%02d"
- , logFileNamePrefix_.c_str(), (char *)&startTimeFmt_, logFileNum_);
-
- SBX_log_write(logFileType_, // log_type
- logFileDirPtr, // log_file_dir
- logFilePrefix, // log_file_prefix
- SQEVL_MONITOR, // component id
- eventType, // event id
- SQ_LOG_SEAQUEST, // facility
- SQ_LOG_CRIT, // severity
- myProcessName_.c_str(), // name
- NULL, // msg_prefix
- msg, // msg
- NULL, // snmptrap_cmd
- NULL, // msg_snmptrap
- NULL, // msg_ret
- 0); // msg_ret size
- }
-
- return;
-}
-
void CMonLog::writeMonLog(int eventType, posix_sqlog_severity_t severity, char *msg)
{
logLevel llevel = getLogLevel( severity );
+ int status = pthread_mutex_lock(&MonLogMutex);
+ assert(status == 0);
+
// Log4cxx logging
CommonLogger::log( log4cxxComponent_
, llevel
, "Node Number: %u,, PIN: %u , Process Name: %s,,, TID: %d, Message ID: %u, %s"
, myPNid_, myPid_, myProcessName_.c_str(), gettid(), eventType, msg);
+ status = pthread_mutex_unlock(&MonLogMutex);
+ assert(status == 0);
+
return;
}
@@ -329,11 +278,18 @@ void CMonLog::writeMonProcLog(int eventType, posix_sqlog_severity_t severity, ch
{
logLevel llevel = getLogLevel( severity );
+ int status = pthread_mutex_lock(&MonLogMutex);
+ assert(status == 0);
+
// Log4cxx logging
CommonLogger::log( log4cxxComponent_
, llevel
, "Node Number: %u, CPU: %u, PIN: %u , Process Name: %s,,, TID: %u, Message ID: %u, %s"
, myPNid_, myNid_, myPid_, myProcessName_.c_str(), gettid(), eventType, msg);
+
+ status = pthread_mutex_unlock(&MonLogMutex);
+ assert(status == 0);
+
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/monlogging.h
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/monlogging.h b/core/sqf/monitor/linux/monlogging.h
index 356f8f0..f3b1840 100755
--- a/core/sqf/monitor/linux/monlogging.h
+++ b/core/sqf/monitor/linux/monlogging.h
@@ -50,9 +50,6 @@ void mem_log_write(int eventType, int value1 = 0, int value2 = 0);
// Used by monitor primitive processes
int monproc_log_write(int event_type, posix_sqlog_severity_t severity, char *evl_buf);
-// Used by monitor and SQWatchdog process
-int snmp_log_write(int event_type, char *evl_buf);
-
// header of the memory log buffer
typedef struct memLogHeader
{
@@ -92,8 +89,6 @@ public:
void writeMonProcLog(int eventType, posix_sqlog_severity_t severity, char *msg);
- void writeSnmpAltLog(int event_type, const char *msg);
-
inline int getLogFileNum() { return logFileNum_; }
void setLogFileNum(int value);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/montrace.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/montrace.cxx b/core/sqf/monitor/linux/montrace.cxx
index 9b0e098..9f2a391 100644
--- a/core/sqf/monitor/linux/montrace.cxx
+++ b/core/sqf/monitor/linux/montrace.cxx
@@ -59,6 +59,7 @@ const CMonTrace::traceArea CMonTrace::traceAreaList[] =
{"MON_TRACE_EVLOG_MSG", TRACE_EVLOG_MSG},
{"MON_TRACE_ENTRY_EXIT", TRACE_ENTRY_EXIT},
{"MON_TRACE_REDIRECTION", TRACE_REDIRECTION},
+ {"MON_TRACE_TRAFCONFIG", TRACE_TRAFCONFIG},
{"MON_TRACE_HEALTH", TRACE_HEALTH},
{"MON_TRACE_SIG_HANDLER", TRACE_SIG_HANDLER}
};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/montrace.h
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/montrace.h b/core/sqf/monitor/linux/montrace.h
index 6dcfbcc..dce911a 100644
--- a/core/sqf/monitor/linux/montrace.h
+++ b/core/sqf/monitor/linux/montrace.h
@@ -57,8 +57,7 @@
// Input/output redirection from child processes
#define TRACE_REDIRECTION 0x10000
// Cluster Configration
-#define TRACE_CLUST_CONF 0x20000
-#define TRACE_CLUST_CONF_DETAIL 0x20000
+#define TRACE_TRAFCONFIG 0x20000
// Health check
#define TRACE_HEALTH 0x40000
// Signal handler
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/persistconfig.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/persistconfig.cxx b/core/sqf/monitor/linux/persistconfig.cxx
index e69d151..485c6a4 100644
--- a/core/sqf/monitor/linux/persistconfig.cxx
+++ b/core/sqf/monitor/linux/persistconfig.cxx
@@ -189,32 +189,21 @@ const char *FormatZidString( FormatZid_t type )
// Persistent Process Configuration
///////////////////////////////////////////////////////////////////////////////
-CPersistConfig::CPersistConfig( const char *persistPrefix
- , const char *processNamePrefix
- , const char *processNameFormat
- , const char *stdoutPrefix
- , const char *stdoutFormat
- , const char *programName
- , const char *zidFormat
- , PROCESSTYPE processType
- , bool requiresDTM
- , int persistRetries
- , int persistWindow
- )
- : persistPrefix_(persistPrefix)
- , processNamePrefix_(processNamePrefix)
- , processNameFormat_(processNameFormat)
- , stdoutPrefix_(stdoutPrefix)
- , stdoutFormat_(stdoutFormat)
- , programName_(programName)
- , zoneFormat_(zidFormat)
- , processType_(processType)
+CPersistConfig::CPersistConfig( persistConfigInfo_t &persistConfigInfo )
+ : persistPrefix_(persistConfigInfo.persistPrefix)
+ , processNamePrefix_(persistConfigInfo.processNamePrefix)
+ , processNameFormat_(persistConfigInfo.processNameFormat)
+ , stdoutPrefix_(persistConfigInfo.stdoutPrefix)
+ , stdoutFormat_(persistConfigInfo.stdoutFormat)
+ , programName_(persistConfigInfo.programName)
+ , zoneFormat_(persistConfigInfo.zoneFormat)
+ , processType_(persistConfigInfo.processType)
, processNameNidFormat_(Nid_Undefined)
, stdoutNidFormat_(Nid_Undefined)
, zoneZidFormat_(Zid_Undefined)
- , requiresDTM_(requiresDTM)
- , persistRetries_(persistRetries)
- , persistWindow_(persistWindow)
+ , requiresDTM_(persistConfigInfo.requiresDTM)
+ , persistRetries_(persistConfigInfo.persistRetries)
+ , persistWindow_(persistConfigInfo.persistWindow)
, next_(NULL)
, prev_(NULL)
{
@@ -373,34 +362,12 @@ void CPersistConfigContainer::Clear( void )
TRACE_EXIT;
}
-CPersistConfig *CPersistConfigContainer::AddPersistConfig( const char *persistPrefix
- , const char *processNamePrefix
- , const char *processNameFormat
- , const char *stdoutPrefix
- , const char *stdoutFormat
- , const char *programName
- , const char *zidFormat
- , PROCESSTYPE processType
- , bool requiresDTM
- , int persistRetries
- , int persistWindow
- )
+CPersistConfig *CPersistConfigContainer::AddPersistConfig( persistConfigInfo_t &persistConfigInfo )
{
const char method_name[] = "CPersistConfigContainer::AddPersistConfig";
TRACE_ENTRY;
- CPersistConfig *persistConfig = new CPersistConfig( persistPrefix
- , processNamePrefix
- , processNameFormat
- , stdoutPrefix
- , stdoutFormat
- , programName
- , zidFormat
- , processType
- , requiresDTM
- , persistRetries
- , persistWindow
- );
+ CPersistConfig *persistConfig = new CPersistConfig( persistConfigInfo );
if (persistConfig)
{
persistsCount_++;
@@ -496,7 +463,8 @@ CPersistConfig *CPersistConfigContainer::GetPersistConfig( PROCESSTYPE processTy
return config;
}
-void CPersistConfigContainer::InitializePersistKeys( char *persistkeys )
+void CPersistConfigContainer::InitializePersistKeys( char *persistkeys
+ , pkeysVector_t &pkeysVector )
{
const char method_name[] = "CPersistConfigContainer::InitializePersistKeys";
TRACE_ENTRY;
@@ -512,6 +480,7 @@ void CPersistConfigContainer::InitializePersistKeys( char *persistkeys )
trace_printf("%s@%d Setting pkeysVector=%s\n",
method_name, __LINE__, token);
}
+ pkeysVector.push_back( token );
pkeysVector_.push_back( token );
token = strtok( NULL, " ," );
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/persistconfig.h
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/persistconfig.h b/core/sqf/monitor/linux/persistconfig.h
index cd1386b..0614b7e 100644
--- a/core/sqf/monitor/linux/persistconfig.h
+++ b/core/sqf/monitor/linux/persistconfig.h
@@ -26,6 +26,8 @@
#include <string>
#include <vector>
#include "msgdef.h"
+#include "trafconfig.h"
+
using namespace std;
#define TOKEN_NID "%nid"
@@ -49,6 +51,23 @@ typedef enum
//, Zid_SET // %zid[n,...] future?
} FormatZid_t;
+typedef vector<string> pkeysVector_t;
+
+typedef struct persistConfigInfo_s
+{
+ char persistPrefix[TC_PERSIST_KEY_MAX];
+ char processNamePrefix[TC_PERSIST_VALUE_MAX];
+ char processNameFormat[TC_PERSIST_VALUE_MAX];
+ char stdoutPrefix[TC_PERSIST_VALUE_MAX];
+ char stdoutFormat[TC_PERSIST_VALUE_MAX];
+ char programName[TC_PERSIST_VALUE_MAX];
+ char zoneFormat[TC_PERSIST_VALUE_MAX];
+ PROCESSTYPE processType;
+ bool requiresDTM;
+ int persistRetries;
+ int persistWindow;
+} persistConfigInfo_t;
+
class CPersistConfig;
class CPersistConfigContainer
@@ -57,18 +76,7 @@ public:
CPersistConfigContainer( void );
~CPersistConfigContainer( void );
- CPersistConfig *AddPersistConfig( const char *persistPrefix
- , const char *processNamePrefix
- , const char *processNameFormat
- , const char *stdoutPrefix
- , const char *stdoutFormat
- , const char *programName
- , const char *zidFormat
- , PROCESSTYPE processType
- , bool requiresDTM
- , int persistRetries
- , int persistWindow
- );
+ CPersistConfig *AddPersistConfig( persistConfigInfo_t &persistConfigInfo );
void Clear( void );
void DeletePersistConfig( CPersistConfig *persistConfig );
inline CPersistConfig *GetFirstPersistConfig( void ) { return ( head_ ); }
@@ -79,11 +87,12 @@ public:
inline int GetPersistConfigCount( void ) { return ( persistsCount_ ); }
protected:
- void InitializePersistKeys( char *persistkeys );
+ void InitializePersistKeys( char *persistkeys
+ , pkeysVector_t &pkeysVector );
int GetPersistKeysCount( void ) { return ( pkeysVector_.size() ); }
int persistsCount_; // # of persistent configuration object
- vector<string> pkeysVector_; // vector of persist keys
+ pkeysVector_t pkeysVector_; // vector of persist keys
private:
CPersistConfig *head_; // head of persist configuration linked list
@@ -92,32 +101,10 @@ private:
class CPersistConfig
{
- friend CPersistConfig *CPersistConfigContainer::AddPersistConfig( const char *persistPrefix
- , const char *processNamePrefix
- , const char *processNameFormat
- , const char *stdoutPrefix
- , const char *stdoutFormat
- , const char *programName
- , const char *zidFormat
- , PROCESSTYPE processType
- , bool requiresDTM
- , int persistRetries
- , int persistWindow
- );
+ friend CPersistConfig *CPersistConfigContainer::AddPersistConfig( persistConfigInfo_t &persistConfigInfo );
friend void CPersistConfigContainer::DeletePersistConfig( CPersistConfig *persistConfig );
public:
- CPersistConfig( const char *persistPrefix
- , const char *processNamePrefix
- , const char *processNameFormat
- , const char *stdoutPrefix
- , const char *stdoutFormat
- , const char *programName
- , const char *zidFormat
- , PROCESSTYPE processType
- , bool requiresDTM
- , int persistRetries
- , int persistWindow
- );
+ CPersistConfig( persistConfigInfo_t &persistConfigInfo );
~CPersistConfig( void );
inline CPersistConfig *GetNext( void ){ return( next_); }
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/pnodeconfig.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/pnodeconfig.cxx b/core/sqf/monitor/linux/pnodeconfig.cxx
index dcd67aa..82b42d6 100644
--- a/core/sqf/monitor/linux/pnodeconfig.cxx
+++ b/core/sqf/monitor/linux/pnodeconfig.cxx
@@ -46,15 +46,12 @@ using namespace std;
///////////////////////////////////////////////////////////////////////////////
CPNodeConfig::CPNodeConfig( CPNodeConfigContainer *pnodesConfig
- , int pnid
- , int excludedLastCore
- , int excludedFirstCore
- , const char *hostname
+ , pnodeConfigInfo_t &pnodeConfigInfo
)
: pnodesConfig_(pnodesConfig)
- , pnid_(pnid)
- , excludedFirstCore_(excludedFirstCore)
- , excludedLastCore_(excludedLastCore)
+ , pnid_(pnodeConfigInfo.pnid)
+ , excludedFirstCore_(pnodeConfigInfo.excludedFirstCore)
+ , excludedLastCore_(pnodeConfigInfo.excludedLastCore)
, spareNode_(false)
, sparePNids_(NULL)
, sparePNidsCount_(0)
@@ -64,11 +61,7 @@ CPNodeConfig::CPNodeConfig( CPNodeConfigContainer *pnodesConfig
const char method_name[] = "CPNodeConfig::CPNodeConfig";
TRACE_ENTRY;
- int len = strlen( hostname );
- assert( len <= MPI_MAX_PROCESSOR_NAME );
-
- strcpy( name_, hostname );
-
+ strcpy( name_, pnodeConfigInfo.nodename );
CPU_ZERO( &excludedCoreMask_ );
TRACE_EXIT;
@@ -263,35 +256,27 @@ void CPNodeConfigContainer::Clear( void )
TRACE_EXIT;
}
-CPNodeConfig *CPNodeConfigContainer::AddPNodeConfig( int pnid
- , char *name
- , int excludedFirstCore
- , int excludedLastCore
- , bool spare
- )
+CPNodeConfig *CPNodeConfigContainer::AddPNodeConfig( pnodeConfigInfo_t &pnodeConfigInfo )
{
const char method_name[] = "CPNodeConfigContainer::AddPNodeConfig";
TRACE_ENTRY;
// pnid list is NOT sequential from zero
- if ( ! (pnid >= 0 && pnid < pnodesConfigMax_) )
+ if ( ! (pnodeConfigInfo.pnid >= 0 && pnodeConfigInfo.pnid < pnodesConfigMax_) )
{
char la_buf[MON_STRING_BUF_SIZE];
- sprintf(la_buf, "[%s], Error: Invalid pnid=%d - should be >= 0 and < %d)\n", method_name, pnid, pnodesConfigMax_);
+ sprintf( la_buf, "[%s], Error: Invalid pnid=%d - should be >= 0 and < %d)\n"
+ , method_name, pnodeConfigInfo.pnid, pnodesConfigMax_);
mon_log_write(MON_PNODECONF_ADD_PNODE_1, SQ_LOG_CRIT, la_buf);
return( NULL );
}
- assert( pnodesConfig_[pnid] == NULL );
+ assert( pnodesConfig_[pnodeConfigInfo.pnid] == NULL );
- CPNodeConfig *pnodeConfig = new CPNodeConfig( this
- , pnid
- , excludedFirstCore
- , excludedLastCore
- , name );
+ CPNodeConfig *pnodeConfig = new CPNodeConfig( this, pnodeConfigInfo );
if (pnodeConfig)
{
- if ( spare )
+ if ( pnodeConfigInfo.spareCount )
{
snodesCount_++;
spareNodesConfigList_.push_back( pnodeConfig );
@@ -300,7 +285,7 @@ CPNodeConfig *CPNodeConfigContainer::AddPNodeConfig( int pnid
// Bump the physical node count
pnodesCount_++;
// Add it to the array
- pnodesConfig_[pnid] = pnodeConfig;
+ pnodesConfig_[pnodeConfigInfo.pnid] = pnodeConfig;
// Add it to the container list
if ( head_ == NULL )
{
@@ -314,7 +299,7 @@ CPNodeConfig *CPNodeConfigContainer::AddPNodeConfig( int pnid
}
// Set the next available pnid
- nextPNid_ = (pnid == nextPNid_) ? (pnid+1) : nextPNid_ ;
+ nextPNid_ = (pnodeConfigInfo.pnid == nextPNid_) ? (pnodeConfigInfo.pnid+1) : nextPNid_ ;
if ( nextPNid_ == pnodesConfigMax_ )
{ // We are at the limit, search for unused pnid from begining
nextPNid_ = -1;
@@ -347,7 +332,7 @@ CPNodeConfig *CPNodeConfigContainer::AddPNodeConfig( int pnid
" (pnid=%d, nextPNid_=%d)\n"
" (pnodesCount_=%d,pnodesConfigMax=%d)\n"
, method_name, __LINE__
- , pnid, nextPNid_
+ , pnodeConfigInfo.pnid, nextPNid_
, pnodesCount_, pnodesConfigMax_);
}
}
@@ -355,7 +340,8 @@ CPNodeConfig *CPNodeConfigContainer::AddPNodeConfig( int pnid
{
int err = errno;
char la_buf[MON_STRING_BUF_SIZE];
- sprintf(la_buf, "[%s], Error: Can't allocate physical node configuration object - errno=%d (%s)\n", method_name, err, strerror(errno));
+ sprintf( la_buf, "[%s], Error: Can't allocate physical node configuration object - errno=%d (%s)\n"
+ , method_name, err, strerror(errno));
mon_log_write(MON_PNODECONF_ADD_PNODE_2, SQ_LOG_ERR, la_buf);
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/04040d30/core/sqf/monitor/linux/pnodeconfig.h
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/pnodeconfig.h b/core/sqf/monitor/linux/pnodeconfig.h
index f0992cd..2bf7cc2 100644
--- a/core/sqf/monitor/linux/pnodeconfig.h
+++ b/core/sqf/monitor/linux/pnodeconfig.h
@@ -30,19 +30,29 @@
#include "lnodeconfig.h"
+class CLNodeConfig;
+class CPNodeConfig;
+
typedef list<CPNodeConfig *> PNodesConfigList_t;
+typedef struct pnodeConfigInfo_s
+{
+ int pnid;
+ char nodename[MPI_MAX_PROCESSOR_NAME];
+ int excludedFirstCore;
+ int excludedLastCore;
+ cpu_set_t excludedCoreMask;
+ int spareCount;
+ int sparePNid[MAX_NODES];
+} pnodeConfigInfo_t;
+
class CPNodeConfigContainer
{
public:
CPNodeConfigContainer( int pnodesConfigMax );
~CPNodeConfigContainer( void );
- CPNodeConfig *AddPNodeConfig( int pnid
- , char *name
- , int excludedFirstCore
- , int excludedLastCore
- , bool spare );
+ CPNodeConfig *AddPNodeConfig( pnodeConfigInfo_t &pnodeConfigInfo );
void Clear( void );
void DeletePNodeConfig( CPNodeConfig *pnodeConfig );
inline CPNodeConfig *GetFirstPNodeConfig( void ) { return ( head_ ); }
@@ -72,19 +82,12 @@ private:
class CPNodeConfig : public CLNodeConfigContainer
{
- friend CPNodeConfig *CPNodeConfigContainer::AddPNodeConfig( int pnid
- , char *name
- , int excludedFirstCore
- , int excludedLastCore
- , bool spare );
- friend void CPNodeConfigContainer::DeletePNodeConfig( CPNodeConfig *entry );
+ friend CPNodeConfig *CPNodeConfigContainer::AddPNodeConfig( pnodeConfigInfo_t &pnodeConfigInfo );
+ friend void CPNodeConfigContainer::DeletePNodeConfig( CPNodeConfig *pnodeConfig );
public:
CPNodeConfig( CPNodeConfigContainer *pnodesConfig
- , int pnid
- , int excludedFirstCore
- , int excludedLastCore
- , const char *hostname
+ , pnodeConfigInfo_t &pnodeConfigInfo
);
~CPNodeConfig( void );
@@ -102,8 +105,8 @@ public:
inline bool IsSpareNode( void ) { return ( spareNode_ ); }
inline void SetExcludedCoreMask( cpu_set_t &coreMask ) { excludedCoreMask_ = coreMask; }
- void SetSpareList( int sparePNid[], int spareCount );
- void ResetSpare( void );
+ void SetSpareList( int sparePNid[], int spareCount );
+ void ResetSpare( void );
protected:
private: