http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/persistconfig.cxx ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/persistconfig.cxx b/core/sqf/monitor/linux/persistconfig.cxx deleted file mode 100644 index b2e4526..0000000 --- a/core/sqf/monitor/linux/persistconfig.cxx +++ /dev/null @@ -1,636 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// @@@ START COPYRIGHT @@@ -// -// (C) Copyright 2015 Hewlett Packard Enterprise Development LP -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// @@@ END COPYRIGHT @@@ -// -/////////////////////////////////////////////////////////////////////////////// - -using namespace std; - -#include <string.h> -#include "montrace.h" -#include "monlogging.h" -#include "persistconfig.h" - -const char *PersistProcessTypeString( PROCESSTYPE type ) -{ - const char *str; - - switch( type ) - { - case ProcessType_TSE: - str = "TSE"; - break; - case ProcessType_DTM: - str = "DTM"; - break; - case ProcessType_ASE: - str = "ASE"; - break; - case ProcessType_Generic: - str = "GENERIC"; - break; - case ProcessType_Watchdog: - str = "WDG"; - break; - case ProcessType_AMP: - str = "AMP"; - break; - case ProcessType_Backout: - str = "BO"; - break; - case ProcessType_VolumeRecovery: - str = "VR"; - break; - case ProcessType_MXOSRVR: - str = "MXOSRVR"; - break; - case ProcessType_SPX: - str = "SPX"; - break; - case ProcessType_SSMP: - str = "SSMP"; - break; - case ProcessType_PSD: - str = "PSD"; - break; - case ProcessType_SMS: - str = "SMS"; - break; - case ProcessType_TMID: - str = "TMID"; - break; - case ProcessType_PERSIST: - str = "PERSIST"; - break; - default: - str = "Undefined"; - break; - } - - return( str ); -} - -const char *ProcessTypeString( PROCESSTYPE type ) -{ - const char *str; - - switch( type ) - { - case ProcessType_Undefined: - str = "ProcessType_Undefined"; - break; - case ProcessType_TSE: - str = "ProcessType_TSE"; - break; - case ProcessType_DTM: - str = "ProcessType_DTM"; - break; - case ProcessType_ASE: - str = "ProcessType_ASE"; - break; - case ProcessType_Generic: - str = "ProcessType_Generic"; - break; - case ProcessType_Watchdog: - str = "ProcessType_Watchdog"; - break; - case ProcessType_AMP: - str = "ProcessType_AMP"; - break; - case ProcessType_Backout: - str = "ProcessType_Backout"; - break; - case ProcessType_VolumeRecovery: - str = "ProcessType_VolumeRecovery"; - break; - case ProcessType_MXOSRVR: - str = "ProcessType_MXOSRVR"; - break; - case ProcessType_SPX: - str = "ProcessType_SPX"; - break; - case ProcessType_SSMP: - str = "ProcessType_SSMP"; - break; - case ProcessType_PSD: - str = "ProcessType_PSD"; - break; - case ProcessType_SMS: - str = "ProcessType_SMS"; - break; - case ProcessType_TMID: - str = "ProcessType_TMID"; - break; - case ProcessType_PERSIST: - str = "ProcessType_PERSIST"; - break; - default: - str = "ProcessType_Invalid"; - } - - return( str ); -} - -const char *FormatNidString( FormatNid_t type ) -{ - const char *str; - - switch( type ) - { - case Nid_ALL: - str = "Nid_ALL"; - break; - case Nid_RELATIVE: - str = "Nid_RELATIVE"; - break; - default: - str = "Nid_Undefined"; - } - - return( str ); -} - -const char *FormatZidString( FormatZid_t type ) -{ - const char *str; - - switch( type ) - { - case Zid_ALL: - str = "Zid_ALL"; - break; - case Zid_RELATIVE: - str = "Zid_RELATIVE"; - break; - default: - str = "Zid_Undefined"; - } - - return( str ); -} - -/////////////////////////////////////////////////////////////////////////////// -// Persistent Process Configuration -/////////////////////////////////////////////////////////////////////////////// - -CPersistConfig::CPersistConfig( persistConfigInfo_t &persistConfigInfo ) - : persistPrefix_(persistConfigInfo.persistPrefix) - , processName_("") - , processNamePrefix_(persistConfigInfo.processNamePrefix) - , processNameFormat_(persistConfigInfo.processNameFormat) - , stdoutFile_("") - , stdoutPrefix_(persistConfigInfo.stdoutPrefix) - , stdoutFormat_(persistConfigInfo.stdoutFormat) - , programName_(persistConfigInfo.programName) - , programArgs_(persistConfigInfo.programArgs) - , zoneFormat_(persistConfigInfo.zoneFormat) - , processType_(persistConfigInfo.processType) - , processNameNidFormat_(Nid_Undefined) - , stdoutNidFormat_(Nid_Undefined) - , zoneZidFormat_(Zid_Undefined) - , requiresDTM_(persistConfigInfo.requiresDTM) - , persistRetries_(persistConfigInfo.persistRetries) - , persistWindow_(persistConfigInfo.persistWindow) - , programArgc_(0) - , programArgv_(NULL) - , programArgvLen_(0) - , next_(NULL) - , prev_(NULL) -{ - const char method_name[] = "CPersistConfig::CPersistConfig"; - TRACE_ENTRY; - - if (processNameFormat_.compare(TOKEN_NID_PLUS) == 0) - { - processNameNidFormat_ = Nid_ALL; - } - else - { - if (processNameFormat_.compare(TOKEN_NID) == 0) - { - processNameNidFormat_ = Nid_RELATIVE; - } - } - if (stdoutFormat_.compare(TOKEN_NID_PLUS) == 0) - { - stdoutNidFormat_ = Nid_ALL; - } - else - { - if (stdoutFormat_.compare(TOKEN_NID) == 0) - { - stdoutNidFormat_ = Nid_RELATIVE; - } - } - if (zoneFormat_.compare(TOKEN_ZID_PLUS) == 0) - { - zoneZidFormat_ = Zid_ALL; - } - else - { - if (zoneFormat_.compare(TOKEN_ZID) == 0) - { - zoneZidFormat_ = Zid_RELATIVE; - } - } - - char *token, *programArgs = NULL; - static const char *delim = " "; - stringVector_t argvVector; - - if (programArgs_.size()) - { - programArgs = new char [programArgs_.size()+100]; - memset(programArgs, 0, programArgs_.size()+100); - memcpy(programArgs, programArgs_.c_str(), programArgs_.size()); - - token = strtok( programArgs, delim ); - while (token != NULL) - { - if ( trace_settings & TRACE_INIT ) - { - trace_printf("%s@%d Setting argvVector=%s\n", - method_name, __LINE__, token); - } - argvVector.push_back( token ); - token = strtok( NULL, delim ); - } - - programArgc_ = argvVector.size(); - - // Compute amount of space need to store argument strings - stringVector_t::iterator avit; - for (avit = argvVector.begin(); avit < argvVector.end(); avit++ ) - { - programArgvLen_ += strlen(avit->c_str()) + 1; - } - - if ( trace_settings & TRACE_INIT ) - { - trace_printf( "%s@%d - Copying arguments " - "programArgc_=%d, programArgvLen_=%d\n" - , method_name, __LINE__ - , programArgc_, programArgvLen_); - } - - if (programArgvLen_ != 0) - { - programArgv_ = new char[programArgvLen_]; - if (programArgv_) - { - memset(programArgv_, 0, programArgvLen_); - char *pProgramArgv = programArgv_; - for (avit = argvVector.begin(); avit < argvVector.end(); avit++ ) - { - if ( trace_settings & TRACE_INIT ) - { - trace_printf("%s@%d - prefix=%s, Copying argvVector='%s'\n" - , method_name, __LINE__ - , persistPrefix_.c_str(), avit->c_str()); - } - strcpy (pProgramArgv, avit->c_str()); - pProgramArgv += strlen(avit->c_str()) + 1; - } - } - } - } - - if (programArgs) delete [] programArgs; - - TRACE_EXIT; -} - -CPersistConfig::~CPersistConfig( void ) -{ - const char method_name[] = "CPersistConfig::~CPersistConfig"; - TRACE_ENTRY; - - if (programArgv_) delete [] programArgv_; - - TRACE_EXIT; -} - - -const char *CPersistConfig::GetProcessName( int nid ) -{ - const char method_name[] = "CPersistConfig::GetProcessName"; - TRACE_ENTRY; - - char nidStr[MAX_PROCESS_NAME]; - - switch (processNameNidFormat_) - { - case Nid_ALL: - case Nid_RELATIVE: - if (nid == -1) - { - processName_ = processNamePrefix_; - } - else - { - sprintf( nidStr, "%d", nid ); - processName_ = processNamePrefix_ + nidStr; - } - break; - case Nid_Undefined: - processName_ = processNamePrefix_; - } - - if ( trace_settings & (TRACE_REQUEST | TRACE_PROCESS)) - { - trace_printf( "%s@%d Process prefix=%s, name=%s, format=%s\n" - , method_name, __LINE__ - , processNamePrefix_.c_str() - , processName_.c_str() - , FormatNidString(processNameNidFormat_)); - } - - TRACE_EXIT; - return( processName_.c_str() ); -} - -const char *CPersistConfig::GetStdoutFile( int nid ) -{ - const char method_name[] = "CPersistConfig::GetStdoutFile"; - TRACE_ENTRY; - - char nidStr[MAX_PROCESS_NAME]; - - switch (stdoutNidFormat_) - { - case Nid_ALL: - case Nid_RELATIVE: - if (nid == -1) - { - stdoutFile_ = stdoutPrefix_; - } - else - { - sprintf( nidStr, "%d", nid ); - stdoutFile_ = stdoutPrefix_ + nidStr; - } - break; - case Nid_Undefined: - stdoutFile_ = stdoutPrefix_; - } - - if ( trace_settings & (TRACE_REQUEST | TRACE_PROCESS)) - { - trace_printf( "%s@%d stdout prefix=%s, file=%s, format=%s\n" - , method_name, __LINE__ - , stdoutPrefix_.c_str() - , stdoutFile_.c_str() - , FormatNidString(stdoutNidFormat_)); - } - - TRACE_EXIT; - return( stdoutFile_.c_str() ); -} - -bool CPersistConfig::IsPersistConfig( const char *processName, int nid ) -{ - const char method_name[] = "CPersistConfig:IsPersistConfig"; - TRACE_ENTRY; - - bool match = false; - - string name = GetProcessName( nid ); - if ( name.compare( processName ) == 0 ) - { - match = true; - } - - TRACE_EXIT; - return( match ); -} - -bool CPersistConfig::IsZoneMatch( int zid ) -{ - const char method_name[] = "CPersistConfig:IsZoneMatch"; - TRACE_ENTRY; - - bool match = false; - - switch (stdoutNidFormat_) - { - case Zid_ALL: - if (zid == -1) - { - match = false; - } - else - { - match = true; - } - break; - case Zid_RELATIVE: - if (zid == -1) - { - match = false; - } - else - { - match = true; - } - break; - case Zid_Undefined: - match = true; - break; - } - - TRACE_EXIT; - return( match ); -} - -CPersistConfigContainer::CPersistConfigContainer( void ) - : persistsCount_(0) - , head_(NULL) - , tail_(NULL) -{ - const char method_name[] = "CPersistConfigContainer::CPersistConfigContainer"; - TRACE_ENTRY; - - TRACE_EXIT; -} - -CPersistConfigContainer::~CPersistConfigContainer(void) -{ - CPersistConfig *persistConfig = head_; - - const char method_name[] = "CPersistConfigContainer::~CPersistConfigContainer"; - TRACE_ENTRY; - - while ( head_ ) - { - DeletePersistConfig( persistConfig ); - persistConfig = head_; - } - - pkeysVector_.clear(); - - TRACE_EXIT; -} - -void CPersistConfigContainer::Clear( void ) -{ - CPersistConfig *persistConfig = head_; - - const char method_name[] = "CPersistConfigContainer::Clear"; - TRACE_ENTRY; - - while ( head_ ) - { - DeletePersistConfig( persistConfig ); - persistConfig = head_; - } - - pkeysVector_.clear(); - - persistsCount_ = 0; - head_ = NULL; - tail_ = NULL; - - TRACE_EXIT; -} - -CPersistConfig *CPersistConfigContainer::AddPersistConfig( persistConfigInfo_t &persistConfigInfo ) -{ - const char method_name[] = "CPersistConfigContainer::AddPersistConfig"; - TRACE_ENTRY; - - CPersistConfig *persistConfig = new CPersistConfig( persistConfigInfo ); - if (persistConfig) - { - persistsCount_++; - // Add it to the container list - if ( head_ == NULL ) - { - head_ = tail_ = persistConfig; - } - else - { - tail_->next_ = persistConfig; - persistConfig->prev_ = tail_; - tail_ = persistConfig; - } - } - else - { - int err = errno; - char la_buf[MON_STRING_BUF_SIZE]; - sprintf(la_buf, "[%s], Error: Can't allocate persistent configuration " - "object - errno=%d (%s)\n" - , method_name, err, strerror(errno)); - mon_log_write(MON_PERSISTCONFIG_ADDCONFIG_1, SQ_LOG_ERR, la_buf); - } - - TRACE_EXIT; - return persistConfig; -} - -void CPersistConfigContainer::DeletePersistConfig( CPersistConfig *persistConfig ) -{ - - if ( head_ == persistConfig ) - head_ = persistConfig->next_; - if ( tail_ == persistConfig ) - tail_ = persistConfig->prev_; - if ( persistConfig->prev_ ) - persistConfig->prev_->next_ = persistConfig->next_; - if ( persistConfig->next_ ) - persistConfig->next_->prev_ = persistConfig->prev_; - delete persistConfig; -} - -CPersistConfig *CPersistConfigContainer::GetPersistConfig( const char *persistPrefix ) -{ - CPersistConfig *config = head_; - - const char method_name[] = "CPersistConfigContainer::GetPersistConfig"; - TRACE_ENTRY; - - while ( config ) - { - if (strcasecmp( config->GetPersistPrefix(), persistPrefix) == 0) - { - break; - } - config = config->GetNext(); - } - - TRACE_EXIT; - return config; -} - -CPersistConfig *CPersistConfigContainer::GetPersistConfig( PROCESSTYPE processType - , const char *processName - , int nid ) -{ - CPersistConfig *config = head_; - - const char method_name[] = "CPersistConfigContainer::GetPersistConfig"; - TRACE_ENTRY; - - while ( config ) - { - if (config->GetProcessType() == processType) - { - if ( trace_settings & (TRACE_REQUEST | TRACE_PROCESS)) - { - trace_printf( "%s@%d Process type=%s, name=%s\n" - , method_name, __LINE__ - , PersistProcessTypeString(processType) - , processName); - } - if (config->IsPersistConfig( processName, nid )) - { - break; - } - } - config = config->GetNext(); - } - - TRACE_EXIT; - return config; -} - -void CPersistConfigContainer::InitializePersistKeys( char *persistkeys - , pkeysVector_t &pkeysVector ) -{ - const char method_name[] = "CPersistConfigContainer::InitializePersistKeys"; - TRACE_ENTRY; - - char *token; - static const char *delim = ", "; - - token = strtok( persistkeys, delim ); - while (token != NULL) - { - if ( trace_settings & TRACE_INIT ) - { - trace_printf("%s@%d Setting pkeysVector=%s\n", - method_name, __LINE__, token); - } - pkeysVector.push_back( token ); - pkeysVector_.push_back( token ); - token = strtok( NULL, " ," ); - } - - TRACE_EXIT; -}
http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/persistconfig.h ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/persistconfig.h b/core/sqf/monitor/linux/persistconfig.h deleted file mode 100644 index 12c3322..0000000 --- a/core/sqf/monitor/linux/persistconfig.h +++ /dev/null @@ -1,165 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// @@@ START COPYRIGHT @@@ -// -// (C) Copyright 2015 Hewlett Packard Enterprise Development LP -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// @@@ END COPYRIGHT @@@ -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef PERSISTCONFIG_H_ -#define PERSISTCONFIG_H_ - -#include <string> -#include <vector> -#include "msgdef.h" -#include "trafconfig.h" - -using namespace std; - -#define TOKEN_NID "%nid" -#define TOKEN_NID_PLUS "%nid+" -#define TOKEN_ZID "%zid" -#define TOKEN_ZID_PLUS "%zid+" - -typedef enum -{ - Nid_Undefined=0 - , Nid_ALL // %nid+ - , Nid_RELATIVE // %nid - //, Nid_SET // %nid[n,...] future? -} FormatNid_t; - -typedef enum -{ - Zid_Undefined=0 - , Zid_ALL // %zid+ - , Zid_RELATIVE // %zid - //, Zid_SET // %zid[n,...] future? -} FormatZid_t; - -typedef vector<string> pkeysVector_t; -typedef vector<string> stringVector_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 programArgs[TC_PERSIST_VALUE_MAX]; - char zoneFormat[TC_PERSIST_VALUE_MAX]; - PROCESSTYPE processType; - bool requiresDTM; - int persistRetries; - int persistWindow; -} persistConfigInfo_t; - -class CPersistConfig; - -class CPersistConfigContainer -{ -public: - CPersistConfigContainer( void ); - ~CPersistConfigContainer( void ); - - CPersistConfig *AddPersistConfig( persistConfigInfo_t &persistConfigInfo ); - void Clear( void ); - void DeletePersistConfig( CPersistConfig *persistConfig ); - inline CPersistConfig *GetFirstPersistConfig( void ) { return ( head_ ); } - CPersistConfig *GetPersistConfig( const char *persistPrefix ); - CPersistConfig *GetPersistConfig( PROCESSTYPE processType - , const char *processName - , int nid ); - inline int GetPersistConfigCount( void ) { return ( persistsCount_ ); } - -protected: - void InitializePersistKeys( char *persistkeys - , pkeysVector_t &pkeysVector ); - int GetPersistKeysCount( void ) { return ( pkeysVector_.size() ); } - - int persistsCount_; // # of persistent configuration object - pkeysVector_t pkeysVector_; // vector of persist keys - -private: - CPersistConfig *head_; // head of persist configuration linked list - CPersistConfig *tail_; // tail of persist configuration linked list -}; - -class CPersistConfig -{ - friend CPersistConfig *CPersistConfigContainer::AddPersistConfig( persistConfigInfo_t &persistConfigInfo ); - friend void CPersistConfigContainer::DeletePersistConfig( CPersistConfig *persistConfig ); -public: - CPersistConfig( persistConfigInfo_t &persistConfigInfo ); - ~CPersistConfig( void ); - - inline CPersistConfig *GetNext( void ){ return( next_); } - - inline const char *GetPersistPrefix( void ) { return( persistPrefix_.c_str() ); } - const char *GetProcessName( int nid ); - inline const char *GetProcessNamePrefix( void ) { return( processNamePrefix_.c_str() ); } - inline const char *GetProcessNameFormat( void ) { return( processNameFormat_.c_str() ); } - inline FormatNid_t GetProcessNameNidFormat( void ) { return( processNameNidFormat_ ); } - const char *GetStdoutFile( int nid ); - inline const char *GetStdoutPrefix( void ) { return( stdoutPrefix_.c_str() ); } - inline const char *GetStdoutFormat( void ) { return( stdoutFormat_.c_str() ); } - inline FormatNid_t GetStdoutNidFormat( void ) { return( stdoutNidFormat_ ); } - inline const char *GetProgramName( void ) { return( programName_.c_str() ); } - inline const char *GetProgramArgs( void ) { return( programArgs_.c_str() ); } - inline int GetProgramArgc( void ) { return( programArgc_ ); } - inline const char *GetProgramArgv( void ) { return( programArgv_ ); } - inline int GetProgramArgvLen( void ) { return( programArgvLen_ ); } - inline const char *GetZoneFormat( void ) { return( zoneFormat_.c_str() ); } - inline FormatZid_t GetZoneZidFormat( void ) { return( zoneZidFormat_ ); } - inline PROCESSTYPE GetProcessType( void ) { return ( processType_ ); } - inline bool GetRequiresDTM( void ) { return ( requiresDTM_ ); } - inline int GetPersistRetries( void ) { return ( persistRetries_ ); } - inline int GetPersistWindow( void ) { return ( persistWindow_ ); } - bool IsPersistConfig( const char *processName, int nid ); - bool IsZoneMatch( int zid ); - -protected: -private: - string persistPrefix_; - string processName_; - string processNamePrefix_; - string processNameFormat_; - string stdoutFile_; - string stdoutPrefix_; - string stdoutFormat_; - string programName_; - string programArgs_; - string zoneFormat_; - PROCESSTYPE processType_; - FormatNid_t processNameNidFormat_; - FormatNid_t stdoutNidFormat_; - FormatZid_t zoneZidFormat_; - bool requiresDTM_; - int persistRetries_; - int persistWindow_; - - int programArgc_; - char *programArgv_; - int programArgvLen_; - - CPersistConfig *next_; // next PersistConfig in CPersistConfigContainer list - CPersistConfig *prev_; // previous PersistConfig in CPersistConfigContainer list -}; - -#endif /* PERSISTCONFIG_H_ */ http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/pnode.cxx ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/pnode.cxx b/core/sqf/monitor/linux/pnode.cxx index 00f1271..8aa0671 100644 --- a/core/sqf/monitor/linux/pnode.cxx +++ b/core/sqf/monitor/linux/pnode.cxx @@ -3159,7 +3159,8 @@ void CNodeContainer::LoadConfig( void ) } if ( clusterConfig_ ) { - if ( clusterConfig_->Initialize( MonTrace->getTraceFileName() ) ) + bool traceEnabled = (trace_settings & TRACE_TRAFCONFIG) ? true : false; + if ( clusterConfig_->Initialize( traceEnabled, MonTrace->getTraceFileName() ) ) { if ( ! clusterConfig_->LoadConfig() ) { http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/pnode.h ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/pnode.h b/core/sqf/monitor/linux/pnode.h index 6d07f4b..56a1321 100644 --- a/core/sqf/monitor/linux/pnode.h +++ b/core/sqf/monitor/linux/pnode.h @@ -32,8 +32,6 @@ #include "internal.h" #include "clusterconf.h" -#include "pnodeconfig.h" -#include "lnodeconfig.h" #include "lnode.h" #include "monlogging.h" http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/pnodeconfig.cxx ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/pnodeconfig.cxx b/core/sqf/monitor/linux/pnodeconfig.cxx deleted file mode 100644 index 03f52c9..0000000 --- a/core/sqf/monitor/linux/pnodeconfig.cxx +++ /dev/null @@ -1,631 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// @@@ START COPYRIGHT @@@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// -// @@@ END COPYRIGHT @@@ -// -/////////////////////////////////////////////////////////////////////////////// - -using namespace std; - -#include <errno.h> -#include <assert.h> -#include <sched.h> -#include <stdlib.h> -#include <stdio.h> -#include <fcntl.h> -#include <sys/ioctl.h> -#include <iostream> -#include <mpi.h> -#include "msgdef.h" -#include "seabed/trace.h" -#include "montrace.h" -#include "monlogging.h" -#include "pnodeconfig.h" - - -/////////////////////////////////////////////////////////////////////////////// -// Physical Node Configuration -/////////////////////////////////////////////////////////////////////////////// - -CPNodeConfig::CPNodeConfig( CPNodeConfigContainer *pnodesConfig - , pnodeConfigInfo_t &pnodeConfigInfo - ) - : pnodesConfig_(pnodesConfig) - , pnid_(pnodeConfigInfo.pnid) - , excludedFirstCore_(pnodeConfigInfo.excludedFirstCore) - , excludedLastCore_(pnodeConfigInfo.excludedLastCore) - , spareNode_(false) - , sparePNids_(NULL) - , sparePNidsCount_(0) - , next_(NULL) - , prev_(NULL) -{ - const char method_name[] = "CPNodeConfig::CPNodeConfig"; - TRACE_ENTRY; - - strcpy( name_, pnodeConfigInfo.nodename ); - CPU_ZERO( &excludedCoreMask_ ); - - TRACE_EXIT; -} - -CPNodeConfig::~CPNodeConfig( void ) -{ - const char method_name[] = "CPNodeConfig::~CPNodeConfig"; - TRACE_ENTRY; - - if (sparePNids_) - { - delete [] sparePNids_; - } - - TRACE_EXIT; -} - -int CPNodeConfig::GetSpareList( int sparePNids[] ) -{ - const char method_name[] = "CPNodeConfig::GetSpareList"; - TRACE_ENTRY; - - if ( ! sparePNids_ || ! sparePNids ) - { - return(0); - } - - if ( sparePNidsCount_ > 0 ) - { - for ( int i = 0; i < sparePNidsCount_ ; i++ ) - { - sparePNids[i] = sparePNids_[i]; - } - } - - TRACE_EXIT; - return(sparePNidsCount_); -} - -void CPNodeConfig::ResetSpare( void ) -{ - const char method_name[] = "CPNodeConfig::ResetSpare"; - TRACE_ENTRY; - - spareNode_ = false; - sparePNidsCount_ = 0; - if (sparePNids_) - { - delete [] sparePNids_; - } - - TRACE_EXIT; -} - -void CPNodeConfig::SetSpareList( int sparePNids[], int spareCount ) -{ - const char method_name[] = "CPNodeConfig::SetSpareList"; - TRACE_ENTRY; - - assert( ! sparePNids_ || spareCount ); - - sparePNidsCount_ = spareCount; - sparePNids_ = new int [sparePNidsCount_]; - - if ( ! sparePNids_ ) - { - int err = errno; - char la_buf[MON_STRING_BUF_SIZE]; - sprintf(la_buf, "[%s], Error: Can't allocate spare pnids array - errno=%d (%s)\n", method_name, err, strerror(errno)); - mon_log_write(MON_PNODECONF_SET_SPARE_1, SQ_LOG_CRIT, la_buf); - } - else - { - for ( int i = 0; i < sparePNidsCount_ ; i++ ) - { - sparePNids_[i] = sparePNids[i]; - if (trace_settings & TRACE_INIT) - { - trace_printf("%s@%d - Added spare pnid=%d to spare node array in (pnid=%d, nodename=%s)\n", method_name, __LINE__, sparePNids_[i], pnid_, name_); - } - } - spareNode_ = true; - } - - TRACE_EXIT; -} - -void CPNodeConfig::SetName( const char *newName ) -{ - if (newName) - { - strcpy(name_, newName); - } -} - -void CPNodeConfig::SetExcludedFirstCore( int excludedFirstCore ) -{ - excludedFirstCore_ = excludedFirstCore; -} - -void CPNodeConfig::SetExcludedLastCore( int excludedLastCore ) -{ - excludedLastCore_ = excludedLastCore; -} - -CPNodeConfigContainer::CPNodeConfigContainer( int pnodesConfigMax ) - : pnodesConfig_(NULL) - , pnodesCount_(0) - , snodesCount_(0) - , nextPNid_(0) - , pnodesConfigMax_(pnodesConfigMax) - , head_(NULL) - , tail_(NULL) -{ - const char method_name[] = "CPNodeConfigContainer::CPNodeConfigContainer"; - TRACE_ENTRY; - - pnodesConfig_ = new CPNodeConfig *[pnodesConfigMax_]; - - if ( ! pnodesConfig_ ) - { - int err = errno; - char la_buf[MON_STRING_BUF_SIZE]; - sprintf(la_buf, "[%s], Error: Can't allocate physical node configuration array - errno=%d (%s)\n", method_name, err, strerror(errno)); - mon_log_write(MON_PNODECONF_CONSTR_1, SQ_LOG_CRIT, la_buf); - } - else - { - // Initialize array - for ( int i = 0; i < pnodesConfigMax_; i++ ) - { - pnodesConfig_[i] = NULL; - } - } - - TRACE_EXIT; -} - -CPNodeConfigContainer::~CPNodeConfigContainer( void ) -{ - CPNodeConfig *pnodeConfig = head_; - - const char method_name[] = "CPNodeConfigContainer::~CPNodeConfigContainer"; - TRACE_ENTRY; - - // Delete entries - while ( head_ ) - { - DeletePNodeConfig( pnodeConfig ); - pnodeConfig = head_; - } - - // Delete array - if ( pnodesConfig_ ) - { - delete [] pnodesConfig_; - } - - TRACE_EXIT; -} - -void CPNodeConfigContainer::Clear( void ) -{ - const char method_name[] = "CPNodeConfigContainer::Clear"; - TRACE_ENTRY; - - CPNodeConfig *pnodeConfig = head_; - - // Delete entries - while ( head_ ) - { - DeletePNodeConfig( pnodeConfig ); - pnodeConfig = head_; - } - - if ( pnodesConfig_ ) - { - // Initialize array - for ( int i = 0; i < pnodesConfigMax_ ;i++ ) - { - pnodesConfig_[i] = NULL; - } - } - - pnodesCount_ = 0; - snodesCount_ = 0; - nextPNid_ = 0; - head_ = NULL; - tail_ = NULL; - - TRACE_EXIT; -} - -CPNodeConfig *CPNodeConfigContainer::AddPNodeConfig( pnodeConfigInfo_t &pnodeConfigInfo ) -{ - const char method_name[] = "CPNodeConfigContainer::AddPNodeConfig"; - TRACE_ENTRY; - - // pnid list is NOT sequential from zero - 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, pnodeConfigInfo.pnid, pnodesConfigMax_); - mon_log_write(MON_PNODECONF_ADD_PNODE_1, SQ_LOG_CRIT, la_buf); - return( NULL ); - } - - assert( pnodesConfig_[pnodeConfigInfo.pnid] == NULL ); - - CPNodeConfig *pnodeConfig = new CPNodeConfig( this, pnodeConfigInfo ); - if (pnodeConfig) - { - if ( pnodeConfigInfo.spareCount ) - { - snodesCount_++; - spareNodesConfigList_.push_back( pnodeConfig ); - } - - // Bump the physical node count - pnodesCount_++; - // Add it to the array - pnodesConfig_[pnodeConfigInfo.pnid] = pnodeConfig; - // Add it to the container list - if ( head_ == NULL ) - { - head_ = tail_ = pnodeConfig; - } - else - { - tail_->next_ = pnodeConfig; - pnodeConfig->prev_ = tail_; - tail_ = pnodeConfig; - } - - // Set the next available pnid - nextPNid_ = (pnodeConfigInfo.pnid == nextPNid_) ? (pnodeConfigInfo.pnid+1) : nextPNid_ ; - if ( nextPNid_ == pnodesConfigMax_ ) - { // We are at the limit, search for unused pnid from begining - nextPNid_ = -1; - for (int i = 0; i < pnodesConfigMax_; i++ ) - { - if ( pnodesConfig_[i] == NULL ) - { - nextPNid_ = i; - break; - } - } - } - else if ( pnodesConfig_[nextPNid_] != NULL ) - { // pnid is in use - int next = ((nextPNid_ + 1) < pnodesConfigMax_) ? nextPNid_ + 1 : 0 ; - nextPNid_ = -1; - for (int i = next; i < pnodesConfigMax_; i++ ) - { - if ( pnodesConfig_[i] == NULL ) - { - nextPNid_ = i; - break; - } - } - } - - if (trace_settings & (TRACE_INIT | TRACE_REQUEST)) - { - trace_printf( "%s@%d - Added physical node configuration object\n" - " (pnid=%d, nextPNid_=%d)\n" - " (pnodesCount_=%d,pnodesConfigMax=%d)\n" - , method_name, __LINE__ - , pnodeConfigInfo.pnid, nextPNid_ - , pnodesCount_, pnodesConfigMax_); - } - } - else - { - 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)); - mon_log_write(MON_PNODECONF_ADD_PNODE_2, SQ_LOG_ERR, la_buf); - } - - TRACE_EXIT; - return( pnodeConfig ); -} - -void CPNodeConfigContainer::DeletePNodeConfig( CPNodeConfig *pnodeConfig ) -{ - const char method_name[] = "CPNodeConfigContainer::DeletePNodeConfig"; - TRACE_ENTRY; - - if (trace_settings & (TRACE_INIT | TRACE_REQUEST)) - { - trace_printf( "%s@%d Deleting node=%s, pnid=%d, nextPNid_=%d\n" - , method_name, __LINE__ - , pnodeConfig->GetName() - , pnodeConfig->GetPNid() - , nextPNid_ ); - } - - int pnid = pnodeConfig->GetPNid(); - pnodesConfig_[pnid] = NULL; - - if ( head_ == pnodeConfig ) - head_ = pnodeConfig->next_; - if ( tail_ == pnodeConfig ) - tail_ = pnodeConfig->prev_; - if ( pnodeConfig->prev_ ) - pnodeConfig->prev_->next_ = pnodeConfig->next_; - if ( pnodeConfig->next_ ) - pnodeConfig->next_->prev_ = pnodeConfig->prev_; - delete pnodeConfig; - - // Decrement the physical node configuration count - pnodesCount_--; - - if ( nextPNid_ == -1 ) - { // We are at the limit, use the deleted pnid as the next available - nextPNid_ = pnid; - } - else if ( nextPNid_ > pnid ) - { // Always use the lower pnid value - nextPNid_ = pnid; - } - - if (trace_settings & (TRACE_INIT | TRACE_REQUEST)) - { - trace_printf( "%s@%d - Deleted physical node configuration object\n" - " (pnid=%d, nextPNid_=%d)\n" - " (pnodesCount_=%d,pnodesConfigMax=%d)\n" - , method_name, __LINE__ - , pnid, nextPNid_ - , pnodesCount_, pnodesConfigMax_); - } - TRACE_EXIT; -} - -int CPNodeConfigContainer::GetPNid( char *nodename ) -{ - const char method_name[] = "CPNodeConfigContainer::GetPNid"; - TRACE_ENTRY; - - int pnid = -1; - CPNodeConfig *config = head_; - while (config) - { - if ( hostnamecmp( config->GetName(), nodename ) == 0 ) - { - pnid = config->GetPNid(); - break; - } - config = config->GetNext(); - } - - TRACE_EXIT; - return( pnid ); -} - -CPNodeConfig *CPNodeConfigContainer::GetPNodeConfig( char *nodename ) -{ - const char method_name[] = "CPNodeConfigContainer::GetPNodeConfig"; - TRACE_ENTRY; - - CPNodeConfig *config = head_; - while (config) - { - if ( hostnamecmp( config->GetName(), nodename ) == 0 ) - { - break; - } - config = config->GetNext(); - } - - TRACE_EXIT; - return config; -} - -CPNodeConfig *CPNodeConfigContainer::GetPNodeConfig( int pnid ) -{ - const char method_name[] = "CPNodeConfigContainer::GetPNodeConfig"; - TRACE_ENTRY; - - CPNodeConfig *config = head_; - while (config) - { - if ( config->GetPNid() == pnid ) - { - break; - } - config = config->GetNext(); - } - - TRACE_EXIT; - return config; -} - -void CPNodeConfigContainer::GetSpareNodesConfigSet( const char *name - , PNodesConfigList_t &spareSet ) -{ - bool foundInSpareSet = false; - CPNodeConfig *spareNodeConfig; - CPNodeConfig *pNodeconfig; - PNodesConfigList_t tempSpareSet; - - const char method_name[] = "CPNodeConfigContainer::GetSpareNodesConfigSet"; - TRACE_ENTRY; - - PNodesConfigList_t::iterator itSn; - for ( itSn = spareNodesConfigList_.begin(); - itSn != spareNodesConfigList_.end(); - itSn++ ) - { - spareNodeConfig = *itSn; - if (trace_settings & TRACE_INIT) - { - trace_printf( "%s@%d - %s is a configured spare node\n" - , method_name, __LINE__ - , spareNodeConfig->GetName()); - } - - // Build the set of pnids that constitute the 'spare set' - int sparePNidsCount = spareNodeConfig->GetSparesCount()+1; - int *sparePNids = new int [sparePNidsCount]; - spareNodeConfig->GetSpareList( sparePNids ); - sparePNids[spareNodeConfig->GetSparesCount()] = spareNodeConfig->GetPNid(); - - // Build the list of configured physical nodes that - // constitute the 'spare set' - for ( int i = 0; i < sparePNidsCount ; i++ ) - { - pNodeconfig = GetPNodeConfig( sparePNids[i] ); - if ( pNodeconfig ) - { - tempSpareSet.push_back( pNodeconfig ); - if (trace_settings & TRACE_INIT) - { - trace_printf( "%s@%d - Added %s as member of spare set (%s, count=%ld)\n" - , method_name, __LINE__ - , pNodeconfig->GetName() - , spareNodeConfig->GetName() - , tempSpareSet.size() ); - } - } - } - - // Check each node in the 'spare set' - PNodesConfigList_t::iterator itSnSet; - for ( itSnSet = tempSpareSet.begin(); - itSnSet != tempSpareSet.end(); - itSnSet++ ) - { - pNodeconfig = *itSnSet; - if (trace_settings & TRACE_INIT) - { - trace_printf( "%s@%d - %s is in spare set (%s, count=%ld)\n" - , method_name, __LINE__ - , pNodeconfig->GetName() - , spareNodeConfig->GetName() - , tempSpareSet.size() ); - } - if ( CPNodeConfigContainer::hostnamecmp( pNodeconfig->GetName(), name ) == 0 ) - { - foundInSpareSet = true; - spareSet = tempSpareSet; - if (trace_settings & TRACE_INIT) - { - trace_printf( "%s@%d - Found %s in spare set (%s, count=%ld)\n" - , method_name, __LINE__ - , pNodeconfig->GetName() - , spareNodeConfig->GetName() - , tempSpareSet.size() ); - } - } - } - if (sparePNids) - { - tempSpareSet.clear(); - delete [] sparePNids; - } - if (foundInSpareSet) - { - break; - } - } - - TRACE_EXIT; -} - -int CPNodeConfigContainer::hostnamecmp( const char *p_str1, const char *p_str2 ) -{ - static bool sb_first_time = true; - static bool sb_strict_hostname_check = false; - if ( sb_first_time ) - { - sb_first_time = false; - char *lv_envvar=getenv( "MON_STRICT_HOSTNAME_CHECK" ); - - if ( lv_envvar && (atoi( lv_envvar ) == 1) ) - { - sb_strict_hostname_check = true; - } - } - - if ( !p_str1 ) return 1; - if ( !p_str2 ) return 1; - - // Compare the string passed in - int lv_ret = strcmp( p_str1, p_str2 ); - if ( lv_ret == 0 ) - { // Got a match! - return lv_ret; - } - if ( sb_strict_hostname_check ) - { - return lv_ret; - } - - char lv_str1_to_cmp[1024]; - char lv_str2_to_cmp[1024]; - memset( lv_str1_to_cmp, 0, 1024 ); - memset( lv_str2_to_cmp, 0, 1024 ); - - char *lp_str1_dot = strchr( (char *) p_str1, '.' ); - if ( lp_str1_dot ) - { // Found '.', copy up to one char before '.' - memcpy( lv_str1_to_cmp, p_str1, lp_str1_dot - p_str1 ); - } - else - { // Copy entire string - strcpy( lv_str1_to_cmp, p_str1 ); - } - - char *lp_str2_dot = strchr( (char *) p_str2, '.' ); - if ( lp_str2_dot ) - { // Found '.', copy up to one char before '.' - memcpy( lv_str2_to_cmp, p_str2, lp_str2_dot - p_str2 ); - } - else - { // Copy entire string - strcpy( lv_str2_to_cmp, p_str2 ); - } - - // Ignore case - NormalizeCase( lv_str1_to_cmp ); - NormalizeCase( lv_str2_to_cmp ); - return strcmp( lv_str1_to_cmp, lv_str2_to_cmp ); -} - -char *CPNodeConfigContainer::NormalizeCase( char *token ) -{ - char *ptr = token; - - const char method_name[] = "CPNodeConfigContainer::NormalizeCase"; - TRACE_ENTRY; - - while ( *ptr ) - { - *ptr = tolower( *ptr ); - if ( *ptr == '\n' ) *ptr = '\0'; - ptr++; - } - - TRACE_EXIT; - return token; -} - http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/pnodeconfig.h ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/pnodeconfig.h b/core/sqf/monitor/linux/pnodeconfig.h deleted file mode 100644 index 5deccc8..0000000 --- a/core/sqf/monitor/linux/pnodeconfig.h +++ /dev/null @@ -1,130 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// @@@ START COPYRIGHT @@@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// -// @@@ END COPYRIGHT @@@ -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef PNODECONFIG_H_ -#define PNODECONFIG_H_ - -#include <list> - -#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( pnodeConfigInfo_t &pnodeConfigInfo ); - void Clear( void ); - static int hostnamecmp(const char *p_str1, const char *p_str2); - void DeletePNodeConfig( CPNodeConfig *pnodeConfig ); - inline CPNodeConfig *GetFirstPNodeConfig( void ) { return ( head_ ); } - inline int GetNextPNid( void ) { return ( nextPNid_ ); } - int GetPNid( char *nodename ); - CPNodeConfig *GetPNodeConfig( char *nodename ); - CPNodeConfig *GetPNodeConfig( int pnid ); - inline int GetPNodesConfigMax( void ) { return ( pnodesConfigMax_ ); } - inline int GetPNodesCount( void ) { return ( pnodesCount_ ); } - inline int GetSNodesCount( void ) { return ( snodesCount_ ); } - inline PNodesConfigList_t *GetSpareNodesConfigList( void ) { return ( &spareNodesConfigList_ ); } - void GetSpareNodesConfigSet( const char *name, PNodesConfigList_t &spareSet ); - -protected: - CPNodeConfig **pnodesConfig_;// array of physical node configuration objects - int pnodesCount_; // # of physical nodes - int snodesCount_; // # of spare nodes - int nextPNid_; // next physical node id available - -private: - static char *NormalizeCase( char *token ); - - int pnodesConfigMax_; // maximum number of physical nodes - PNodesConfigList_t spareNodesConfigList_; // configured spare nodes list - CPNodeConfig *head_; // head of physical nodes linked list - CPNodeConfig *tail_; // tail of physical nodes linked list - -}; - -class CPNodeConfig : public CLNodeConfigContainer -{ - friend CPNodeConfig *CPNodeConfigContainer::AddPNodeConfig( pnodeConfigInfo_t &pnodeConfigInfo ); - friend void CPNodeConfigContainer::DeletePNodeConfig( CPNodeConfig *pnodeConfig ); -public: - - CPNodeConfig( CPNodeConfigContainer *pnodesConfig - , pnodeConfigInfo_t &pnodeConfigInfo - ); - ~CPNodeConfig( void ); - - inline cpu_set_t &GetExcludedCoreMask( void ) { return (excludedCoreMask_); } - inline int GetExcludedFirstCore( void ) { return ( excludedFirstCore_ ); } - inline int GetExcludedLastCore( void ) { return ( excludedLastCore_ ); } - inline const char *GetName( void ) { return ( name_ ); } - inline CPNodeConfig *GetNext( void ) { return ( next_ ); } - inline int GetPNid( void ) { return ( pnid_ ); } - void SetName( const char *newName ); - void SetExcludedFirstCore( int excludedFirstCore ); - void SetExcludedLastCore( int excludedLastCore ); - int GetSpareList( int sparePNid[] ); - inline int GetSparesCount( void ) { return ( sparePNidsCount_ ); } - - inline bool IsSpareNode( void ) { return ( spareNode_ ); } - inline void SetExcludedCoreMask( cpu_set_t &coreMask ) { excludedCoreMask_ = coreMask; } - void SetSpareList( int sparePNid[], int spareCount ); - void ResetSpare( void ); - -protected: -private: - CPNodeConfigContainer *pnodesConfig_; // physical nodes container - char name_[MPI_MAX_PROCESSOR_NAME]; // hostname - int pnid_; // physical node identifier - cpu_set_t excludedCoreMask_; // mask of excluded SMP processor cores - int excludedFirstCore_;// First excluded SMP processor core used by logical node - int excludedLastCore_; // Last excluded SMP processor core used by logical node - bool spareNode_; // true when this is a spare physical node - int *sparePNids_; // array of pnids this physical node can spare - int sparePNidsCount_; // # of entries in spare sparePNids_ array - - CPNodeConfig *next_; // next PNodeConfig in CPNodeConfigContainer list - CPNodeConfig *prev_; // previous PNodeConfig in CPNodeConfigContainer list -}; - -#endif /* PNODECONFIG_H_ */ http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/pstartd.h ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/pstartd.h b/core/sqf/monitor/linux/pstartd.h index 9c2f0e2..9d8a831 100644 --- a/core/sqf/monitor/linux/pstartd.h +++ b/core/sqf/monitor/linux/pstartd.h @@ -35,7 +35,7 @@ using namespace std; #include "msgdef.h" #include "lock.h" -#include "trafconfig.h" +#include "trafconf/trafconfig.h" class CMonUtil { http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/reqnodeadd.cxx ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/reqnodeadd.cxx b/core/sqf/monitor/linux/reqnodeadd.cxx index 760e5a2..8333df6 100644 --- a/core/sqf/monitor/linux/reqnodeadd.cxx +++ b/core/sqf/monitor/linux/reqnodeadd.cxx @@ -137,7 +137,7 @@ void CExtNodeAddReq::performRequest() clusterConfig->SetCoreMask( lnodeConfigInfo.lastCore , lnodeConfigInfo.firstCore , lnodeConfigInfo.coreMask ); - lnodeConfigInfo.zoneType = (ZoneType)msg_->u.request.u.node_add.roles; + lnodeConfigInfo.zoneType = static_cast<ZoneType>(msg_->u.request.u.node_add.roles); lnodeConfig = new CLNodeConfig( pnodeConfig , lnodeConfigInfo ); if (lnodeConfig) http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/shell.cxx ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/shell.cxx b/core/sqf/monitor/linux/shell.cxx index 5037dd3..5ad73ab 100644 --- a/core/sqf/monitor/linux/shell.cxx +++ b/core/sqf/monitor/linux/shell.cxx @@ -3097,7 +3097,8 @@ bool load_configuration( void ) // It was previously loaded, remove the current configuration ClusterConfig.Clear(); } - if ( ClusterConfig.Initialize( traceFileName ) ) + bool traceEnabled = (trace_settings & TRACE_TRAFCONFIG) ? true : false; + if ( ClusterConfig.Initialize( traceEnabled, traceFileName ) ) { if ( ! ClusterConfig.LoadConfig() ) { @@ -3211,7 +3212,7 @@ void node_add( char *node_name, int first_core, int last_core, int processors, i " roles = %s\n" , method_name, __LINE__, MyName , node_name, first_core, last_core, processors - , RoleTypeString( (ZoneType) roles )); + , RoleTypeString( static_cast<ZoneType>(roles) )); // Check that node_name is not in the configuration pnid = get_pnid_by_node_name( node_name ); http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/tcdb.cxx ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/tcdb.cxx b/core/sqf/monitor/linux/tcdb.cxx deleted file mode 100644 index 6f99195..0000000 --- a/core/sqf/monitor/linux/tcdb.cxx +++ /dev/null @@ -1,478 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// @@@ START COPYRIGHT @@@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// -// @@@ END COPYRIGHT @@@ -// -/////////////////////////////////////////////////////////////////////////////// - -#include <stdlib.h> -#include <string.h> -#include <cctype> -#include <string> - -using namespace std; - -#include "tclog.h" -#include "tctrace.h" -#include "trafconfig.h" -//#include "tcdbzstore.h" -#include "tcdbsqlite.h" -#include "tcdb.h" - -/////////////////////////////////////////////////////////////////////////////// -// Cluster Configuration -/////////////////////////////////////////////////////////////////////////////// - -CTcdb::CTcdb( void ) - : dbStorageType_(TCDBSTOREUNDEFINED) - , tcdbStore_(NULL) -{ - const char method_name[] = "CTcdb::CTcdb"; - TRACE_ENTRY; - - memcpy(&eyecatcher_, "TCDB", 4); - - char *env; - string tcDbType; - size_t found; - - env = getenv("TRAF_CONFIG_DBSTORE"); - if ( env ) - { - char c; - int i = 0; - while ( env[i] ) - { - c=env[i]; - env[i] = (char) toupper( c ); - i++; - } - tcDbType = env; - if ( tcDbType.length() == 0 ) - { - char buf[TC_LOG_BUF_SIZE]; - snprintf( buf, sizeof(buf) - , "[%s], Environment variable TRAF_CONFIGDB_STORE value is not set, " - "defaulting to SQLite storage method!\n" - , method_name ); - TcLogWrite( TCDB_TCDB_1, TC_LOG_WARNING, buf ); - dbStorageType_ = TCDBSQLITE; - } - else - { - found = tcDbType.find( TC_STORE_SQLITE ); - if (found != std::string::npos) - { - dbStorageType_ = TCDBSQLITE; - } - else - { - found = tcDbType.find( TC_STORE_ZOOKEEPER ); - if (found != std::string::npos) - { - dbStorageType_ = TCDBZOOKEEPER; - } - else - { - found = tcDbType.find( TC_STORE_POSTGRESQL ); - if (found != std::string::npos) - { - dbStorageType_ = TCDBPOSTGRESQL; - } - else - { - found = tcDbType.find( TC_STORE_MYSQL ); - if (found != std::string::npos) - { - dbStorageType_ = TCDBMYSQL; - } - else - { - if ( tcDbType.length() == 0 ) - { - char buf[TC_LOG_BUF_SIZE]; - snprintf( buf, sizeof(buf) - , "[%s], Environment variable TRAF_CONFIG_DBSTORE value (%s) invalid!\n" - , method_name, tcDbType.c_str() ); - TcLogWrite( TCDB_TCDB_2, TC_LOG_CRIT, buf ); - TRACE_EXIT; - } - } - } - } - } - } - } - else - { - // Environment variable TRAF_CONFIG_DBSTORE is undefined - // defaulting to SQLite storage method! - dbStorageType_ = TCDBSQLITE; - } - - TRACE_EXIT; -} - -CTcdb::~CTcdb ( void ) -{ - const char method_name[] = "CTcdb::~CTcdb"; - TRACE_ENTRY; - memcpy(&eyecatcher_, "tcdb", 4); - TRACE_EXIT; -} - -int CTcdb::AddRegistryKey( const char *key ) -{ - const char method_name[] = "CTcdb::AddRegistryKey"; - TRACE_ENTRY; - - int rc = tcdbStore_->AddRegistryKey( key ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::AddRegistryProcess( const char *processName ) -{ - const char method_name[] = "CTcdb::AddRegistryProcess"; - TRACE_ENTRY; - - int rc = tcdbStore_->AddRegistryProcess( processName ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::AddRegistryClusterData( const char *key - , const char *dataValue ) -{ - const char method_name[] = "CTcdb::AddRegistryClusterData"; - TRACE_ENTRY; - - int rc = tcdbStore_->AddRegistryClusterData( key, dataValue ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::AddRegistryProcessData( const char *processName - , const char *key - , const char *dataValue ) -{ - const char method_name[] = "CTcdb::AddRegistryProcessData"; - TRACE_ENTRY; - - int rc = tcdbStore_->AddRegistryProcessData( processName, key, dataValue ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::AddUniqueString( int nid - , int id - , const char *uniqStr ) -{ - const char method_name[] = "CTcdb::AddUniqueString"; - TRACE_ENTRY; - - int rc = tcdbStore_->AddUniqueString( nid, id, uniqStr ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::Close( void ) -{ - const char method_name[] = "CTcdb::Close"; - TRACE_ENTRY; - - int rc = tcdbStore_->Close(); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::DeleteNodeData( int pnid ) -{ - const char method_name[] = "CTcdb::DeleteNodeData"; - TRACE_ENTRY; - - int rc = tcdbStore_->DeleteNodeData( pnid ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::DeleteUniqueString( int nid ) -{ - const char method_name[] = "CTcdb::DeleteUniqueString"; - TRACE_ENTRY; - - int rc = tcdbStore_->DeleteUniqueString( nid ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::Initialize( void ) -{ - const char method_name[] = "CTcdb::Initialize"; - TRACE_ENTRY; - - if ( IsInitialized() ) - { - return( TCALREADYINIT ); - } - - if (!tcdbStore_) - { - switch (dbStorageType_) - { - case TCDBZOOKEEPER: -// tcdbStore_ = new CTcdbZstore; - return( TCNOTIMPLEMENTED ); - break; - case TCDBSQLITE: - tcdbStore_ = new CTcdbSqlite; - break; - default: - TRACE_EXIT; - return( TCNOTIMPLEMENTED ); - } - } - - int rc = tcdbStore_->Initialize(); - - TRACE_EXIT; - return( rc ); -} - -bool CTcdb::IsInitialized( void ) -{ - const char method_name[] = "CTcdb::IsInitialized"; - TRACE_ENTRY; - - bool rs = false; - if ( tcdbStore_ ) - { - rs = tcdbStore_->IsInitialized(); - } - - TRACE_EXIT; - return( rs ); -} - -int CTcdb::GetNode( int nid - , node_configuration_t &nodeConfig ) -{ - const char method_name[] = "CTcdb::GetNode"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetNode( nid, nodeConfig ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetNode( const char *name - , node_configuration_t &nodeConfig ) -{ - const char method_name[] = "CTcdb::GetNode"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetNode( name, nodeConfig ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetNodes( int &count - , int max - , node_configuration_t nodeConfig[] ) -{ - const char method_name[] = "CTcdb::GetNodes"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetNodes( count, max, nodeConfig ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetPNode( int pNid - , physical_node_configuration_t &pnodeConfig ) -{ - const char method_name[] = "CTcdb::GetPNode"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetPNode( pNid, pnodeConfig ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetPNode( const char *name - , physical_node_configuration_t &pnodeConfig ) -{ - const char method_name[] = "CTcdb::GetPNode"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetPNode( name, pnodeConfig ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetSNodes( int &count - , int max - , physical_node_configuration_t spareNodeConfig[] ) -{ - const char method_name[] = "CTcdb::GetSNodes"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetSNodes( count, max, spareNodeConfig ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetPersistProcess( const char *persistPrefix - , persist_configuration_t &persistConfig ) -{ - const char method_name[] = "CTcdb::GetPersistProcess"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetPersistProcess( persistPrefix, persistConfig ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetPersistProcessKeys( const char *persistProcessKeys ) -{ - const char method_name[] = "CTcdb::GetPersistProcessKeys"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetPersistProcessKeys( persistProcessKeys ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetRegistryClusterSet( int &count - , int max - , registry_configuration_t registryConfig[] ) -{ - const char method_name[] = "CTcdb::GetRegistryClusterSet"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetRegistryClusterSet( count, max, registryConfig ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetRegistryProcessSet( int &count - , int max - , registry_configuration_t registryConfig[] ) -{ - const char method_name[] = "CTcdb::GetRegistryProcessSet"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetRegistryProcessSet( count, max, registryConfig ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetUniqueString( int nid, int id, const char *uniqStr ) -{ - const char method_name[] = "CTcdb::GetUniqueString"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetUniqueString( nid, id, uniqStr ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetUniqueStringId( int nid - , const char *uniqStr - , int &id ) -{ - const char method_name[] = "CTcdb::GetUniqueStringId"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetUniqueStringId( nid, uniqStr, id ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::GetUniqueStringIdMax( int nid, int &id ) -{ - const char method_name[] = "CTcdb::GetUniqueStringIdMax"; - TRACE_ENTRY; - - int rc = tcdbStore_->GetUniqueStringIdMax( nid, id ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::SaveLNodeData( int nid - , int pnid - , int firstCore - , int lastCore - , int processors - , int roles ) -{ - const char method_name[] = "CTcdb::SaveLNodeData"; - TRACE_ENTRY; - - int rc = tcdbStore_->SaveLNodeData( nid - , pnid - , firstCore - , lastCore - , processors - , roles ); - - TRACE_EXIT; - return( rc ); -} - -int CTcdb::SavePNodeData( const char *name - , int pnid - , int excludedFirstCore - , int excludedLastCore ) -{ - const char method_name[] = "CTcdb::SavePNodeData"; - TRACE_ENTRY; - - - int rc = tcdbStore_->SavePNodeData( name - , pnid - , excludedFirstCore - , excludedLastCore ); - - TRACE_EXIT; - return( rc ); -} http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/tcdb.h ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/tcdb.h b/core/sqf/monitor/linux/tcdb.h deleted file mode 100644 index a9ee2c6..0000000 --- a/core/sqf/monitor/linux/tcdb.h +++ /dev/null @@ -1,117 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// @@@ START COPYRIGHT @@@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// -// @@@ END COPYRIGHT @@@ -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef TCDB_H_ -#define TCDB_H_ - -#include <stdlib.h> -#include "tcdbsqlite.h" -//#include "tcdbzstore.h" -#include "trafconfig.h" - -using namespace std; - - -// -// Trafodion Configuration Database Adaptor (CTrafConfigDb class) -// -// Implements common interface to storage classes used by the -// Trafodion Configuration API (trafconfig.cxx/.h). -// - -class CTcdb -{ -private: - int eyecatcher_; // Debuggging aid -- leave as first - // member variable of the class -public: - - CTcdb( void ); - ~CTcdb( void ); - - int Close( void ); - int AddRegistryKey( const char *key ); - int AddRegistryProcess( const char *name ); - int AddRegistryClusterData( const char *key, const char *dataValue ); - int AddRegistryProcessData( const char *procName - , const char *key - , const char *dataValue ); - int AddUniqueString( int nid, int id, const char *uniqStr ); - int DeleteNodeData( int pnid ); - int DeleteUniqueString( int nid ); - int GetNode( int nid - , node_configuration_t &nodeConfig ); - int GetNode( const char *name - , node_configuration_t &nodeConfig ); - int GetNodes( int &count - , int max - , node_configuration_t nodeConfig[] ); - int GetPNode( int pnid - , physical_node_configuration_t &pnodeConfig ); - int GetPNode( const char *name - , physical_node_configuration_t &pnodeConfig ); - int GetSNodes( int &count - , int max - , physical_node_configuration_t pNodeConfig[] ); - int GetPersistProcess( const char *persistPrefix - , persist_configuration_t &persistConfig ); - int GetPersistProcessKeys( const char *persistProcessKeys ); - int GetRegistryClusterSet( int &count - , int max - , registry_configuration_t registryConfig[] ); - int GetRegistryProcessSet( int &count - , int max - , registry_configuration_t registryConfig[] ); - inline TC_STORAGE_TYPE GetStorageType( void ) { return(dbStorageType_); } - int GetUniqueString( int nid, int id, const char *uniqStr ); - int GetUniqueStringId( int nid - , const char *uniqStr - , int &id ); - int GetUniqueStringIdMax( int nid, int &id ); - int Initialize( void ); - bool IsInitialized( void ); - int SaveLNodeData( int nid - , int pnid - , int firstCore - , int lastCore - , int processors - , int roles ); - int SavePNodeData( const char *name - , int pnid - , int excludedFirstCore - , int excludedLastCore ); - int UpdatePNodeConfig( int pnid - , const char *name - , int excludedFirstCore - , int excludedLastCore ); - -protected: -private: - TC_STORAGE_TYPE dbStorageType_; - CTcdbStore *tcdbStore_; -}; - - -#endif /* TCDB_H_ */
