[TRAFODION-2650] Restructured Trafodion Configuration code into separate directory structure.
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/87849fcf Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/87849fcf Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/87849fcf Branch: refs/heads/master Commit: 87849fcf8199857e0c525d332a061db8744c86cb Parents: 0edae94 Author: Zalo Correa <[email protected]> Authored: Thu Feb 1 17:51:35 2018 -0800 Committer: Zalo Correa <[email protected]> Committed: Thu Feb 1 17:51:35 2018 -0800 ---------------------------------------------------------------------- core/.gitignore | 2 +- core/sqf/Makefile | 10 +- core/sqf/export/include/trafconf/trafconfig.h | 349 ++ core/sqf/monitor/linux/clusterconf.cxx | 863 ----- core/sqf/monitor/linux/clusterconf.h | 118 - core/sqf/monitor/linux/getseq.cxx | 2 - core/sqf/monitor/linux/lnode.h | 1 + core/sqf/monitor/linux/lnodeconfig.cxx | 399 --- core/sqf/monitor/linux/lnodeconfig.h | 119 - core/sqf/monitor/linux/macros.gmk | 10 + core/sqf/monitor/linux/makefile | 116 +- core/sqf/monitor/linux/monlogging.cxx | 3 +- core/sqf/monitor/linux/msgdef.h | 27 +- core/sqf/monitor/linux/persistconfig.cxx | 636 ---- core/sqf/monitor/linux/persistconfig.h | 165 - core/sqf/monitor/linux/pnode.cxx | 3 +- core/sqf/monitor/linux/pnode.h | 2 - core/sqf/monitor/linux/pnodeconfig.cxx | 631 ---- core/sqf/monitor/linux/pnodeconfig.h | 130 - core/sqf/monitor/linux/pstartd.h | 2 +- core/sqf/monitor/linux/reqnodeadd.cxx | 2 +- core/sqf/monitor/linux/shell.cxx | 5 +- core/sqf/monitor/linux/tcdb.cxx | 478 --- core/sqf/monitor/linux/tcdb.h | 117 - core/sqf/monitor/linux/tcdbsqlite.cxx | 3390 -------------------- core/sqf/monitor/linux/tcdbsqlite.h | 130 - core/sqf/monitor/linux/tcdbstore.cxx | 55 - core/sqf/monitor/linux/tcdbstore.h | 113 - core/sqf/monitor/linux/tcdbzstore.cxx | 2192 ------------- core/sqf/monitor/linux/tcdbzstore.h | 130 - core/sqf/monitor/linux/tclog.cxx | 121 - core/sqf/monitor/linux/tclog.h | 46 - core/sqf/monitor/linux/tctrace.cxx | 366 --- core/sqf/monitor/linux/tctrace.h | 103 - core/sqf/monitor/linux/trafconf.cxx | 631 ---- core/sqf/monitor/linux/trafconfig.cxx | 560 ---- core/sqf/monitor/linux/trafconfig.h | 305 -- core/sqf/sqenvcom.sh | 9 + core/sqf/sql/scripts/monitor.env | 59 + core/sqf/sql/scripts/sqconfig.sample | 7 + core/sqf/sql/scripts/sqgen | 62 +- core/sqf/src/Makefile | 4 + core/sqf/src/trafconf/Makefile | 119 + core/sqf/src/trafconf/clusterconf.cpp | 855 +++++ core/sqf/src/trafconf/clusterconf.h | 118 + core/sqf/src/trafconf/lnodeconfig.cpp | 397 +++ core/sqf/src/trafconf/lnodeconfig.h | 121 + core/sqf/src/trafconf/macros.gmk | 112 + core/sqf/src/trafconf/persistconfig.cpp | 637 ++++ core/sqf/src/trafconf/persistconfig.h | 164 + core/sqf/src/trafconf/pnodeconfig.cpp | 629 ++++ core/sqf/src/trafconf/pnodeconfig.h | 131 + core/sqf/src/trafconf/tcdb.cpp | 474 +++ core/sqf/src/trafconf/tcdb.h | 118 + core/sqf/src/trafconf/tcdbsqlite.cpp | 3390 ++++++++++++++++++++ core/sqf/src/trafconf/tcdbsqlite.h | 130 + core/sqf/src/trafconf/tcdbstore.cpp | 56 + core/sqf/src/trafconf/tcdbstore.h | 112 + core/sqf/src/trafconf/tclog.cpp | 121 + core/sqf/src/trafconf/tclog.h | 46 + core/sqf/src/trafconf/tctrace.cpp | 367 +++ core/sqf/src/trafconf/tctrace.h | 105 + core/sqf/src/trafconf/trafconf.cpp | 630 ++++ core/sqf/src/trafconf/trafconfig.cpp | 599 ++++ 64 files changed, 9950 insertions(+), 11954 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/.gitignore ---------------------------------------------------------------------- diff --git a/core/.gitignore b/core/.gitignore index c20d35c..10db5be 100644 --- a/core/.gitignore +++ b/core/.gitignore @@ -3,4 +3,4 @@ *.o *.jar trafodion*.tgz - +sqf/sql/scripts/DUMPENVS http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/Makefile ---------------------------------------------------------------------- diff --git a/core/sqf/Makefile b/core/sqf/Makefile index 2c1d952..36ecc8d 100644 --- a/core/sqf/Makefile +++ b/core/sqf/Makefile @@ -41,7 +41,7 @@ SQL_W=$(TRAF_HOME)/../sql DP2=se MISC = win misc_sec -SQ_COMPONENTS := make_sqevlog seabed stfs $(MISC) tm $(SEAMONSTER_TARGET) make_sql make_monitor tools hbase_utilities +SQ_COMPONENTS := make_sqevlog seabed stfs trafconf $(MISC) tm $(SEAMONSTER_TARGET) make_sql make_monitor tools hbase_utilities .PHONY: $(SQ_COMPONENTS) @@ -57,6 +57,8 @@ win: make_sqevlog seabed seabed: make_sqevlog cd src/seabed; $(MAKE) 2>&1 | sed -e "s/$$/ ##(SQF)/" ; exit $${PIPESTATUS[0]} +trafconf: make_sqevlog + cd src/trafconf; $(MAKE) 2>&1 | sed -e "s/$$/ ##(SQF)/" ; exit $${PIPESTATUS[0]} tm: seabed make_sqevlog cd src/tm; $(MAKE) 2>&1 | sed -e "s/$$/ ##(SQF)/" ; exit $${PIPESTATUS[0]} @@ -72,7 +74,7 @@ make_sql: $(SEAMONSTER_TARGET) win hbase_utilities cd sql; $(MAKE) WROOT=$(SQL_W) 2>&1 | sed -e "s/$$/ ##(SQL)/" ; exit $${PIPESTATUS[0]} cd $(TRAF_HOME)/sql/scripts && ./makemsg.ksh 2>&1 | sed -e "s/$$/ ##(SQL)/" ; exit $${PIPESTATUS[0]} -make_monitor: stfs make_sqevlog seabed +make_monitor: stfs make_sqevlog seabed trafconf cd monitor/linux; $(MAKE) 2>&1 | sed -e "s/$$/ ##(SQF)/" ; exit $${PIPESTATUS[0]} stfs: make_sqevlog @@ -108,6 +110,7 @@ clean: setupdir_clean -cd src/tm; $(MAKE) clean -cd sql; $(MAKE) WROOT=$(SQL_W) clean -cd sqevlog; $(MAKE) clean + -cd src/trafconf; $(MAKE) clean -cd hbase_utilities; $(MAKE) clean # from genverhdr.ksh rm -f export/include/SCMBuildStr.h export/include/SCMBuildStr.java export/include/buildId @@ -123,6 +126,7 @@ cleanall: setupdir_clean -cd src/tm; $(MAKE) cleanall -cd sql; $(MAKE) WROOT=$(SQL_W) clean -cd sqevlog; $(MAKE) cleanall + -cd src/trafconf; $(MAKE) cleanall -cd hbase_utilities; $(MAKE) clean # from genverhdr.ksh rm -f export/include/SCMBuildStr.h export/include/SCMBuildStr.java export/include/buildId @@ -135,6 +139,7 @@ cleaner: -cd src/stfs; $(MAKE) -f Makefile.stub cleaner -cd src/win; $(MAKE) cleaner -cd src/tm; $(MAKE) cleaner + -cd src/trafconf; $(MAKE) cleaner -cd sql; $(MAKE) WROOT=$(SQL_W) cleaner -cd sqevlog; $(MAKE) cleaner @@ -181,6 +186,7 @@ setupdir: -cd src/win; $(MAKE) setup -cd src/seabed; $(MAKE) setup -cd src/tm; $(MAKE) setup + -cd src/trafconf; $(MAKE) setup -cd sqevlog; $(MAKE) setup @# builds/copies 3rd party dependencies as necessary cd sql; $(MAKE) WROOT=$(SQL_W) setup http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/export/include/trafconf/trafconfig.h ---------------------------------------------------------------------- diff --git a/core/sqf/export/include/trafconf/trafconfig.h b/core/sqf/export/include/trafconf/trafconfig.h new file mode 100644 index 0000000..db137bf --- /dev/null +++ b/core/sqf/export/include/trafconf/trafconfig.h @@ -0,0 +1,349 @@ +/********************************************************************** +// @@@ 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 TRAFCONFIG_H_ +#define TRAFCONFIG_H_ + +// +// On Windows, this would actually do something like: +// #define TRAF_Export __declspec(dllexport) +// +#define TC_Export + +#ifdef USE_TRAFCONF_DIAGS +#define TC_DIAG_UNUSED __attribute__((warn_unused_result)) +#else +#define TC_DIAG_UNUSED +#endif + +#ifdef USE_TRAFCONF_DEPRECATED +#define TC_DIAG_DEPRECATED __attribute__((deprecated)) +#else +#define TC_DIAG_DEPRECATED +#endif + +#define TC_PROCESSOR_NAME_MAX 128 + +#define TC_REGISTRY_KEY_MAX 64 +#define TC_REGISTRY_VALUE_MAX 4096 +#define TC_PERSIST_PROCESSOR_NAME_MAX TC_PROCESSOR_NAME_MAX +#define TC_PERSIST_ROLES_MAX 128 +#define TC_PERSIST_KEY_MAX 64 +#define TC_PERSIST_VALUE_MAX 4096 +#define TC_PERSIST_KEYS_VALUE_MAX 4096 +#define TC_NODES_MAX 256 +#define TC_SPARE_NODES_MAX 256 +#define TC_UNIQUE_STRING_VALUE_MAX 4096 + +#define TC_STORE_MYSQL "MYSQL" +#define TC_STORE_POSTGRESQL "POSTGRESQL" +#define TC_STORE_SQLITE "SQLITE" + +#define PERSIST_PROCESS_KEYS "PERSIST_PROCESS_KEYS" +#define PERSIST_PROCESS_NAME_KEY "PROCESS_NAME" +#define PERSIST_PROCESS_TYPE_KEY "PROCESS_TYPE" +#define PERSIST_PROGRAM_NAME_KEY "PROGRAM_NAME" +#define PERSIST_PROGRAM_ARGS_KEY "PROGRAM_ARGS" +#define PERSIST_REQUIRES_DTM "REQUIRES_DTM" +#define PERSIST_STDOUT_KEY "STDOUT" +#define PERSIST_RETRIES_KEY "PERSIST_RETRIES" +#define PERSIST_ZONES_KEY "PERSIST_ZONES" + +#define TC_ROOT_NODE "/trafodion" +#define TC_INSTANCE_NODE "/instance" + +typedef enum { + ProcessType_Undefined=0, // No process type as been defined + ProcessType_TSE, // Identifies a Table Storage Engine (DP2) + ProcessType_DTM, // Identifies a Distributed Transaction Monitor process + ProcessType_ASE, // Identifies a Audit Storage Engine (ADP) + ProcessType_Generic, // Identifies a generic process + ProcessType_Watchdog, // Identifies the monitor's watchdog processes + ProcessType_AMP, // Identifies a AMP process + ProcessType_Backout, // Identifies a Backout process + ProcessType_VolumeRecovery, // Identifies a Volume Recovery process + ProcessType_MXOSRVR, // Identifies a MXOSRVR process + ProcessType_SPX, // Identifies a SeaPilot ProXy process + ProcessType_SSMP, // Identifies a SQL Statistics Merge Process (SSMP) + ProcessType_PSD, // Identifies the monitor's process start daemon processes + ProcessType_SMS, // Identifies a SeaMonster Service process + ProcessType_TMID, // Identifies a Transaction Management ID process + ProcessType_PERSIST, // Identifies a generic persistent process + + ProcessType_Invalid // marks the end of the process + // types, add any new process + // types before this one +} TC_PROCESS_TYPE; + +typedef enum { + ZoneType_Undefined = 0x0000, // No zone type defined + ZoneType_Edge = 0x0001, // Zone of service only nodes + ZoneType_Aggregation = 0x0002, // Zone of compute only nodes + ZoneType_Storage = 0x0004, // Zone of storage only nodes + ZoneType_Excluded = 0x0010, // Excluded cores + ZoneType_Any = ( ZoneType_Edge | ZoneType_Aggregation | ZoneType_Storage ), + ZoneType_Frontend = ( ZoneType_Edge | ZoneType_Aggregation ), + ZoneType_Backend = ( ZoneType_Aggregation | ZoneType_Storage ) +} TC_ZONE_TYPE; + +typedef enum { +//enum TC_STORAGE_TYPE { + TCDBSTOREUNDEFINED = 0 + , TCDBMYSQL = 1 // MySQL Database + , TCDBPOSTGRESQL = 2 // PostgresQL Database [TBD] + , TCDBSQLITE = 3 // Sqlite Database [deprecated] +} TC_STORAGE_TYPE; + +typedef enum { +//enum TC_ERRORS { + TCSUCCESS = 0 // Successful operation + , TCNOTIMPLEMENTED = -1 // Not implemented + , TCNOTINIT = -2 // Database not open + , TCALREADYINIT = -3 // Database already opened + , TCDBOPERROR = -4 // Database operation failed + , TCDBNOEXIST = -5 // Database operation yielded non-existent data + , TCDBTRUNCATE = -6 // Database operation returned less data than available + , TCDBCORRUPT = -7 // Internal processing error or database corruption +} TC_ERRORS; + +typedef struct node_configuration_s +{ + int nid; // Node Id (logical) + int pnid; // Physical Node ID + char node_name[TC_PERSIST_PROCESSOR_NAME_MAX]; // hostname + int excluded_first_core; // First or only core assigned + int excluded_last_core; // Last core assigned or -1 + int first_core; // First or only core assigned + int last_core; // Last core assigned or -1 + int processors; // Number logical processors + int roles; // Role assigment +} node_configuration_t; + +typedef struct physical_node_configuration_s +{ + int pnid; // Physical Node ID + char node_name[TC_PERSIST_PROCESSOR_NAME_MAX]; // hostname + int excluded_first_core; // First or only core assigned + int excluded_last_core; // Last core assigned or -1 + int spare_count; // Number of entries in spare_pnid[] + int spare_pnid[TC_SPARE_NODES_MAX]; // list of pnids for which this node can be a spare +} physical_node_configuration_t; + +typedef struct registry_configuration_s +{ + char scope[TC_REGISTRY_KEY_MAX]; + char key[TC_REGISTRY_KEY_MAX]; + char value[TC_REGISTRY_VALUE_MAX]; +} registry_configuration_t; + +typedef struct persist_configuration_s +{ + char persist_prefix[TC_PERSIST_KEY_MAX]; // DTM, TMID, or ... (PERSIST_PROCESS_KEYS) + char process_name[TC_PERSIST_VALUE_MAX]; // Process name {<prefix>[<format>]} + char process_type[TC_PERSIST_VALUE_MAX]; // DTM, TMID, PERSIST, ... + char program_name[TC_PERSIST_VALUE_MAX]; // Program executable name (no path in name) + char program_args[TC_PERSIST_VALUE_MAX]; // Program program arguments (runtime options) + char std_out[TC_PERSIST_VALUE_MAX]; // STDOUT {<prefix>[<format>]} + bool requires_DTM; // True when process requires transaction support + int persist_retries; // Process create retries + int persist_window; // Process create retries window (seconds) + char persist_zones[TC_PERSIST_VALUE_MAX]; // Process creation zones {<format>} +} persist_configuration_t; + + +TC_Export int tc_close( void ) +TC_DIAG_UNUSED; + +TC_Export const char *tc_errmsg( int err ) +TC_DIAG_UNUSED; + +TC_Export int tc_initialize( bool traceEnabled + , const char *traceFileName = NULL + , const char *instanceNode = NULL + , const char *rootNode = NULL ) +TC_DIAG_UNUSED; + +TC_Export TC_STORAGE_TYPE tc_get_storage_type( void ) +TC_DIAG_UNUSED; + +TC_Export int tc_delete_node( int nid + , const char *node_name ) +TC_DIAG_UNUSED; + +TC_Export int tc_get_node( const char *node_name + , node_configuration_t *node_config ) +TC_DIAG_UNUSED; + +TC_Export int tc_put_node( node_configuration_t *node_config ) +TC_DIAG_UNUSED; + + +TC_Export int tc_get_pnode( const char *node_name + , physical_node_configuration_t *pnode_config ) +TC_DIAG_UNUSED; + +TC_Export int tc_put_pnode( physical_node_configuration_t *pnode_config ) +TC_DIAG_UNUSED; + +// +// Call this to get all configured logical nodes +// +// count: is number of node_config array entries returned +// max: is size of the node_config array +// node_config: is array of logical node configuration entries +// +// if count would be greater than max, an error is returned +// if node_config is null, max is ignored and +// number of node_config entries is returned in count +// +TC_Export int tc_get_nodes( int *count + , int max + , node_configuration_t *node_config ) +TC_DIAG_UNUSED; + +// +// Call this to get all configured spare nodes +// +// count: is number of pnode_config array entries returned +// max: is size of the pnode_config array +// pnode_config: is array of spare node configuration entries +// +// if count would be greater than max, an error is returned +// if pnode_config is null, max is ignored and +// number of pnode_config array entries is returned in count +// +TC_Export int tc_get_snodes( int *count + , int max + , physical_node_configuration_t *pnode_config ) +TC_DIAG_UNUSED; + + +TC_Export int tc_delete_persist_keys( void ) +TC_DIAG_UNUSED; + +TC_Export int tc_get_persist_keys( const char *persist_keys ) +TC_DIAG_UNUSED; + +TC_Export int tc_put_persist_keys( const char *persist_keys ) +TC_DIAG_UNUSED; + + +TC_Export int tc_delete_persist_process( const char *persist_key_prefix ) +TC_DIAG_UNUSED; + +TC_Export int tc_get_persist_process( const char *persist_key_prefix + , persist_configuration_t *persist_config ) +TC_DIAG_UNUSED; + +TC_Export int tc_put_persist_process( const char *persist_key_prefix + , persist_configuration_t *persist_config ) +TC_DIAG_UNUSED; + + +// +// Call this to get all cluster scope configuration registry entries +// +// count: is number of registry_config array entries returned +// max: is size of the registry_config array +// registry_configuration: is the array of cluster registry entries +// +// if count would be greater than max, an error is returned +// if registry_config is null, max is ignored and +// number of registry entries is returned in count +// +TC_Export int tc_get_registry_cluster_set( int *count + , int max + , registry_configuration_t *registry_config ) +TC_DIAG_UNUSED; + +// +// Call this to get all process scope configuration registry entries +// +// count: is number of registry_config array entries returned +// max: is size of the registry_config array +// registry_configuration: is the array of process registry entries +// +// if count would be greater than max, an error is returned +// if registry_config is null, max is ignored and +// number of registry entries entries is returned in count +// +TC_Export int tc_get_registry_process_set( int *count + , int max + , registry_configuration_t *registry_config ) +TC_DIAG_UNUSED; + + +TC_Export int tc_get_registry_key( const char *key ) +TC_DIAG_UNUSED; + +TC_Export int tc_put_registry_key( const char *key ) +TC_DIAG_UNUSED; + + +TC_Export int tc_get_registry_process( const char *process_name ) +TC_DIAG_UNUSED; + +TC_Export int tc_put_registry_process( const char *process_name ) +TC_DIAG_UNUSED; + + +TC_Export int tc_get_registry_cluster_data( const char *key + , const char *data ) +TC_DIAG_UNUSED; + +TC_Export int tc_put_registry_cluster_data( const char *key + , const char *data ) +TC_DIAG_UNUSED; + + +TC_Export int tc_get_registry_process_data( const char *process_name + , const char *key + , const char *data ) +TC_DIAG_UNUSED; + +TC_Export int tc_put_registry_process_data( const char *process_name + , const char *key + , const char *data ) +TC_DIAG_UNUSED; + + +TC_Export TC_STORAGE_TYPE tc_get_storage_type( void ) +TC_DIAG_UNUSED; + + +TC_Export int tc_delete_unique_strings( int nid ) +TC_DIAG_UNUSED; + +TC_Export int tc_get_unique_string( int nid, int id, const char *unique_string ) +TC_DIAG_UNUSED; + +TC_Export int tc_put_unique_string( int nid, int id, const char *unique_string ) +TC_DIAG_UNUSED; + + +TC_Export int tc_get_unique_string_id( int nid, const char *unique_string, int *id ) +TC_DIAG_UNUSED; + +TC_Export int tc_get_unique_string_id_max( int nid, int *id ) +TC_DIAG_UNUSED; + +#endif // TRAFCONFIG_H_ http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/clusterconf.cxx ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/clusterconf.cxx b/core/sqf/monitor/linux/clusterconf.cxx deleted file mode 100644 index 205bf36..0000000 --- a/core/sqf/monitor/linux/clusterconf.cxx +++ /dev/null @@ -1,863 +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 <string.h> -#include <iostream> -#include <string> -#include <vector> -#include <mpi.h> -#include "msgdef.h" -#include "seabed/trace.h" -#include "montrace.h" -#include "monlogging.h" -#include "config.h" -#include "pnode.h" -#include "trafconfig.h" -#include "clusterconf.h" - -extern CNodeContainer *Nodes; -extern CConfigContainer *Config; - -/////////////////////////////////////////////////////////////////////////////// -// Cluster Configuration -/////////////////////////////////////////////////////////////////////////////// - -CClusterConfig::CClusterConfig( void ) - : CPNodeConfigContainer(MAX_NODES) - , CLNodeConfigContainer(MAX_LNODES) - , nodeReady_(false) - , persistReady_(false) - , newPNodeConfig_(true) - , trafConfigInitialized_(false) - , trafConfigStorageType_(TCDBSTOREUNDEFINED) - , prevPNodeConfig_(NULL) - , prevLNodeConfig_(NULL) - , prevPersistConfig_(NULL) -{ - const char method_name[] = "CClusterConfig::CClusterConfig"; - TRACE_ENTRY; - - TRACE_EXIT; -} - -CClusterConfig::~CClusterConfig ( void ) -{ - const char method_name[] = "CClusterConfig::~CClusterConfig"; - TRACE_ENTRY; - - TRACE_EXIT; -} - -void CClusterConfig::Clear( void ) -{ - const char method_name[] = "CClusterConfig::Clear"; - TRACE_ENTRY; - - // Delete the node configuration objects - CPNodeConfigContainer::Clear(); - CLNodeConfigContainer::Clear(); - CPersistConfigContainer::Clear(); - - nodeReady_ = false; - persistReady_ = false; - newPNodeConfig_ = true; - prevPNodeConfig_ = NULL; - - if ( trafConfigInitialized_ ) - { - int rc = tc_close(); - if ( rc ) - { - char la_buf[MON_STRING_BUF_SIZE]; - snprintf( la_buf, sizeof(la_buf) - , "[%s], Can't close configuration!\n" - , method_name ); - mon_log_write( MON_CLUSTERCONF_CLEAR_1, SQ_LOG_CRIT, la_buf ); - } - - trafConfigInitialized_ = false; - } - - TRACE_EXIT; -} - -void CClusterConfig::AddNodeConfiguration( pnodeConfigInfo_t &pnodeConfigInfo - , lnodeConfigInfo_t &lnodeConfigInfo ) -{ - const char method_name[] = "CClusterConfig::AddNodeConfiguration"; - TRACE_ENTRY; - - if ( trace_settings & TRACE_INIT ) - { - trace_printf( "%s@%d nid=%d, pnid=%d, nodename=%s\n" - , method_name, __LINE__ - , lnodeConfigInfo.nid - , pnodeConfigInfo.pnid - , pnodeConfigInfo.nodename ); - } - - if ( newPNodeConfig_ ) - { - prevPNodeConfig_ = CPNodeConfigContainer::AddPNodeConfig( pnodeConfigInfo ); - newPNodeConfig_ = false; - } - prevLNodeConfig_ = CLNodeConfigContainer::AddLNodeConfig( prevPNodeConfig_ - , lnodeConfigInfo ); - - TRACE_EXIT; -} - -void CClusterConfig::AddSNodeConfiguration( pnodeConfigInfo_t &pnodeConfigInfo ) -{ - const char method_name[] = "CClusterConfig::AddSNodeConfiguration"; - TRACE_ENTRY; - - if ( trace_settings & TRACE_INIT ) - { - trace_printf( "%s@%d pnid=%d, nodename=%s\n" - , method_name, __LINE__ - , pnodeConfigInfo.pnid - , pnodeConfigInfo.nodename ); - } - - if ( newPNodeConfig_ ) - { - prevPNodeConfig_ = CPNodeConfigContainer::AddPNodeConfig( pnodeConfigInfo ); - prevPNodeConfig_->SetSpareList( pnodeConfigInfo.sparePNid - , pnodeConfigInfo.spareCount ); - newPNodeConfig_ = false; - } - - TRACE_EXIT; -} - -void CClusterConfig::AddPersistConfiguration( persistConfigInfo_t &persistConfigInfo ) -{ - const char method_name[] = "CClusterConfig::AddPersistConfiguration"; - TRACE_ENTRY; - - if ( trace_settings & TRACE_INIT ) - { - trace_printf( "%s@%d persistkey=%s\n" - , method_name, __LINE__ - , persistConfigInfo.persistPrefix ); - } - - prevPersistConfig_ = CPersistConfigContainer::AddPersistConfig( persistConfigInfo ); - - TRACE_EXIT; -} - -bool CClusterConfig::DeleteNodeConfig( int pnid ) -{ - const char method_name[] = "CClusterConfig::DeleteNodeConfig"; - TRACE_ENTRY; - - bool rs = true; - int rc; - - if (trace_settings & (TRACE_INIT | TRACE_REQUEST)) - { - trace_printf( "%s@%d deleting (pnid=%d), pnodesCount=%d, lnodesCount=%d\n" - , method_name, __LINE__ - , pnid - , GetPNodesCount() - , GetLNodesCount() ); - } - - // Delete logical and physical nodes from the configuration database - - rc = tc_delete_node( pnid, NULL ); - if ( rc == 0 ) - { - // Delete logical and physical nodes from configuration objects - CPNodeConfig *pnodeConfig = GetPNodeConfig( pnid ); - if (pnodeConfig) - { - - CLNodeConfig *lnodeConfig = pnodeConfig->GetFirstLNodeConfig(); - while ( lnodeConfig ) - { - // Delete logical nodes unique strings from the configuration database - rc = tc_delete_unique_strings( lnodeConfig->GetNid() ); - if ( rc ) - { - rs = false; - break; - } - DeleteLNodeConfig( lnodeConfig ); - lnodeConfig = pnodeConfig->GetFirstLNodeConfig(); - } - - if (rs) - { - DeletePNodeConfig( pnodeConfig ); - - if (trace_settings & (TRACE_INIT | TRACE_REQUEST)) - { - trace_printf( "%s@%d deleted (pnid=%d), pnodesCount=%d, lnodesCount=%d\n" - , method_name, __LINE__ - , pnid - , GetPNodesCount() - , GetLNodesCount() ); - } - } - } - } - else - { - char buf[MON_STRING_BUF_SIZE]; - snprintf( buf, sizeof(buf), "[%s] Node delete failed, pnid=%d\n", - method_name, pnid ); - mon_log_write( MON_CLUSTERCONF_DELETENODE_1, SQ_LOG_ERR, buf ); - rs = false; - } - - TRACE_EXIT; - return( rs ); -} - -// The following method maps the 'sqconfig' text file persist section's -// <persist-key>_PROCESS_TYPE string value to the internal -// PROCESSTYPE enum value -PROCESSTYPE CClusterConfig::GetProcessType( const char *processtype ) -{ - if (strcmp( "DTM", processtype) == 0) - { - return(ProcessType_DTM); - } - else if (strcmp( "GENERIC", processtype) == 0) - { - return(ProcessType_Generic); - } - else if (strcmp( "WDG", processtype) == 0) - { - return(ProcessType_Watchdog); - } - else if (strcmp( "MXOSRVR", processtype) == 0) - { - return(ProcessType_MXOSRVR); - } - else if (strcmp( "SPX", processtype) == 0) - { - return(ProcessType_SPX); - } - else if (strcmp( "SSMP", processtype) == 0) - { - return(ProcessType_SSMP); - } - else if (strcmp( "PSD", processtype) == 0) - { - return(ProcessType_PSD); - } - else if (strcmp( "SMS", processtype) == 0) - { - return(ProcessType_SMS); - } - else if (strcmp( "TMID", processtype) == 0) - { - return(ProcessType_TMID); - } - else if (strcmp( "PERSIST", processtype) == 0) - { - return(ProcessType_PERSIST); - } - - return(ProcessType_Undefined); -} - -bool CClusterConfig::Initialize( void ) -{ - return( Initialize( NULL ) ); -} - -bool CClusterConfig::Initialize( const char *traceFile ) -{ - const char method_name[] = "CClusterConfig::Initialize"; - TRACE_ENTRY; - - if ( trafConfigInitialized_ ) - { - // Already initialized - return( true ); - } - - bool trafConfigTrace = (trace_settings & TRACE_TRAFCONFIG); - int rc = tc_initialize( trafConfigTrace, traceFile ); - if ( rc ) - { - char la_buf[MON_STRING_BUF_SIZE]; - snprintf( la_buf, sizeof(la_buf) - , "[%s], Can't initialize configuration!\n" - , method_name ); - mon_log_write( MON_CLUSTERCONF_INIT_1, SQ_LOG_CRIT, la_buf ); - return( false ); - } - - trafConfigInitialized_ = true; - trafConfigStorageType_ = tc_get_storage_type(); - - TRACE_EXIT; - return( true ); -} - -void CClusterConfig::InitCoreMask( cpu_set_t &coreMask ) -{ - CPU_ZERO( &coreMask ); -} - -bool CClusterConfig::LoadConfig( void ) -{ - const char method_name[] = "CClusterConfig::LoadConfig"; - TRACE_ENTRY; - - if ( LoadNodeConfig() ) - { - LoadPersistConfig(); - } - - TRACE_EXIT; - return( nodeReady_ && persistReady_ ); -} - -bool CClusterConfig::LoadNodeConfig( void ) -{ - const char method_name[] = "CClusterConfig::LoadNodeConfig"; - TRACE_ENTRY; - - int rc; - int nodeCount = 0; - int snodeCount = 0; - node_configuration_t nodeConfigData[TC_NODES_MAX]; - physical_node_configuration_t spareNodeConfigData[TC_SPARE_NODES_MAX]; - pnodeConfigInfo_t pnodeConfigInfo; - lnodeConfigInfo_t lnodeConfigInfo; - - rc = tc_get_nodes( &nodeCount - , TC_NODES_MAX - , nodeConfigData ); - 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_CLUSTERCONF_LOADNODE_1, SQ_LOG_CRIT, la_buf); - return( false ); - } - - // Process logical nodes - for (int i =0; i < nodeCount; i++ ) - { - ProcessLNode( nodeConfigData[i], pnodeConfigInfo, lnodeConfigInfo ); - AddNodeConfiguration( pnodeConfigInfo, lnodeConfigInfo ); - } - - rc = tc_get_snodes( &snodeCount - , TC_NODES_MAX - , spareNodeConfigData ); - 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_CLUSTERCONF_LOADNODE_2, SQ_LOG_CRIT, la_buf); - return( false ); - } - - // Process spare nodes - for (int i =0; i < snodeCount; i++ ) - { - ProcessSNode( spareNodeConfigData[i], pnodeConfigInfo ); - AddSNodeConfiguration( pnodeConfigInfo ); - } - - nodeReady_ = true; - - if ( trace_settings & TRACE_INIT ) - { - if ( nodeReady_ ) - trace_printf("%s@%d - Successfully loaded node configuration\n", method_name, __LINE__); - else - trace_printf("%s@%d - Failed to load node configuration\n", method_name, __LINE__); - } - - TRACE_EXIT; - return( nodeReady_ ); -} - -bool CClusterConfig::LoadPersistConfig( void ) -{ - const char method_name[] = "CClusterConfig::LoadPersistConfig"; - TRACE_ENTRY; - - int rc; - - // Get persistent process keys - char persistProcessKeys[TC_PERSIST_KEYS_VALUE_MAX]; - rc = tc_get_persist_keys( persistProcessKeys ); - if ( rc ) - { - char la_buf[MON_STRING_BUF_SIZE]; - snprintf( la_buf, sizeof(la_buf) - , "[%s] Persist keys configuration access failed!\n" - , method_name ); - mon_log_write(MON_CLUSTERCONF_LOADPERSIST_1, SQ_LOG_CRIT, la_buf); - return( false ); - } - - persist_configuration_t persistConfig; - persistConfigInfo_t persistConfigInfo; - pkeysVector_t pkeysVector; // vector of persist prefix strings - - // Initialize vector of persistent keys - CPersistConfigContainer::InitializePersistKeys( persistProcessKeys - , pkeysVector ); - if ( CPersistConfigContainer::GetPersistKeysCount() == 0 ) - { - char la_buf[MON_STRING_BUF_SIZE]; - snprintf( la_buf, sizeof(la_buf) - , "[%s] Invalid PERSIST_PROCESS_KEYS value, %s\n" - , method_name, persistProcessKeys ); - mon_log_write(MON_CLUSTERCONF_LOADPERSIST_2, SQ_LOG_CRIT, la_buf); - return( false ); - } - - pkeysVector_t::iterator pkit; - - // Process each prefix in the vector - for (pkit = pkeysVector.begin(); pkit < pkeysVector.end(); pkit++ ) - { - memset( &persistConfig, 0, sizeof(persist_configuration_t) ); - memset( &persistConfigInfo, 0, sizeof(persistConfigInfo_t) ); - strncpy( persistConfig.persist_prefix - , pkit->c_str() - , sizeof(persistConfig.persist_prefix)); - rc = tc_get_persist_process( pkit->c_str(), &persistConfig ); - if ( rc ) - { - char la_buf[MON_STRING_BUF_SIZE]; - snprintf( la_buf, sizeof(la_buf) - , "[%s] Persist process info for prefix key %s does not exist!\n" - , method_name, pkit->c_str() ); - mon_log_write(MON_CLUSTERCONF_LOADPERSIST_3, SQ_LOG_CRIT, la_buf); - return( false ); - } - - ProcessPersistInfo( persistConfig, persistConfigInfo ); - AddPersistConfiguration( persistConfigInfo ); - } - - persistReady_ = true; - - if ( trace_settings & TRACE_INIT ) - { - if ( persistReady_ ) - trace_printf("%s@%d - Successfully loaded persist configuration\n", method_name, __LINE__); - else - trace_printf("%s@%d - Failed to load persist configuration\n", method_name, __LINE__); - } - - TRACE_EXIT; - return( persistReady_ ); -} - -void CClusterConfig::ProcessLNode( node_configuration_t &nodeConfigData - , pnodeConfigInfo_t &pnodeConfigInfo - , lnodeConfigInfo_t &lnodeConfigInfo ) -{ - const char method_name[] = "CClusterConfig::ProcessLNode"; - TRACE_ENTRY; - - bool excludedCores = false; - - if ( trace_settings & TRACE_INIT ) - { - trace_printf( "%s@%d nid=%d, pnid=%d, name=%s, excluded cores=(%d:%d)," - " cores=(%d:%d), processors=%d, roles=%d\n" - , method_name, __LINE__ - , nodeConfigData.nid - , nodeConfigData.pnid - , nodeConfigData.node_name - , nodeConfigData.excluded_first_core - , nodeConfigData.excluded_last_core - , nodeConfigData.first_core - , nodeConfigData.last_core - , nodeConfigData.processors - , nodeConfigData.roles ); - } - - newPNodeConfig_ = ((prevPNodeConfig_ == NULL) || - (nodeConfigData.pnid != prevPNodeConfig_->GetPNid())) - ? true : false; - if ( newPNodeConfig_ ) - { - memset( &pnodeConfigInfo, 0, sizeof(pnodeConfigInfo) ); - pnodeConfigInfo.pnid = nodeConfigData.pnid; - strncpy( pnodeConfigInfo.nodename - , nodeConfigData.node_name - , sizeof(pnodeConfigInfo.nodename) ); - pnodeConfigInfo.excludedFirstCore = nodeConfigData.excluded_first_core; - pnodeConfigInfo.excludedLastCore = nodeConfigData.excluded_last_core; - excludedCores = (nodeConfigData.excluded_first_core != -1 || - nodeConfigData.excluded_last_core != -1) - ? true : false; - if ( excludedCores ) - { - SetCoreMask( nodeConfigData.excluded_first_core - , nodeConfigData.excluded_last_core - , pnodeConfigInfo.excludedCoreMask ); - } - else - { - InitCoreMask( pnodeConfigInfo.excludedCoreMask ); - } - } - - lnodeConfigInfo.nid = nodeConfigData.nid; - lnodeConfigInfo.pnid = nodeConfigData.pnid; - strncpy( lnodeConfigInfo.nodename - , nodeConfigData.node_name - , sizeof(lnodeConfigInfo.nodename) ); - lnodeConfigInfo.firstCore = nodeConfigData.first_core; - lnodeConfigInfo.lastCore = nodeConfigData.last_core; - SetCoreMask( nodeConfigData.first_core - , nodeConfigData.last_core - , lnodeConfigInfo.coreMask ); - lnodeConfigInfo.processor = nodeConfigData.processors; - lnodeConfigInfo.zoneType = (ZoneType)nodeConfigData.roles; - - TRACE_EXIT; -} - -void CClusterConfig::ProcessSNode( physical_node_configuration_t &pnodeConfig - , pnodeConfigInfo_t &pnodeConfigInfo ) -{ - const char method_name[] = "CClusterConfig::ProcessSNode"; - TRACE_ENTRY; - - if ( trace_settings & TRACE_INIT ) - { - trace_printf( "%s@%d pnid=%d, name=%s, excluded cores=(%d:%d), " - "spareCount=%d\n" - , method_name, __LINE__ - , pnodeConfig.pnid - , pnodeConfig.node_name - , pnodeConfig.excluded_first_core - , pnodeConfig.excluded_last_core - , pnodeConfig.spare_count - ); - } - - newPNodeConfig_ = (pnodeConfig.pnid != prevPNodeConfig_->GetPNid()) - ? true : false; - if ( newPNodeConfig_ ) - { - strncpy( pnodeConfigInfo.nodename - , pnodeConfig.node_name - , sizeof(pnodeConfigInfo.nodename) ); - - bool excludedCores = (pnodeConfig.excluded_first_core != -1 || - pnodeConfig.excluded_last_core != -1) - ? true : false; - if ( excludedCores ) - { - SetCoreMask( pnodeConfig.excluded_first_core - , pnodeConfig.excluded_last_core - , pnodeConfigInfo.excludedCoreMask ); - } - - memset( pnodeConfigInfo.sparePNid, 255, sizeof(pnodeConfigInfo.sparePNid) ); - - pnodeConfigInfo.spareCount = pnodeConfig.spare_count; - for (int i = 0; i < pnodeConfigInfo.spareCount ; i++ ) - { - pnodeConfigInfo.sparePNid[i] = pnodeConfig.spare_pnid[i]; - } - } - - TRACE_EXIT; -} - -void CClusterConfig::ProcessPersistInfo( persist_configuration_t &persistConfig - , persistConfigInfo_t &persistConfigInfo ) -{ - const char method_name[] = "CClusterConfig::ProcessPersistInfo"; - TRACE_ENTRY; - - char workValue[TC_PERSIST_VALUE_MAX]; - char *token1; - char *token2; - static const char *delimPercent = "%"; - static int chPercent = '%'; - - if ( trace_settings & TRACE_INIT ) - { - trace_printf( "%s@%d Processing persist info for persistKey=%s\n" - , method_name, __LINE__ - , persistConfig.persist_prefix ); - } - - strncpy( persistConfigInfo.persistPrefix - , persistConfig.persist_prefix - , sizeof(persistConfigInfo.persistPrefix) ); - - strncpy( workValue, persistConfig.process_name, sizeof(workValue) ); - if (strlen(workValue)) - { - // Extract name prefix - token1 = strtok( workValue, delimPercent ); - if (token1) - { - strncpy( persistConfigInfo.processNamePrefix - , token1 - , sizeof(persistConfigInfo.processNamePrefix) ); - } - // Extract nid format - strncpy( workValue, persistConfig.process_name, sizeof(workValue) ); - token2 = strchr( workValue, chPercent ); - if (token2) - { - strncpy( persistConfigInfo.processNameFormat - , token2 - , sizeof(persistConfigInfo.processNameFormat) ); - } - } - - persistConfigInfo.processType = GetProcessType( persistConfig.process_type ); - - strncpy( persistConfigInfo.programName - , persistConfig.program_name - , sizeof(persistConfigInfo.programName) ); - - strncpy( persistConfigInfo.programArgs - , persistConfig.program_args - , sizeof(persistConfigInfo.programArgs) ); - - persistConfigInfo.requiresDTM = persistConfig.requires_DTM; - - strncpy( workValue, persistConfig.std_out, sizeof(workValue) ); - if (strlen(workValue)) - { - // Extract name prefix - token1 = strtok( workValue, delimPercent ); - if (token1) - { - strncpy( persistConfigInfo.stdoutPrefix - , token1 - , sizeof(persistConfigInfo.stdoutPrefix) ); - } - // Extract nid format - strncpy( workValue, persistConfig.std_out, sizeof(workValue) ); - token2 = strchr( workValue, chPercent ); - if (token2) - { - strncpy( persistConfigInfo.stdoutFormat - , token2 - , sizeof(persistConfigInfo.stdoutFormat) ); - } - } - - persistConfigInfo.persistRetries = persistConfig.persist_retries; - - persistConfigInfo.persistWindow = persistConfig.persist_window; - - strncpy( persistConfigInfo.zoneFormat - , persistConfig.persist_zones - , sizeof(persistConfigInfo.zoneFormat) ); - - TRACE_EXIT; -} - -bool CClusterConfig::SaveNodeConfig( const char *name - , int nid - , int pnid - , int firstCore - , int lastCore - , int processors - , int excludedFirstCore - , int excludedLastCore - , int roles ) -{ - const char method_name[] = "CClusterConfig::SaveNodeConfig"; - TRACE_ENTRY; - - bool rs = true; - int rc; - node_configuration_t nodeConfig; - pnodeConfigInfo_t pnodeConfigInfo; - lnodeConfigInfo_t lnodeConfigInfo; - - if (trace_settings & (TRACE_INIT | TRACE_REQUEST)) - { - trace_printf( "%s@%d Saving node config (node_name=%s, processors=%d, " - "roles=%d, firstCore=%d, lastCore=%d " - "excludedFirstCore=%d, excludedLastCore=%d)\n" - , method_name, __LINE__ - , name - , processors - , roles - , firstCore - , lastCore - , excludedFirstCore - , excludedLastCore ); - } - - nodeConfig.nid = nid; - nodeConfig.pnid = pnid; - strncpy( nodeConfig.node_name, name, sizeof(nodeConfig.node_name) ); - nodeConfig.excluded_first_core = excludedFirstCore; - nodeConfig.excluded_last_core = excludedLastCore; - nodeConfig.first_core = firstCore; - nodeConfig.last_core = lastCore; - nodeConfig.processors = processors; - nodeConfig.roles = roles; - - // Insert data into pnode and lnode tables - rc = tc_put_node( &nodeConfig ); - if ( rc == 0 ) - { - ProcessLNode( nodeConfig, pnodeConfigInfo, lnodeConfigInfo ); - // Add new logical and physical nodes to configuration objects - AddNodeConfiguration( pnodeConfigInfo, lnodeConfigInfo ); - } - else - { - rs = false; - char buf[MON_STRING_BUF_SIZE]; - snprintf( buf, sizeof(buf), "[%s] Node add failed, pnid=%d\n", - method_name, pnid ); - mon_log_write( MON_CLUSTERCONF_SAVENODE_1, SQ_LOG_ERR, buf ); - } - - TRACE_EXIT; - return( rs ); -} - -void CClusterConfig::SetCoreMask( int firstCore - , int lastCore - , cpu_set_t &coreMask ) -{ - CPU_ZERO( &coreMask ); - for (int i = firstCore; i < (lastCore+1) ; i++ ) - { - CPU_SET( i, &coreMask ); - } -} - -bool CClusterConfig::UpdatePNodeConfig( int pnid - , const char *name - , int excludedFirstCore - , int excludedLastCore ) -{ - const char method_name[] = "CClusterConfig::UpdatePNodeConfig"; - TRACE_ENTRY; - - bool rs = true; - int rc; - physical_node_configuration_t pnodeConfig; - - if (trace_settings & (TRACE_INIT | TRACE_REQUEST)) - { - trace_printf( "%s@%d Updating pnode config " - "(pnid=%d, node_name=%s, " - "excludedFirstCore=%d, excludedLastCore=%d)\n" - , method_name, __LINE__ - , pnid - , name - , excludedFirstCore - , excludedLastCore ); - } - - memset( &pnodeConfig, 0, sizeof(physical_node_configuration_t) ); - pnodeConfig.pnid = pnid; - strncpy( pnodeConfig.node_name, name, sizeof(pnodeConfig.node_name) ); - pnodeConfig.excluded_first_core = excludedFirstCore; - pnodeConfig.excluded_last_core = excludedLastCore; - - // Update pnode table - rc = tc_put_pnode( &pnodeConfig ); - if ( rc == 0 ) - { - // Update physical node to configuration object - UpdatePNodeConfiguration( pnid - , name - , excludedFirstCore - , excludedLastCore ); - } - else - { - rs = false; - char buf[MON_STRING_BUF_SIZE]; - snprintf( buf, sizeof(buf) - , "[%s] PNode update failed, pnid=%d, node_name=%s\n" - , method_name, pnid, name ); - mon_log_write( MON_CLUSTERCONF_UPDATEPNODECFG_1, SQ_LOG_ERR, buf ); - } - - TRACE_EXIT; - return( rs ); -} - -void CClusterConfig::UpdatePNodeConfiguration( int pnid - , const char *name - , int excludedFirstCore - , int excludedLastCore ) -{ - const char method_name[] = "CClusterConfig::UpdatePNodeConfiguration"; - TRACE_ENTRY; - - if (trace_settings & (TRACE_INIT | TRACE_REQUEST)) - { - trace_printf( "%s@%d pnid=%d, name=%s, " - "excludedFirstCore=%d, excludedLastCore=%d\n" - , method_name, __LINE__ - , pnid - , name - , excludedFirstCore - , excludedLastCore ); - } - - CPNodeConfig *pnodeConfig = GetPNodeConfig( pnid ); - if ( pnodeConfig ) - { - pnodeConfig->SetName( name ); - pnodeConfig->SetExcludedFirstCore( excludedFirstCore ); - pnodeConfig->SetExcludedLastCore( excludedLastCore ); - } - - TRACE_EXIT; -} - http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/clusterconf.h ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/clusterconf.h b/core/sqf/monitor/linux/clusterconf.h deleted file mode 100644 index d9a1b79..0000000 --- a/core/sqf/monitor/linux/clusterconf.h +++ /dev/null @@ -1,118 +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 CLUSTERCONF_H_ -#define CLUSTERCONF_H_ - -#include <stdlib.h> - -#include "lnodeconfig.h" -#include "pnodeconfig.h" -#include "persistconfig.h" - -class CClusterConfig : public CPNodeConfigContainer - , public CLNodeConfigContainer - , public CPersistConfigContainer -{ -public: - - CClusterConfig( void ); - ~CClusterConfig( void ); - - void Clear( void ); - bool DeleteNodeConfig( int pnid ); - bool Initialize( void ); - bool Initialize( const char *traceFile ); - void InitCoreMask( cpu_set_t &coreMask ); - inline bool IsConfigReady( void ) { return( nodeReady_ && persistReady_ ); } - inline bool IsNodeReady( void ) { return( nodeReady_ ); } - inline bool IsPersistReady( void ) { return( persistReady_ ); } - inline TC_STORAGE_TYPE GetStorageType( void ) { return(trafConfigStorageType_); } - bool LoadConfig( void ); - bool LoadNodeConfig( void ); - bool LoadPersistConfig( void ); - bool SaveNodeConfig( const char *name - , int nid - , int pnid - , int firstCore - , int lastCore - , int processors - , int excludedFirstCore - , int excludedLastCore - , int roles ); - void SetCoreMask( int firstCore - , int lastCore - , cpu_set_t &coreMask ); - bool UpdatePNodeConfig( int pnid - , const char *name - , int excludedFirstCore - , int excludedLastCore ); - -protected: -private: - - bool nodeReady_; // true when node configuration loaded - bool persistReady_; // true when persist configuration loaded - bool newPNodeConfig_; - bool trafConfigInitialized_; - TC_STORAGE_TYPE trafConfigStorageType_; - CPNodeConfig *prevPNodeConfig_; - CLNodeConfig *prevLNodeConfig_; - CPersistConfig *prevPersistConfig_; - - void AddNodeConfiguration( pnodeConfigInfo_t &pnodeConfigInfo - , lnodeConfigInfo_t &lnodeConfigInfo ); - void AddSNodeConfiguration( pnodeConfigInfo_t &pnodeConfigInfo ); - void AddPersistConfiguration( persistConfigInfo_t &persistConfigInfo ); - bool DeleteDbNodeData( int pnid ); - PROCESSTYPE GetProcessType( const char *processtype ); - void ProcessLNode( node_configuration_t &nodeConfig - , pnodeConfigInfo_t &pnodeConfigInfo - , lnodeConfigInfo_t &lnodeConfigInfo ); - void ProcessSNode( physical_node_configuration_t &pnodeConfig - , pnodeConfigInfo_t &pnodeConfigInfo ); - void ProcessPersistInfo( persist_configuration_t &persistConfigData - , persistConfigInfo_t &persistConfigInfo ); - bool SaveDbLNodeData( int nid - , int pnid - , int firstCore - , int lastCore - , int processors - , int roles ); - bool SaveDbPNodeData( const char *name - , int pnid - , int excludedFirstCore - , int excludedLastCore ); - bool UpdateDbPNodeData( int pnid - , const char *name - , int excludedFirstCore - , int excludedLastCore ); - void UpdatePNodeConfiguration( int pnid - , const char *name - , int excludedFirstCore - , int excludedLastCore ); -}; - -#endif /* CLUSTERCONF_H_ */ http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/getseq.cxx ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/getseq.cxx b/core/sqf/monitor/linux/getseq.cxx index 5f8f5f3..d4bc0b5 100644 --- a/core/sqf/monitor/linux/getseq.cxx +++ b/core/sqf/monitor/linux/getseq.cxx @@ -420,8 +420,6 @@ void InitLocalIO( void ) int main (int argc, char *argv[]) { - int i; - int key = 413675219; //413675218 to display banner MPI_Initialized(&key); http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/lnode.h ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/lnode.h b/core/sqf/monitor/linux/lnode.h index 6b1dba7..c5e3c8d 100644 --- a/core/sqf/monitor/linux/lnode.h +++ b/core/sqf/monitor/linux/lnode.h @@ -26,6 +26,7 @@ #ifndef LNODE_H_ #define LNODE_H_ +#include "clusterconf.h" #include "process.h" class CLNodeContainer; http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/lnodeconfig.cxx ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/lnodeconfig.cxx b/core/sqf/monitor/linux/lnodeconfig.cxx deleted file mode 100644 index 77c2360..0000000 --- a/core/sqf/monitor/linux/lnodeconfig.cxx +++ /dev/null @@ -1,399 +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" -#include "lnodeconfig.h" - - -/////////////////////////////////////////////////////////////////////////////// -// Logical Node Configuration -/////////////////////////////////////////////////////////////////////////////// - -CLNodeConfig::CLNodeConfig( CPNodeConfig *pnodeConfig - , lnodeConfigInfo_t &lnodeConfigInfo - ) - : nid_(lnodeConfigInfo.nid) - , zid_(pnodeConfig->GetPNid()) - , coreMask_(lnodeConfigInfo.coreMask) - , firstCore_(lnodeConfigInfo.firstCore) - , lastCore_(lnodeConfigInfo.lastCore) - , processors_(lnodeConfigInfo.processor) - , zoneType_(lnodeConfigInfo.zoneType) - , pnodeConfig_(pnodeConfig) - , next_(NULL) - , prev_(NULL) - , nextP_(NULL) - , prevP_(NULL) -{ - const char method_name[] = "CLNodeConfig::CLNodeConfig"; - TRACE_ENTRY; - - pnodeConfig_->AddLNodeConfigP( this ); - - TRACE_EXIT; -} - -CLNodeConfig::~CLNodeConfig( void ) -{ - const char method_name[] = "CLNodeConfig::~CLNodeConfig"; - TRACE_ENTRY; - - pnodeConfig_->RemoveLNodeConfigP( this ); - - TRACE_EXIT; -} - -const char *CLNodeConfig::GetName( void ) -{ - return( pnodeConfig_->GetName() ); -} - -int CLNodeConfig::GetPNid( void ) -{ - return( pnodeConfig_->GetPNid() ); -} - -CLNodeConfigContainer::CLNodeConfigContainer( void ) - : lnodesCount_(0) - , nextNid_(-1) - , lnodesConfigMax_(0) - , lnodesConfig_(NULL) - , head_(NULL) - , tail_(NULL) -{ - const char method_name[] = "CLNodeConfigContainer::CLNodeConfigContainer"; - TRACE_ENTRY; - - TRACE_EXIT; -} - -CLNodeConfigContainer::CLNodeConfigContainer( int lnodesConfigMax ) - : lnodesCount_(0) - , nextNid_(0) - , lnodesConfigMax_(lnodesConfigMax) - , lnodesConfig_(NULL) - , head_(NULL) - , tail_(NULL) -{ - const char method_name[] = "CLNodeConfigContainer::CLNodeConfigContainer"; - TRACE_ENTRY; - - lnodesConfig_ = new CLNodeConfig *[lnodesConfigMax_]; - - if ( ! lnodesConfig_ ) - { - int err = errno; - char la_buf[MON_STRING_BUF_SIZE]; - sprintf(la_buf, "[%s], Error: Can't allocate logical node configuration array - errno=%d (%s)\n", method_name, err, strerror(errno)); - mon_log_write(MON_LNODECONF_CONSTR_1, SQ_LOG_CRIT, la_buf); - } - else - { - // Initialize array - for ( int i = 0; i < lnodesConfigMax_ ;i++ ) - { - lnodesConfig_[i] = NULL; - } - } - - TRACE_EXIT; -} - -CLNodeConfigContainer::~CLNodeConfigContainer(void) -{ - CLNodeConfig *lnodeConfig = head_; - - const char method_name[] = "CLNodeConfigContainer::~CLNodeConfigContainer"; - TRACE_ENTRY; - - // Only the main container builds the array of - // logical node configuration objects. - // The logical nodes container in a physical node configuration object - // only stores the configured logical nodes it hosts. - if ( lnodesConfig_ ) - { // This is the main container - // Delete entries - while ( head_ ) - { - DeleteLNodeConfig( lnodeConfig ); - lnodeConfig = head_; - } - - // Delete array - delete [] lnodesConfig_; - } - - TRACE_EXIT; -} - -void CLNodeConfigContainer::Clear( void ) -{ - const char method_name[] = "CLNodeConfigContainer::Clear"; - TRACE_ENTRY; - - CLNodeConfig *lnodeConfig = head_; - - // Only the main container builds the array of - // logical node configuration objects. - // The logical nodes container in a physical node configuration object - // only stores the configured logical nodes it hosts. - if ( lnodesConfig_ ) - { - while ( head_ ) - { - DeleteLNodeConfig( lnodeConfig ); - lnodeConfig = head_; - } - - // Initialize array - for ( int i = 0; i < lnodesConfigMax_; i++ ) - { - lnodesConfig_[i] = NULL; - } - } - - lnodesCount_ = 0; - nextNid_ = 0; - head_ = NULL; - tail_ = NULL; - - TRACE_EXIT; -} - -CLNodeConfig *CLNodeConfigContainer::AddLNodeConfigP( CLNodeConfig *lnodeConfig ) -{ - const char method_name[] = "CLNodeConfigContainer::AddLNodeConfig"; - TRACE_ENTRY; - - assert( lnodeConfig != NULL ); - - if ( lnodeConfig ) - { - lnodesCount_++; - // Add it to the container list - if ( head_ == NULL ) - { - head_ = tail_ = lnodeConfig; - } - else - { - //tail_ = tail_->LinkP( entry ); - tail_->nextP_ = lnodeConfig; - lnodeConfig->prevP_ = tail_; - tail_ = lnodeConfig; - } - } - - TRACE_EXIT; - return( lnodeConfig ); -} - -CLNodeConfig *CLNodeConfigContainer::AddLNodeConfig( CPNodeConfig *pnodeConfig - , lnodeConfigInfo_t &lnodeConfigInfo - ) -{ - const char method_name[] = "CLNodeConfigContainer::AddLNodeConfig"; - TRACE_ENTRY; - - // nid list is NOT sequential from zero - 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, lnodeConfigInfo.nid, lnodesConfigMax_); - mon_log_write(MON_LNODECONF_ADD_LNODE_1, SQ_LOG_CRIT, la_buf); - return( NULL ); - } - - assert( lnodesConfig_[lnodeConfigInfo.nid] == NULL ); - - CLNodeConfig *lnodeConfig = new CLNodeConfig( pnodeConfig - , lnodeConfigInfo ); - if (lnodeConfig) - { - // Bump the logical node count - lnodesCount_++; - // Add it to the array - lnodesConfig_[lnodeConfigInfo.nid] = lnodeConfig; - // Add it to the container list - if ( head_ == NULL ) - { - head_ = tail_ = lnodeConfig; - } - else - { - tail_->next_ = lnodeConfig; - lnodeConfig->prev_ = tail_; - tail_ = lnodeConfig; - } - - // Set the next available nid - nextNid_ = (lnodeConfigInfo.nid == nextNid_) ? (lnodeConfigInfo.nid+1) : nextNid_ ; - if ( nextNid_ == lnodesConfigMax_ ) - { // We are at the limit, search for unused nid from begining - nextNid_ = -1; - for (int i = 0; i < lnodesConfigMax_; i++ ) - { - if ( lnodesConfig_[i] == NULL ) - { - nextNid_ = i; - break; - } - } - } - else if ( lnodesConfig_[nextNid_] != NULL ) - { // nid is in use - int next = ((nextNid_ + 1) < lnodesConfigMax_) ? nextNid_ + 1 : 0 ; - nextNid_ = -1; - for (int i = next; i < lnodesConfigMax_; i++ ) - { - if ( lnodesConfig_[i] == NULL ) - { - nextNid_ = i; - break; - } - } - } - - if (trace_settings & (TRACE_INIT | TRACE_REQUEST)) - { - trace_printf( "%s@%d - Added logical node configuration object\n" - " (nid=%d, pnid=%d, nextNid_=%d)\n" - " (lnodesCount_=%d,lnodesConfigMax=%d)\n" - , method_name, __LINE__ - , lnodeConfigInfo.nid, pnodeConfig->GetPNid(), nextNid_ - , lnodesCount_, lnodesConfigMax_); - } - } - else - { - 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)); - mon_log_write(MON_LNODECONF_ADD_LNODE_2, SQ_LOG_ERR, la_buf); - } - - TRACE_EXIT; - return( lnodeConfig ); -} - -void CLNodeConfigContainer::DeleteLNodeConfig( CLNodeConfig *lnodeConfig ) -{ - const char method_name[] = "CLNodeConfigContainer::DeleteLNodeConfig"; - TRACE_ENTRY; - - if (trace_settings & (TRACE_INIT | TRACE_REQUEST)) - { - trace_printf( "%s@%d Deleting nid=%d, nextNid_=%d\n" - , method_name, __LINE__ - , lnodeConfig->GetNid() - , nextNid_ ); - } - - int nid = lnodeConfig->GetNid(); - lnodesConfig_[nid] = NULL; - - if ( head_ == lnodeConfig ) - head_ = lnodeConfig->next_; - if ( tail_ == lnodeConfig ) - tail_ = lnodeConfig->prev_; - if ( lnodeConfig->prev_ ) - lnodeConfig->prev_->next_ = lnodeConfig->next_; - if ( lnodeConfig->next_ ) - lnodeConfig->next_->prev_ = lnodeConfig->prev_; - delete lnodeConfig; - - // Decrement the logical node count - lnodesCount_--; - - if ( nextNid_ == -1 ) - { // We are at the limit, use the deleted nid as the next available - nextNid_ = nid; - } - else if ( nextNid_ > nid ) - { // Always use the lower nid value - nextNid_ = nid; - } - - if (trace_settings & (TRACE_INIT | TRACE_REQUEST)) - { - trace_printf( "%s@%d - Deleted logical node configuration object\n" - " (nid=%d, nextNid_=%d)\n" - " (lnodesCount_=%d,lnodesConfigMax=%d)\n" - , method_name, __LINE__ - , nid, nextNid_ - , lnodesCount_, lnodesConfigMax_); - } - - TRACE_EXIT; -} - -CLNodeConfig *CLNodeConfigContainer::GetLNodeConfig( int nid ) -{ - const char method_name[] = "CLNodeConfigContainer::GetLNodeConfig"; - TRACE_ENTRY; - - CLNodeConfig *config = head_; - while (config) - { - if ( config->GetNid() == nid ) - { - break; - } - config = config->GetNext(); - } - - TRACE_EXIT; - return config; -} - -void CLNodeConfigContainer::RemoveLNodeConfigP( CLNodeConfig *lnodeConfig ) -{ - - if ( head_ == lnodeConfig ) - head_ = lnodeConfig->nextP_; - if ( tail_ == lnodeConfig ) - tail_ = lnodeConfig->prevP_; - if ( lnodeConfig->prevP_ ) - lnodeConfig->prevP_->nextP_ = lnodeConfig->nextP_; - if ( lnodeConfig->nextP_ ) - lnodeConfig->nextP_->prevP_ = lnodeConfig->prevP_; -} http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/lnodeconfig.h ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/lnodeconfig.h b/core/sqf/monitor/linux/lnodeconfig.h deleted file mode 100644 index e32c08f..0000000 --- a/core/sqf/monitor/linux/lnodeconfig.h +++ /dev/null @@ -1,119 +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 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; - -class CLNodeConfigContainer -{ -public: - CLNodeConfigContainer( void ); - CLNodeConfigContainer( int lnodesConfigMax ); - ~CLNodeConfigContainer( void ); - CLNodeConfig *AddLNodeConfig( CPNodeConfig *pnodeConfig - , lnodeConfigInfo_t &lnodeConfigInfo ); - CLNodeConfig *AddLNodeConfigP( CLNodeConfig *lnodeConfig ); - void Clear( void ); - void DeleteLNodeConfig( CLNodeConfig *lnodeConfig ); - void RemoveLNodeConfigP( CLNodeConfig *lnodeConfig ); - inline CLNodeConfig *GetFirstLNodeConfig( void ) { return ( head_ ); } - inline int GetNextNid( void ) { return ( nextNid_ ); } - CLNodeConfig *GetLNodeConfig( int nid ); - inline int GetLNodesConfigMax( void ) { return ( lnodesConfigMax_ ); } - inline int GetLNodesCount( void ) { return ( lnodesCount_ ); } - -protected: - int lnodesCount_; // # of logical nodes - int nextNid_; // next logical node id available - -private: - int lnodesConfigMax_; // maximum number of logical nodes - CLNodeConfig **lnodesConfig_; // array of all logical nodes - - CLNodeConfig *head_; // head of logical nodes linked list - CLNodeConfig *tail_; // tail of logical nodes linked list -}; - -class CLNodeConfig -{ - friend CLNodeConfig *CLNodeConfigContainer::AddLNodeConfig( CPNodeConfig *pnodeConfig - , 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 - , lnodeConfigInfo_t &lnodeConfigInfo - ); - ~CLNodeConfig( void ); - - inline cpu_set_t &GetCoreMask( void ) { return( coreMask_ ); } - inline int GetFirstCore( void ) { return( firstCore_ ); } - inline int GetLastCore( void ) { return( lastCore_ ); } - const char *GetName( void ); - inline CLNodeConfig *GetNext( void ) { return( next_); } - inline CLNodeConfig *GetNextP( void ) { return( nextP_); } - inline int GetNid( void ) { return( nid_ ); } - inline int GetZid( void ) { return( zid_ ); } - int GetPNid( void ); - CPNodeConfig *GetPNodeConfig( void ) { return(pnodeConfig_); } - - inline int GetProcessors( void ) { return( processors_ ); } - inline ZoneType GetZoneType( void ) { return( zoneType_ ); } - -protected: -private: - int nid_; // Logical Node Identifier - int zid_; // Zone Identifier - cpu_set_t coreMask_; // mask of SMP processor cores used by logical node - int firstCore_; // First SMP processor core used by logical node - int lastCore_; // Last SMP processor core used by logical node - int processors_; // # of logical processors in logical node - ZoneType zoneType_; // type of zone - CPNodeConfig *pnodeConfig_; // logical node's current physical node - - CLNodeConfig *next_; // next LNodeConfig in CLNodeConfigContainer list - CLNodeConfig *prev_; // previous LNodeConfig in CLNodeConfigContainer list - CLNodeConfig *nextP_; // next LNodeConfig in pnodeConfig_ linked list - CLNodeConfig *prevP_; // prev LNodeConfig in pnodeConfig_ linked list -}; - -#endif /* LNODECONFIG_H_ */ http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/macros.gmk ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/macros.gmk b/core/sqf/monitor/linux/macros.gmk index 5bb24ec..ea981e0 100644 --- a/core/sqf/monitor/linux/macros.gmk +++ b/core/sqf/monitor/linux/macros.gmk @@ -37,6 +37,14 @@ ifndef SQ_MTYPE SQ_MTYPE = 32 endif +# Trafodion Configuration +SRCTCDIR = ../../src/trafconf + +# Seabed +SRCSBDIR = ../../src/seabed/src + +INCMISCDIR += -I$(SRCTCDIR) -I$(SRCSBDIR) + TOOLBASE := $(shell echo `pwd` | sed -e 's|/src\/.*||') DEPTOOL := $(TOOLBASE)/tools/make/deptool DEPFLAGS = $(DEFINES) $(INCLUDES) -f $(DEPFILE) @@ -75,3 +83,5 @@ CXXFLAGS = $(CXXWARN) $(DBG_FLGS) $(OPTIM_FLGS) CWARN = -Wno-long-long -fmessage-length=0 CXXWARN = -Wno-long-long -Wno-deprecated -fmessage-length=0 + +INCLUDES = -I$(INCEXPDIR) $(INCMISCDIR) http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/makefile ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/makefile b/core/sqf/monitor/linux/makefile index 8f77157..95718ff 100644 --- a/core/sqf/monitor/linux/makefile +++ b/core/sqf/monitor/linux/makefile @@ -49,7 +49,6 @@ 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 -fPIC -SBDIR = ../../src/seabed/src COMMONLOGGERDIR = ../../commonLogger @@ -72,11 +71,10 @@ ifeq ($(SQ_BUILD_TYPE), debug) FLAGS+= -DMON_DEBUG endif -INCLUDES = -I$(INCEXPDIR) - ifeq ($(USE_DMALLOC),1) INCLUDES+= -I$(DMALLOCROOT) endif + INCLUDES+= -I../../inc INCLUDES+= -I../../commonLogger INCLUDES+= -I$(LOG4CXX_INC_DIR) @@ -109,10 +107,6 @@ MONITORSRC += montrace.cxx MONITORSRC += monsonar.cxx MONITORSRC += redirector.cxx MONITORSRC += lock.cxx -MONITORSRC += clusterconf.cxx -MONITORSRC += lnodeconfig.cxx -MONITORSRC += pnodeconfig.cxx -MONITORSRC += persistconfig.cxx MONITORSRC += lnode.cxx MONITORSRC += pnode.cxx MONITORSRC += intprocess.cxx @@ -280,6 +274,7 @@ ZOOMONOBJS += $(OUTDIR)/zclient.o ZOOMONOBJS += $(OUTDIR)/lock.o ZOOMONOBJS += $(OUTDIR)/montrace.o ZOOMONOBJS += $(OUTDIR)/CommonLogger.o +ZOOMONOBJS += $(OUTDIR)/type2str.o MSG_LOG_OBJS = $(OUTDIR)/monlogging.o @@ -296,33 +291,6 @@ 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 - -TCDB_SRC = tcdb.cxx -TCDB_OBJS = $(OUTDIR)/tcdb.o - -TCDBSQLITE_SRC = tcdbsqlite.cxx -TCDBSQLITE_OBJS = $(OUTDIR)/tcdbsqlite.o - -TCDBSTORE_SRC = tcdbstore.cxx -TCDBSTORE_OBJS = $(OUTDIR)/tcdbstore.o - -TCDBZSTORE_SRC = tcdbzstore.cxx -TCDBZSTORE_OBJS = $(OUTDIR)/tcdbzstore.o - -TCLOG_SRC = tclog.cxx -TCLOG_OBJS = $(OUTDIR)/tclog.o - -TCTRACE_SRC = tctrace.cxx -TCTRACE_OBJS = $(OUTDIR)/tctrace.o - -TRAFCONFIG_SRC = trafconfig.cxx -TRAFCONFIG_OBJS = $(OUTDIR)/trafconfig.o - TYPE2STR_SRC = type2str.cxx TYPE2STR_OBJS = $(OUTDIR)/type2str.o @@ -338,14 +306,6 @@ ALLOBJS += $(CONFOBJS) ALLOBJS += $(MEMLOGOBJS) ALLOBJS += $(RTSIGBLOCK_OBJS) ALLOBJS += $(ZOOMONOBJS) -ALLOBJS += $(TRAFCONFOBJS) -ALLOBJS += $(TCDB_OBJS) -ALLOBJS += $(TCDBSQLITE_OBJS) -ALLOBJS += $(TCDBSTORE_OBJS) -#ALLOBJS += $(TCDBZSTORE_OBJS) -ALLOBJS += $(TCLOG_OBJS) -ALLOBJS += $(TCTRACE_OBJS) -ALLOBJS += $(TRAFCONFIG_OBJS) ALLOBJS += $(TYPE2STR_OBJS) SHAREDLIBS = $(LIBEXPDIR)/libtrafconfig.so @@ -372,19 +332,8 @@ TEST_PGMS += $(OUTDIR)/testspx TEST_PGMS += $(OUTDIR)/testconf TEST_PGMS += $(OUTDIR)/zootest -# $(OUTDIR)/attach \ -# $(OUTDIR)/testenv \ - # Compile rules for building sources -#$(OUTDIR)/%:%.cxx $(INCLUDE) -# @echo 'Building target: $@' -# @echo 'Invoking: C++ Compile & Linker' -# @echo $(CXX) $(CDEPFLAGS) $(FLAGS) $(OPTIONS) $(INCLUDES) -o $@ -lrt $(OUTDIR)/clio.o $(OUTDIR)/props.o $< -# @$(CXX) $(CDEPFLAGS) $(FLAGS) $(OPTIONS) $(INCLUDES) -o $@ -lrt $(OUTDIR)/clio.o $(OUTDIR)/props.o $< -# @echo 'Finished building target: $@' -# @echo ' ' - $(BINEXPDIR)/%:%.cxx $(INCLUDE) $(CLIENTOBJS) @echo 'Building target: $@' @echo 'Invoking: C++ Compile & Linker' @@ -420,11 +369,20 @@ $(OUTDIR)/%.o:%.cc @echo ' ' # For compiling Seabed trace modules -$(OUTDIR)/%.o:$(SBDIR)/%.cpp $(INCLUDE) +$(OUTDIR)/%.o:$(SRCSBDIR)/%.cpp $(INCLUDE) + @echo 'Building target: $@' + @echo 'Invoking: C++ Compiler' + @echo $(CXX) $(SBFLAGS) $(INCLUDES) -c -o $@ $< + @$(CXX) $(SBFLAGS) $(INCLUDES) -c -o $@ $< + @echo 'Finished building target: $@' + @echo ' ' + +# For compiling Trafodion Configuration modules +$(OUTDIR)/%.o:$(SRCTCDIR)/%.cpp @echo 'Building target: $@' @echo 'Invoking: C++ Compiler' - @echo $(CXX) $(SBFLAGS) -I$(INCEXPDIR) -I$(SBDIR) -c -o $@ $< - @$(CXX) $(SBFLAGS) -I../../export/include -I../../src/seabed/src -c -o $@ $< + @echo $(CXX) $(SBFLAGS) $(INCLUDES) -c -o $@ $< + @$(CXX) $(SBFLAGS) $(INCLUDES) -c -o $@ $< @echo 'Finished building target: $@' @echo ' ' @@ -439,7 +397,7 @@ $(OUTDIR)/%.o:$(COMMONLOGGERDIR)/%.cpp $(INCLUDE) # Targets # Uncomment the following target to disable parallel make -.NOTPARALLEL: +#.NOTPARALLEL: all: programs examples @@ -468,10 +426,6 @@ $(OUTDIR)/notify : notify.cxx $(CLIENTOBJS) $(TRACE_LOG_OBJS) $(OUTDIR)/testtm : testtm.cxx $(CLIENTOBJS) $(TRACE_LOG_OBJS) -#$(OUTDIR)/attach : attach.cxx $(OUTDIR)/clio.o - -#$(OUTDIR)/testenv : testenv.cxx - $(OUTDIR)/pingpong2 : pingpong2.cxx $(CLIENTOBJS) $(TRACE_LOG_OBJS) $(OUTDIR)/testconf : $(CONFOBJS) $(TRACE_LOG_OBJS) @@ -482,14 +436,6 @@ $(OUTDIR)/testconf : $(CONFOBJS) $(TRACE_LOG_OBJS) @echo 'Finished building target: $@' @echo ' ' -$(BINEXPDIR)/trafconf : $(TRAFCONFOBJS) $(TRACE_LOG_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: Linker' - @echo $(CXX) $(CDEPFLAGS) $(FLAGS) $(OPTIONS) $(INCLUDES) -o $@ -lrt $^ - @$(CXX) $(CDEPFLAGS) $(FLAGS) $(OPTIONS) $(INCLUDES) -o $@ -lrt $(LIBS) $^ - @echo 'Finished building target: $@' - @echo ' ' - $(OUTDIR)/zootest : $(ZOOMONOBJS) $(TRACE_LOG_OBJS) $(MSG_LOG_OBJS) @echo 'Building target: $@' @echo 'Invoking: C++ Compile & Linker' @@ -522,7 +468,7 @@ $(BINEXPDIR)/pstartd: $(PSTARTDOBJS) $(OUTDIR)/monclio.o $(TRACE_LOG_OBJS) @echo 'Finished building target: $@' @echo ' ' -$(BINEXPDIR)/monmemlog : $(MEMLOGOBJS) +$(BINEXPDIR)/monmemlog : $(MEMLOGOBJS) $(TRACE_LOG_OBJS) @echo 'Building target: $@' @echo 'Invoking: C++ Compile & Linker' @echo $(CXX) $(FLAGS) -pthread $(OPTIONS) $(INCLUDES) -o $@ $(LIBS) $^ @@ -549,23 +495,6 @@ $(LIBEXPDIR)/libseabasesig.so: $(RTSIGBLOCK_OBJS) @echo 'Finished building target: $@' @echo ' ' -#$(LIBEXPDIR)/libtrafconfig.so: $(TRAFCONFIG_OBJS) $(TCDB_OBJS) $(TCDBSTORE_OBJS) $(TCDBSQLITE_OBJS) $(TCDBZSTORE_OBJS) $(TRACE_LOG_OBJS) $(TCLOG_OBJS) $(TCTRACE_OBJS) $(TYPE2STR_OBJS) -# @echo 'Building target: $@' -# @echo 'Invoking: Linker' -# @echo $(CXX) $(LNK_FLGS) -shared -o $@ $(TRAFCONFIG_OBJS) $(TCDB_OBJS) $(TCDBSTORE_OBJS) $(TCDBSQLITE_OBJS) $(TCDBZSTORE_OBJS) $(TRACE_LOG_OBJS) $(TCLOG_OBJS) $(TCTRACE_OBJS) $(TYPE2STR_OBJS) -# @$(CXX) $(LNK_FLGS) -shared -o $@ $(TRAFCONFIG_OBJS) $(TCDB_OBJS) $(TCDBSTORE_OBJS) $(TCDBSQLITE_OBJS) $(TCDBZSTORE_OBJS) $(TRACE_LOG_OBJS) $(TCLOG_OBJS) $(TCTRACE_OBJS) $(TYPE2STR_OBJS) -# @echo 'Finished building target: $@' -# @echo ' ' - -$(LIBEXPDIR)/libtrafconfig.so: $(TRAFCONFIG_OBJS) $(TCDB_OBJS) $(TCDBSTORE_OBJS) $(TCDBSQLITE_OBJS) $(TRACE_LOG_OBJS) $(TCLOG_OBJS) $(TCTRACE_OBJS) $(TYPE2STR_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: Linker' - @echo $(CXX) $(LNK_FLGS) -shared -o $@ $(TRAFCONFIG_OBJS) $(TCDB_OBJS) $(TCDBSTORE_OBJS) $(TCDBSQLITE_OBJS) $(TRACE_LOG_OBJS) $(TCLOG_OBJS) $(TCTRACE_OBJS) $(TYPE2STR_OBJS) - @$(CXX) $(LNK_FLGS) -shared -o $@ $(TRAFCONFIG_OBJS) $(TCDB_OBJS) $(TCDBSTORE_OBJS) $(TCDBSQLITE_OBJS) $(TRACE_LOG_OBJS) $(TCLOG_OBJS) $(TCTRACE_OBJS) $(TYPE2STR_OBJS) - @echo 'Finished building target: $@' - @echo ' ' - - setup: @# do nothing @@ -574,7 +503,6 @@ clean: -rm -f $(ALLOBJS) -rm -f $(CDEP_DIR)/*.dep -rm -f $(LIBEXPDIR)/libseabasesig.so - -rm -f $(LIBEXPDIR)/libtrafconfig.so @echo ' ' cleanall: clean @@ -583,18 +511,6 @@ cleanall: clean cleaner: clean -rm -f *~ -#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 ' ' - rebuild: clean all -@echo ' ' http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/monlogging.cxx ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/monlogging.cxx b/core/sqf/monitor/linux/monlogging.cxx index 725a408..a54567a 100755 --- a/core/sqf/monitor/linux/monlogging.cxx +++ b/core/sqf/monitor/linux/monlogging.cxx @@ -37,8 +37,7 @@ using namespace std; #include <sys/shm.h> #include <sys/msg.h> #include <errno.h> -#include <seabed/logalt.h> - +#include "seabed/logalt.h" #include "monlogging.h" #include "montrace.h" #include "msgdef.h" http://git-wip-us.apache.org/repos/asf/trafodion/blob/87849fcf/core/sqf/monitor/linux/msgdef.h ---------------------------------------------------------------------- diff --git a/core/sqf/monitor/linux/msgdef.h b/core/sqf/monitor/linux/msgdef.h index ed0f8e8..4f20c55 100644 --- a/core/sqf/monitor/linux/msgdef.h +++ b/core/sqf/monitor/linux/msgdef.h @@ -27,6 +27,7 @@ #define MSGDEF_H_ #include <mpi.h> +#include "trafconf/trafconfig.h" // HP_MPI supports both 32bit and 64bit modes @@ -210,18 +211,20 @@ typedef enum { RoleType_Aggregation = 0x0002, // Maps to ZoneType_Aggregation, Backend or Any RoleType_Storage = 0x0004 // Maps to ZoneType_Storage, Backend or Any } RoleType; - +#if 0 typedef enum { - ZoneType_Undefined = 0x0000, // No zone type defined - ZoneType_Edge = 0x0001, // Zone of service only nodes + ZoneType_Undefined = 0x0000, // No zone type defined + ZoneType_Edge = 0x0001, // Zone of service only nodes ZoneType_Aggregation = 0x0002, // Zone of compute only nodes - ZoneType_Storage = 0x0004, // Zone of storage only nodes - ZoneType_Excluded = 0x0010, // Excluded cores - ZoneType_Any = ( ZoneType_Edge | ZoneType_Aggregation | ZoneType_Storage ), - ZoneType_Frontend = ( ZoneType_Edge | ZoneType_Aggregation ), - ZoneType_Backend = ( ZoneType_Aggregation | ZoneType_Storage ) + ZoneType_Storage = 0x0004, // Zone of storage only nodes + ZoneType_Excluded = 0x0010, // Excluded cores + ZoneType_Any = ( ZoneType_Edge | ZoneType_Aggregation | ZoneType_Storage ), + ZoneType_Frontend = ( ZoneType_Edge | ZoneType_Aggregation ), + ZoneType_Backend = ( ZoneType_Aggregation | ZoneType_Storage ) } ZoneType; - +#else +typedef TC_ZONE_TYPE ZoneType; +#endif // Service Request types // note: other data structures depend on the ordering of the REQTYPE elements. // if the ordering changes corresponding changes must be made to @@ -327,7 +330,7 @@ typedef enum { // types, add any new message types // before this one } MSGTYPE; - +#if 0 typedef enum { ProcessType_Undefined=0, // No process type as been defined ProcessType_TSE, // Identifies a Table Storage Engine (DP2) @@ -350,7 +353,9 @@ typedef enum { // types, add any new process // types before this one } PROCESSTYPE; - +#else +typedef TC_PROCESS_TYPE PROCESSTYPE; +#endif typedef enum { ShutdownLevel_Undefined=-1, ShutdownLevel_Normal=0, // Wait for all transactions and processes to end
