From 47d54af4f6b9e5aebbb1e92764eb6edd1c2bb34c Mon Sep 17 00:00:00 2001 From: Zalo Correa Date: Tue, 20 Jun 2017 21:15:15 -0700 Subject: [PATCH] [TRAFODION-2648] Added support for _PROGRAM_ARGS [TRAFODION-2650] Preliminary code restructing to support multiple Trafodion Configuration storage methods --- .../include/common/evl_sqlog_eventnum.h | 47 +- core/sqf/monitor/linux/clusterconf.cxx | 14 +- core/sqf/monitor/linux/clusterconf.h | 49 +- core/sqf/monitor/linux/makefile | 49 +- core/sqf/monitor/linux/montrace.cxx | 92 +- core/sqf/monitor/linux/montrace.h | 30 +- core/sqf/monitor/linux/persistconfig.cxx | 69 + core/sqf/monitor/linux/persistconfig.h | 11 + core/sqf/monitor/linux/pnode.cxx | 5 +- core/sqf/monitor/linux/pnode.h | 2 +- core/sqf/monitor/linux/pstartd.cxx | 51 +- core/sqf/monitor/linux/pstartd.h | 2 +- core/sqf/monitor/linux/reqqueue.cxx | 15 - core/sqf/monitor/linux/shell.cxx | 126 +- core/sqf/monitor/linux/tcdb.cxx | 478 ++++ core/sqf/monitor/linux/tcdb.h | 117 + .../{sqliteconfig.cxx => tcdbsqlite.cxx} | 247 +- .../linux/{sqliteconfig.h => tcdbsqlite.h} | 19 +- 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 + .../linux/{trafconfiglog.cxx => tclog.cxx} | 4 +- .../linux/{trafconfiglog.h => tclog.h} | 8 +- .../{trafconfigtrace.cxx => tctrace.cxx} | 75 +- .../linux/{trafconfigtrace.h => tctrace.h} | 6 +- core/sqf/monitor/linux/testconf.cxx | 8 +- core/sqf/monitor/linux/trafconf.cxx | 31 +- core/sqf/monitor/linux/trafconfig.cxx | 218 +- core/sqf/monitor/linux/trafconfig.h | 23 +- core/sqf/monitor/linux/type2str.cxx | 63 + core/sqf/monitor/linux/type2str.h | 34 + core/sqf/monitor/linux/watchdog.cxx | 2 +- core/sqf/monitor/linux/zclient.cxx | 114 +- core/sqf/sqenvcom.sh | 6 + core/sqf/sql/scripts/createConfigDb | 4 +- core/sqf/sql/scripts/sqconfig.persist | 8 + core/sqf/sql/scripts/sqpersist.pm | 30 +- 38 files changed, 4058 insertions(+), 489 deletions(-) create mode 100644 core/sqf/monitor/linux/tcdb.cxx create mode 100644 core/sqf/monitor/linux/tcdb.h rename core/sqf/monitor/linux/{sqliteconfig.cxx => tcdbsqlite.cxx} (93%) rename core/sqf/monitor/linux/{sqliteconfig.h => tcdbsqlite.h} (94%) create mode 100644 core/sqf/monitor/linux/tcdbstore.cxx create mode 100644 core/sqf/monitor/linux/tcdbstore.h create mode 100644 core/sqf/monitor/linux/tcdbzstore.cxx create mode 100644 core/sqf/monitor/linux/tcdbzstore.h rename core/sqf/monitor/linux/{trafconfiglog.cxx => tclog.cxx} (98%) rename core/sqf/monitor/linux/{trafconfiglog.h => tclog.h} (94%) rename core/sqf/monitor/linux/{trafconfigtrace.cxx => tctrace.cxx} (87%) rename core/sqf/monitor/linux/{trafconfigtrace.h => tctrace.h} (97%) create mode 100644 core/sqf/monitor/linux/type2str.cxx create mode 100644 core/sqf/monitor/linux/type2str.h diff --git a/core/sqf/export/include/common/evl_sqlog_eventnum.h b/core/sqf/export/include/common/evl_sqlog_eventnum.h index 3b8954b76d..dbf8d92920 100644 --- a/core/sqf/export/include/common/evl_sqlog_eventnum.h +++ b/core/sqf/export/include/common/evl_sqlog_eventnum.h @@ -810,7 +810,7 @@ /* Module: persistconfig.cxx = 36 */ #define MON_PERSISTCONFIG_ADDCONFIG_1 101360101 -/* Module: zoonode.cxx = 37 */ +/* Module: zclient.cxx = 37 */ #define MON_ZCLIENT_ZCLIENT_1 101370101 #define MON_ZCLIENT_ZCLIENT_2 101370102 #define MON_ZCLIENT_ZCLIENT_3 101370103 @@ -846,8 +846,49 @@ #define MON_ZCLIENT_CHECKMYZNODE_1 101371901 #define MON_ZCLIENT_CHECKMYZNODE_2 101371902 -/* Module: sqliteconfig.cxx = 90 */ -#define MON_DATABASE_ERROR 101900101 +/* Module: zconfig.cxx = 38 */ +#define ZCONFIG_ZCONFIG_1 101380101 +#define ZCONFIG_ZCONFIG_2 101380102 +#define ZCONFIG_ZCONFIG_3 101380103 +#define ZCONFIG_ZCONFIG_4 101380104 +#define ZCONFIG_CHECKCONFIG_1 101380201 +#define ZCONFIG_CHECKCONFIG_2 101380202 +#define ZCONFIG_GETCONFIGZNODESCHILDREN_1 101380301 +#define ZCONFIG_GETZNODEDATA_1 101380401 +#define ZCONFIG_GETZNODEDATA_2 101380402 +#define ZCONFIG_ISZNODEEXISTENT_1 101380501 +#define ZCONFIG_ISZNODEEXISTENT_2 101380502 +#define ZCONFIG_MAKECONFIGZNODE_1 101380601 +#define ZCONFIG_REGISTERZNODE_1 101380701 +#define ZCONFIG_SETZNODEWATCH_1 101380801 +#define ZCONFIG_SETZNODEWATCH_2 101380802 +#define ZCONFIG_WATCHCONFIG_1 101380901 +#define ZCONFIG_WATCHCONFIG_2 101380902 +#define ZCONFIG_WATCHCONFIG_2 101380902 +#define ZCONFIG_WATCHCONFIGZNODE_1 101381001 +#define ZCONFIG_DELETECONFIGZNODE_1 101381001 +#define ZCONFIG_DELETECONFIGZNODE_2 101381002 +#define ZCONFIG_DELETECONFIGZNODE_3 101381003 + +/* Module: tcdb.cxx = 90 */ +#define TCDB_TCDB_1 101900101 +#define TCDB_TCDB_2 101900102 +#define TCDB_TCDB_3 101900103 + +/* Module: tcdbzstore.cxx = 91 */ +#define TCDB_ZSTORE_SESSIONWATCHER_1 101910101 +#define TCDB_ZSTORE_SESSIONWATCHER_2 101910102 +#define TCDB_ZSTORE_ZSTORE_1 101910201 +#define TCDB_ZSTORE_ZSTORE_2 101910202 +#define TCDB_ZSTORE_ZSTORE_3 101910203 +#define TCDB_ZSTORE_ZSTORE_4 101910204 +#define TCDB_ZSTORE_MAKECLUSTERZNODES_1 101910301 +#define TCDB_ZSTORE_MAKECLUSTERZNODES_2 101910302 +#define TCDB_ZSTORE_MAKECLUSTERZNODES_3 101910303 + +/* Module: tcdbsqlite.cxx = 92 */ +#define SQLITE_DB_ACCESS_ERROR 101920101 + /**********************************************/ diff --git a/core/sqf/monitor/linux/clusterconf.cxx b/core/sqf/monitor/linux/clusterconf.cxx index 1316b025a3..205bf36414 100644 --- a/core/sqf/monitor/linux/clusterconf.cxx +++ b/core/sqf/monitor/linux/clusterconf.cxx @@ -60,8 +60,10 @@ CClusterConfig::CClusterConfig( void ) , persistReady_(false) , newPNodeConfig_(true) , trafConfigInitialized_(false) + , trafConfigStorageType_(TCDBSTOREUNDEFINED) , prevPNodeConfig_(NULL) , prevLNodeConfig_(NULL) + , prevPersistConfig_(NULL) { const char method_name[] = "CClusterConfig::CClusterConfig"; TRACE_ENTRY; @@ -296,6 +298,11 @@ PROCESSTYPE CClusterConfig::GetProcessType( const char *processtype ) } bool CClusterConfig::Initialize( void ) +{ + return( Initialize( NULL ) ); +} + +bool CClusterConfig::Initialize( const char *traceFile ) { const char method_name[] = "CClusterConfig::Initialize"; TRACE_ENTRY; @@ -307,7 +314,7 @@ bool CClusterConfig::Initialize( void ) } bool trafConfigTrace = (trace_settings & TRACE_TRAFCONFIG); - int rc = tc_initialize( trafConfigTrace ); + int rc = tc_initialize( trafConfigTrace, traceFile ); if ( rc ) { char la_buf[MON_STRING_BUF_SIZE]; @@ -319,6 +326,7 @@ bool CClusterConfig::Initialize( void ) } trafConfigInitialized_ = true; + trafConfigStorageType_ = tc_get_storage_type(); TRACE_EXIT; return( true ); @@ -654,6 +662,10 @@ void CClusterConfig::ProcessPersistInfo( persist_configuration_t &persistConfig , 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) ); diff --git a/core/sqf/monitor/linux/clusterconf.h b/core/sqf/monitor/linux/clusterconf.h index 00ace06d39..d9a1b79516 100644 --- a/core/sqf/monitor/linux/clusterconf.h +++ b/core/sqf/monitor/linux/clusterconf.h @@ -44,10 +44,12 @@ class CClusterConfig : public CPNodeConfigContainer 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 ); @@ -75,55 +77,10 @@ class CClusterConfig : public CPNodeConfigContainer bool persistReady_; // true when persist configuration loaded bool newPNodeConfig_; bool trafConfigInitialized_; + TC_STORAGE_TYPE trafConfigStorageType_; CPNodeConfig *prevPNodeConfig_; CLNodeConfig *prevLNodeConfig_; CPersistConfig *prevPersistConfig_; -#if 0 - bool excludedCores_; - bool newPNodeConfig_; - bool newLNodeConfig_; - int currNid_; - int currPNid_; - int currSPNid_; - char currNodename_[MPI_MAX_PROCESSOR_NAME]; - cpu_set_t currExcludedCoreMask_; - cpu_set_t currCoreMask_; - int currExcludedFirstCore_; - int currExcludedLastCore_; - int currFirstCore_; - int currLastCore_; - int currProcessor_; - ZoneType currZoneType_; - CPNodeConfig *currPNodeConfig_; - int prevNid_; - int prevPNid_; - int prevSPNid_; - char prevNodename_[MPI_MAX_PROCESSOR_NAME]; - cpu_set_t prevExcludedCoreMask_; - cpu_set_t prevCoreMask_; - int prevExcludedFirstCore_; - int prevExcludedLastCore_; - int prevFirstCore_; - int prevLastCore_; - int prevProcessor_; - ZoneType prevZoneType_; - int sparePNid_[MAX_NODES]; - int spareIndex_; - CPNodeConfig *prevPNodeConfig_; - CLNodeConfig *lnodeConfig_; - char persistPrefix_[PERSIST_KEY_MAX]; - char processNamePrefix_[PERSIST_VALUE_MAX]; - char processNameFormat_[PERSIST_VALUE_MAX]; - char stdoutPrefix_[PERSIST_VALUE_MAX]; - char stdoutFormat_[PERSIST_VALUE_MAX]; - char programName_[PERSIST_VALUE_MAX]; - char zoneFormat_[PERSIST_VALUE_MAX]; - PROCESSTYPE processType_; - bool requiresDTM_; - int persistRetries_; - int persistWindow_; - CPersistConfig *persistConfig_; -#endif void AddNodeConfiguration( pnodeConfigInfo_t &pnodeConfigInfo , lnodeConfigInfo_t &lnodeConfigInfo ); diff --git a/core/sqf/monitor/linux/makefile b/core/sqf/monitor/linux/makefile index b8c034ad48..8f77157e16 100644 --- a/core/sqf/monitor/linux/makefile +++ b/core/sqf/monitor/linux/makefile @@ -220,6 +220,7 @@ MONITOROBJS += $(OUTDIR)/gentrap.o MONITOROBJS += $(OUTDIR)/monrobsem.o MONITOROBJS += $(OUTDIR)/CommonLogger.o MONITOROBJS += $(OUTDIR)/zclient.o +MONITOROBJS += $(OUTDIR)/type2str.o SHELLOBJS = $(OUTDIR)/shell.o SHELLOBJS += $(OUTDIR)/monclio.o @@ -301,18 +302,30 @@ TRAFCONFOBJS += $(OUTDIR)/lnodeconfig.o TRAFCONFOBJS += $(OUTDIR)/pnodeconfig.o TRAFCONFOBJS += $(OUTDIR)/persistconfig.o -SQLITECONFIG_SRC = sqliteconfig.cxx -SQLITECONFIG_OBJS = $(OUTDIR)/sqliteconfig.o +TCDB_SRC = tcdb.cxx +TCDB_OBJS = $(OUTDIR)/tcdb.o -TRAFCONFIGLOG_SRC = trafconfiglog.cxx -TRAFCONFIGLOG_OBJS = $(OUTDIR)/trafconfiglog.o +TCDBSQLITE_SRC = tcdbsqlite.cxx +TCDBSQLITE_OBJS = $(OUTDIR)/tcdbsqlite.o -TRAFCONFIGTRACE_SRC = trafconfigtrace.cxx -TRAFCONFIGTRACE_OBJS = $(OUTDIR)/trafconfigtrace.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 + ALLOBJS = $(MONITOROBJS) ALLOBJS += $(SHELLOBJS) ALLOBJS += $(CLIENTOBJS) @@ -326,10 +339,14 @@ ALLOBJS += $(MEMLOGOBJS) ALLOBJS += $(RTSIGBLOCK_OBJS) ALLOBJS += $(ZOOMONOBJS) ALLOBJS += $(TRAFCONFOBJS) -ALLOBJS += $(SQLITECONFIG_OBJS) +ALLOBJS += $(TCDB_OBJS) +ALLOBJS += $(TCDBSQLITE_OBJS) +ALLOBJS += $(TCDBSTORE_OBJS) +#ALLOBJS += $(TCDBZSTORE_OBJS) +ALLOBJS += $(TCLOG_OBJS) +ALLOBJS += $(TCTRACE_OBJS) ALLOBJS += $(TRAFCONFIG_OBJS) -ALLOBJS += $(TRAFCONFIGLOG_OBJS) -ALLOBJS += $(TRAFCONFIGTRACE_OBJS) +ALLOBJS += $(TYPE2STR_OBJS) SHAREDLIBS = $(LIBEXPDIR)/libtrafconfig.so SHAREDLIBS += $(LIBEXPDIR)/libseabasesig.so @@ -532,11 +549,19 @@ $(LIBEXPDIR)/libseabasesig.so: $(RTSIGBLOCK_OBJS) @echo 'Finished building target: $@' @echo ' ' -$(LIBEXPDIR)/libtrafconfig.so: $(TRAFCONFIG_OBJS) $(SQLITECONFIG_OBJS) $(TRACE_LOG_OBJS) $(TRAFCONFIGLOG_OBJS) $(TRAFCONFIGTRACE_OBJS) +#$(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) $(SQLITECONFIG_OBJS) $(TRACE_LOG_OBJS) $(TRAFCONFIGLOG_OBJS) $(TRAFCONFIGTRACE_OBJS) - @$(CXX) $(LNK_FLGS) -shared -o $@ $(TRAFCONFIG_OBJS) $(SQLITECONFIG_OBJS) $(TRACE_LOG_OBJS) $(TRAFCONFIGLOG_OBJS) $(TRAFCONFIGTRACE_OBJS) + @echo $(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 ' ' diff --git a/core/sqf/monitor/linux/montrace.cxx b/core/sqf/monitor/linux/montrace.cxx index 9f2a3915cc..a4ee502fc9 100644 --- a/core/sqf/monitor/linux/montrace.cxx +++ b/core/sqf/monitor/linux/montrace.cxx @@ -37,11 +37,11 @@ using namespace std; extern int MyPNID; extern char Node_name[MPI_MAX_PROCESSOR_NAME]; -const char *CMonTrace::str_trace_enable = "MON_TRACE_ENABLE"; -const char *CMonTrace::str_trace_file = "MON_TRACE_FILE"; -const char *CMonTrace::str_trace_file_fb = "MON_TRACE_FILE_FB"; +const char *CMonTrace::traceEnableStr_ = "MON_TRACE_ENABLE"; +const char *CMonTrace::traceFileStr_ = "MON_TRACE_FILE"; +const char *CMonTrace::traceFileFbStr_ = "MON_TRACE_FILE_FB"; -const CMonTrace::traceArea CMonTrace::traceAreaList[] = +const CMonTrace::TraceArea_t CMonTrace::traceAreaList_[] = { {"MON_TRACE_REQUEST", TRACE_REQUEST}, {"MON_TRACE_REQUEST_DETAIL", TRACE_REQUEST_DETAIL}, {"MON_TRACE_PROCESS", TRACE_PROCESS}, @@ -69,9 +69,15 @@ long trace_settings = 0; CMonTrace *MonTrace = new CMonTrace (); -CMonTrace::CMonTrace() : tracingEnabled(false), trace_settings_saved(0), trace_file_fb(0), trace_file_base(NULL) +CMonTrace::CMonTrace() + : tracingEnabled_(false) + , numTraceAreas_(0) + , traceSettingsSaved_(0) + , traceFileFB_(0) + , traceFileBase_(NULL) + , traceFileName_("") { - numTraceAreas = sizeof(traceAreaList)/sizeof(traceArea); + numTraceAreas_ = sizeof(traceAreaList_)/sizeof(TraceArea_t); } const char *CMonTrace::getenv_str(const char *key) @@ -120,15 +126,15 @@ void CMonTrace::mon_trace_init(const char * traceLevel, const char *pfname) if (pfname == NULL) { // Caller did not specify a trace file name, get name from // environment variable if specified. - pfname = getenv_str(str_trace_file); + pfname = getenv_str(traceFileStr_); } if (pfname != NULL) { // User specified trace file name // Save the base trace file name for possible use later - trace_file_base = new char[strlen(pfname) + 1]; - strcpy(trace_file_base, pfname); + traceFileBase_ = new char[strlen(pfname) + 1]; + strcpy(traceFileBase_, pfname); if ((strcmp(pfname, "STDOUT") == 0) || strcmp(pfname, "STDERR") == 0) @@ -142,24 +148,26 @@ void CMonTrace::mon_trace_init(const char * traceLevel, const char *pfname) } } + traceFileName_ = trace_file_name; + // Get any trace settings that were specified via environment variables const char *value; - for (int i=0; i 0) + if (traceFileFB_ > 0) { - trace_set_mem(trace_file_fb); + trace_set_mem(traceFileFB_); } } } @@ -214,68 +222,68 @@ const char *CMonTrace::mon_help_str(const char *key, const char *value, void CMonTrace::mon_trace_change(const char *key, const char *value) { - bool trace_was_enabled = tracingEnabled; + bool trace_was_enabled = tracingEnabled_; const char *pfname; - int old_fb = trace_file_fb; + int old_fb = traceFileFB_; if (key == NULL) return; // Restore saved trace settings in case trace flags get modified - trace_settings = trace_settings_saved; + trace_settings = traceSettingsSaved_; // Compare the key with each of the trace flag strings. When // there is an equal compare, assign the value to the appropriate flag. - for (int i=0; i 0) && (old_fb != trace_file_fb)) - trace_set_mem(trace_file_fb); + if ((traceFileFB_ > 0) && (old_fb != traceFileFB_)) + trace_set_mem(traceFileFB_); } diff --git a/core/sqf/monitor/linux/montrace.h b/core/sqf/monitor/linux/montrace.h index dce911a5ad..8a7835942f 100644 --- a/core/sqf/monitor/linux/montrace.h +++ b/core/sqf/monitor/linux/montrace.h @@ -26,6 +26,9 @@ #ifndef MONTRACE_H_ #define MONTRACE_H_ +using namespace std; + +#include #include "seabed/trace.h" // Monitor request processing @@ -82,6 +85,8 @@ class CMonTrace void mon_trace_change(const char *key, const char *value); + inline const char *getTraceFileName(void) { return( traceFileName_.c_str() ); }; + private: const char *getenv_str(const char *key); @@ -97,29 +102,28 @@ class CMonTrace const char *mon_help_str(const char *key, const char *value, const char *key_cmp); - // The number of trace areas held in "traceAreaList" - int numTraceAreas; + bool tracingEnabled_; - bool tracingEnabled; + // The number of trace areas held in "traceAreaList" + int numTraceAreas_; // Save area for retaining prior trace settings if tracing is // disabled. These are used to restore the values when tracing // is re-enabled. - long trace_settings_saved; - - // Optional size of trace file buffer. - int trace_file_fb; + long traceSettingsSaved_; - char *trace_file_base; + int traceFileFB_; // Optional size of trace file buffer. + char *traceFileBase_; + string traceFileName_; // Array of strings defining various trace areas and the // trace bit flag associated with that area - typedef struct {const char *id; long bitFlag;} traceArea; - static const traceArea traceAreaList[]; + typedef struct {const char *id; long bitFlag;} TraceArea_t; + static const TraceArea_t traceAreaList_[]; - static const char *str_trace_enable; - static const char *str_trace_file; - static const char *str_trace_file_fb; + static const char *traceEnableStr_; + static const char *traceFileStr_; + static const char *traceFileFbStr_; }; #endif diff --git a/core/sqf/monitor/linux/persistconfig.cxx b/core/sqf/monitor/linux/persistconfig.cxx index c7572c389b..b2e452608a 100644 --- a/core/sqf/monitor/linux/persistconfig.cxx +++ b/core/sqf/monitor/linux/persistconfig.cxx @@ -198,6 +198,7 @@ CPersistConfig::CPersistConfig( persistConfigInfo_t &persistConfigInfo ) , stdoutPrefix_(persistConfigInfo.stdoutPrefix) , stdoutFormat_(persistConfigInfo.stdoutFormat) , programName_(persistConfigInfo.programName) + , programArgs_(persistConfigInfo.programArgs) , zoneFormat_(persistConfigInfo.zoneFormat) , processType_(persistConfigInfo.processType) , processNameNidFormat_(Nid_Undefined) @@ -206,6 +207,9 @@ CPersistConfig::CPersistConfig( persistConfigInfo_t &persistConfigInfo ) , requiresDTM_(persistConfigInfo.requiresDTM) , persistRetries_(persistConfigInfo.persistRetries) , persistWindow_(persistConfigInfo.persistWindow) + , programArgc_(0) + , programArgv_(NULL) + , programArgvLen_(0) , next_(NULL) , prev_(NULL) { @@ -246,6 +250,69 @@ CPersistConfig::CPersistConfig( persistConfigInfo_t &persistConfigInfo ) } } + 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; } @@ -254,6 +321,8 @@ CPersistConfig::~CPersistConfig( void ) const char method_name[] = "CPersistConfig::~CPersistConfig"; TRACE_ENTRY; + if (programArgv_) delete [] programArgv_; + TRACE_EXIT; } diff --git a/core/sqf/monitor/linux/persistconfig.h b/core/sqf/monitor/linux/persistconfig.h index 1a5ac43303..12c3322bca 100644 --- a/core/sqf/monitor/linux/persistconfig.h +++ b/core/sqf/monitor/linux/persistconfig.h @@ -52,6 +52,7 @@ typedef enum } FormatZid_t; typedef vector pkeysVector_t; +typedef vector stringVector_t; typedef struct persistConfigInfo_s { @@ -61,6 +62,7 @@ typedef struct persistConfigInfo_s 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; @@ -119,6 +121,10 @@ class CPersistConfig 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_ ); } @@ -138,6 +144,7 @@ class CPersistConfig string stdoutPrefix_; string stdoutFormat_; string programName_; + string programArgs_; string zoneFormat_; PROCESSTYPE processType_; FormatNid_t processNameNidFormat_; @@ -147,6 +154,10 @@ class CPersistConfig int persistRetries_; int persistWindow_; + int programArgc_; + char *programArgv_; + int programArgvLen_; + CPersistConfig *next_; // next PersistConfig in CPersistConfigContainer list CPersistConfig *prev_; // previous PersistConfig in CPersistConfigContainer list }; diff --git a/core/sqf/monitor/linux/pnode.cxx b/core/sqf/monitor/linux/pnode.cxx index 4fc35e69bc..19d36f6e5a 100644 --- a/core/sqf/monitor/linux/pnode.cxx +++ b/core/sqf/monitor/linux/pnode.cxx @@ -64,6 +64,7 @@ extern CNode *MyNode; extern CMonStats *MonStats; extern CRedirector Redirector; extern CReplicate Replicator; +extern CMonTrace *MonTrace; extern bool IAmIntegrating; @@ -1425,7 +1426,7 @@ CNodeContainer::CNodeContainer( void ) SyncBuffer = new struct sync_buffer_def; - // Load cluster configuration from 'sqconfig.db' + // Load cluster configuration LoadConfig(); // Allocate logical and physical node arrays @@ -3142,7 +3143,7 @@ void CNodeContainer::LoadConfig( void ) } if ( clusterConfig_ ) { - if ( clusterConfig_->Initialize() ) + if ( clusterConfig_->Initialize( MonTrace->getTraceFileName() ) ) { if ( ! clusterConfig_->LoadConfig() ) { diff --git a/core/sqf/monitor/linux/pnode.h b/core/sqf/monitor/linux/pnode.h index d484b6ac3c..97b02dbb34 100644 --- a/core/sqf/monitor/linux/pnode.h +++ b/core/sqf/monitor/linux/pnode.h @@ -149,7 +149,7 @@ class CNodeContainer : public CLNodeContainer private: int pnodeCount_; // # of physical node objects in array int *indexToPnid_; // map of configuration entries to Node[pnid] - CClusterConfig *clusterConfig_; // 'sqconfig.db' objects + CClusterConfig *clusterConfig_; // configuration objects NodesList spareNodesList_; // current spare physical nodes list NodesList spareNodesConfigList_; // configured spare physical nodes list CNode *head_; // head of physical nodes linked list diff --git a/core/sqf/monitor/linux/pstartd.cxx b/core/sqf/monitor/linux/pstartd.cxx index f3388d842a..f57b550b50 100644 --- a/core/sqf/monitor/linux/pstartd.cxx +++ b/core/sqf/monitor/linux/pstartd.cxx @@ -487,8 +487,8 @@ bool CMonUtil::requestNewProcess (int nid, PROCESSTYPE type, const char *processName, const char *progName, const char *inFile, const char *outFile, - int progArgC, const char *progArgs, - int argBegin[], int argLen[], + int progArgc, const char *progArgs, +// int argBegin[], int argLen[], int& newNid, int& newPid, char *newProcName) { @@ -533,11 +533,28 @@ bool CMonUtil::requestNewProcess (int nid, PROCESSTYPE type, strcpy (msg->u.request.u.new_process.program, progName); STRCPY (msg->u.request.u.new_process.infile, inFile); STRCPY (msg->u.request.u.new_process.outfile, outFile); - msg->u.request.u.new_process.argc = progArgC; - for (int i=0; iu.request.u.new_process.argc = progArgc; + + char *token, *programArgs = NULL; + int argi = 0; + static const char *delim = " "; + + programArgs = new char [MAX_ARG_SIZE*MAX_ARGS]; + memset(programArgs, 0, MAX_ARG_SIZE*MAX_ARGS); + memcpy(programArgs, progArgs, strlen(progArgs)+1); + token = strtok( programArgs, delim ); + while (token != NULL) { - strncpy (msg->u.request.u.new_process.argv[i], &progArgs[argBegin[i]], - argLen[i]); + if ( trace_ ) + { + trace_printf( "%s@%d Setting progArgc=%d, argv[%d]=%s\n" + , method_name, __LINE__, progArgc, argi, token); + } + strncpy( msg->u.request.u.new_process.argv[argi] + , token + , strlen(token)); + argi++; + token = strtok( NULL, delim ); } gp_local_mon_io->send_recv( msg ); @@ -910,7 +927,7 @@ void CPStartD::startProcess( CPersistConfig *persistConfig ) const char method_name[] = "CPStartD::startProcess"; PROCESSTYPE procType = ProcessType_Undefined; - int progArgC = 0; + int progArgc = 0; string procName; string progArgs; string progStdout; @@ -919,13 +936,15 @@ void CPStartD::startProcess( CPersistConfig *persistConfig ) bool result; int newNid; int newPid; - int argBegin[MAX_ARGS]; - int argLen[MAX_ARGS]; +// int argBegin[MAX_ARGS]; +// int argLen[MAX_ARGS]; procName = persistConfig->GetProcessName( MyNid ); procType = persistConfig->GetProcessType(); progStdout = persistConfig->GetStdoutFile( MyNid ); progProgram = persistConfig->GetProgramName(); + progArgs = persistConfig->GetProgramArgs(); + progArgc = persistConfig->GetProgramArgc(); if ( tracing ) { @@ -934,7 +953,7 @@ void CPStartD::startProcess( CPersistConfig *persistConfig ) , method_name, __LINE__, MyNid , ProcessTypeString(procType), procName.c_str() , progProgram.c_str(), progStdout.c_str() - , progArgC, progArgs.c_str()); + , progArgc, progArgs.c_str()); } char buf[MON_STRING_BUF_SIZE]; @@ -950,10 +969,10 @@ void CPStartD::startProcess( CPersistConfig *persistConfig ) , progProgram.c_str() , "" , progStdout.c_str() - , progArgC + , progArgc , progArgs.c_str() - , argBegin - , argLen + // , argBegin + // , argLen , newNid , newPid , newProcName); @@ -996,6 +1015,8 @@ void CPStartD::startProcs ( bool requiresDTM ) "\t\tPersist Retries = %d\n" "\t\tPersist Window = %d\n" "\t\tPersist Zones = %s\n" + "\t\tProgram Args = %s\n" + "\t\tProgram Argc = %d\n" , method_name, __LINE__ , persistConfig->GetPersistPrefix() , persistConfig->GetProcessName( MyNid ) @@ -1005,7 +1026,9 @@ void CPStartD::startProcs ( bool requiresDTM ) , persistConfig->GetRequiresDTM() ? "Y" : "N" , persistConfig->GetPersistRetries() , persistConfig->GetPersistWindow() - , persistConfig->GetZoneFormat() ); + , persistConfig->GetZoneFormat() + , persistConfig->GetProgramArgs() + , persistConfig->GetProgramArgc() ); } switch (persistConfig->GetProcessType()) diff --git a/core/sqf/monitor/linux/pstartd.h b/core/sqf/monitor/linux/pstartd.h index e697638f3e..9c2f0e275a 100644 --- a/core/sqf/monitor/linux/pstartd.h +++ b/core/sqf/monitor/linux/pstartd.h @@ -69,7 +69,7 @@ class CMonUtil const char *progName, const char *inFile, const char *outFile, int progArgC, const char *progArgV, - int argBegin[], int argEnd[], +// int argBegin[], int argEnd[], int& newNid, int& newPid, char *newProcName); diff --git a/core/sqf/monitor/linux/reqqueue.cxx b/core/sqf/monitor/linux/reqqueue.cxx index 19b8313e51..f09534517a 100644 --- a/core/sqf/monitor/linux/reqqueue.cxx +++ b/core/sqf/monitor/linux/reqqueue.cxx @@ -2340,7 +2340,6 @@ void CIntReviveReq::performRequest() mem_log_write(MON_REQQUEUE_REVIVE_4); - // the creator monitor copied sqconfig.db before the above handshake. Config->Init(); if (trace_settings & (TRACE_REQUEST | TRACE_INIT | TRACE_RECOVERY)) @@ -2464,20 +2463,6 @@ void CIntSnapshotReq::performRequest() abort(); } -#if 0 - // copy sqconfig.db - char cmd[256]; - sprintf(cmd, "pdcp -p -w %s %s/sql/scripts/sqconfig.db %s/sql/scripts/.", Monitor->GetIntegratingNode()->GetName(), - getenv("TRAF_HOME"), getenv("TRAF_HOME") ); - - error = system(cmd); - - if (trace_settings & TRACE_REQUEST) - trace_printf("%s@%d - Copied config.db (%s) Error = %d\n", method_name, __LINE__, cmd, error); - - mem_log_write(MON_REQQUEUE_SNAPSHOT_3, error); -#endif - // estimate size of snapshot buffer // about 100 bytes per process, 1.5 times total int procSize = Nodes->ProcessCount() * 1.75 * 100; diff --git a/core/sqf/monitor/linux/shell.cxx b/core/sqf/monitor/linux/shell.cxx index 4705c9eb30..b80d2a1a0c 100644 --- a/core/sqf/monitor/linux/shell.cxx +++ b/core/sqf/monitor/linux/shell.cxx @@ -108,7 +108,7 @@ char nodePendingName[MPI_MAX_PROCESSOR_NAME]; int nodePendingPnid; CLock nodePendingLock; -CClusterConfig ClusterConfig; // 'sqconfig.db' objects +CClusterConfig ClusterConfig; // Configuration objects char PNode[MAX_NODES][MPI_MAX_PROCESSOR_NAME]; char Node[MAX_NODES][MPI_MAX_PROCESSOR_NAME]; @@ -616,7 +616,7 @@ void TraceOpen ( void ) // Initialize tracing trace_init(traceFileName, false, // don't append pid to file name - "shell", // prefix + (char *)"shell", // prefix false); if (traceFileFb > 0) { @@ -1824,9 +1824,12 @@ void get_persist_process_attributes( CPersistConfig *persistConfig , int nid , PROCESSTYPE &processType , char *processName + , int &programArgc + , char *programArgs , char *outfile , char *persistRetries - , char *persistZones ) + , char *persistZones + ) { const char method_name[] = "get_persist_process_attributes"; char zoneStr[MAX_PERSIST_VALUE_STR]; @@ -1875,6 +1878,14 @@ void get_persist_process_attributes( CPersistConfig *persistConfig , persistConfig->GetStdoutPrefix() , nid ); } + + programArgc = persistConfig->GetProgramArgc(); + if (programArgc) + { + sprintf( programArgs, "%s" + , persistConfig->GetProgramArgs() ); + } + sprintf( persistRetries, "%d,%d" , persistConfig->GetPersistRetries() , persistConfig->GetPersistWindow() ); @@ -2981,7 +2992,7 @@ bool load_configuration( void ) // It was previously loaded, remove the current configuration ClusterConfig.Clear(); } - if ( ClusterConfig.Initialize() ) + if ( ClusterConfig.Initialize( traceFileName ) ) { if ( ! ClusterConfig.LoadConfig() ) { @@ -3043,7 +3054,7 @@ bool load_configuration( void ) } else { - printf( "[%s] Warning: No sqconfig.db found\n",MyName); + printf( "[%s] Error: Could not initialize Trafodion Configuration database\n",MyName); return false; } @@ -3916,14 +3927,15 @@ int node_up( int nid, char *node_name, bool nowait ) void persist_config( char *prefix ) { bool foundConfig = false; - char persist_config_buf[MAX_VALUE_SIZE_INT]; - char process_name_str[MAX_TOKEN]; - char process_type_str[MAX_TOKEN]; - char program_name_str[MAX_TOKEN]; - char requires_dtm_str[MAX_TOKEN]; - char stdout_str[MAX_TOKEN]; - char persist_retries_str[MAX_TOKEN]; - char persist_zones_str[MAX_TOKEN]; + char persist_config_buf[TC_PERSIST_VALUE_MAX*2]; + char process_name_str[TC_PERSIST_VALUE_MAX]; + char process_type_str[TC_PERSIST_VALUE_MAX]; + char program_name_str[TC_PERSIST_VALUE_MAX]; + char program_args_str[TC_PERSIST_VALUE_MAX]; + char requires_dtm_str[TC_PERSIST_VALUE_MAX]; + char stdout_str[TC_PERSIST_VALUE_MAX]; + char persist_retries_str[TC_PERSIST_VALUE_MAX]; + char persist_zones_str[TC_PERSIST_VALUE_MAX]; CPersistConfig *persistConfig; persistConfig = ClusterConfig.GetFirstPersistConfig(); @@ -3936,55 +3948,62 @@ void persist_config( char *prefix ) { foundConfig = true; snprintf( process_name_str, sizeof(process_name_str) - , "%s_%s=%s%s" + , "%s_%s = %s%s" , persistConfig->GetPersistPrefix() , PERSIST_PROCESS_NAME_KEY , persistConfig->GetProcessNamePrefix() , persistConfig->GetProcessNameFormat() ); snprintf( process_type_str, sizeof(process_type_str) - , "%s_%s=%s" + , "%s_%s = %s" , persistConfig->GetPersistPrefix() , PERSIST_PROCESS_TYPE_KEY , PersistProcessTypeString(persistConfig->GetProcessType()) ); snprintf( program_name_str, sizeof(program_name_str) - , "%s_%s=%s" + , "%s_%s = %s" , persistConfig->GetPersistPrefix() , PERSIST_PROGRAM_NAME_KEY , persistConfig->GetProgramName() ); + snprintf( program_args_str, sizeof(program_args_str) + , "%s_%s = %s" + , persistConfig->GetPersistPrefix() + , PERSIST_PROGRAM_ARGS_KEY + , persistConfig->GetProgramArgs() + ); snprintf( requires_dtm_str, sizeof(requires_dtm_str) - , "%s_%s=%s" + , "%s_%s = %s" , persistConfig->GetPersistPrefix() , PERSIST_REQUIRES_DTM , persistConfig->GetRequiresDTM()?"Y":"N" ); snprintf( stdout_str, sizeof(stdout_str) - , "%s_%s=%s%s" + , "%s_%s = %s%s" , persistConfig->GetPersistPrefix() , PERSIST_STDOUT_KEY , persistConfig->GetStdoutPrefix() , persistConfig->GetStdoutFormat() ); snprintf( persist_retries_str, sizeof(persist_retries_str) - , "%s_%s=%d,%d" + , "%s_%s = %d,%d" , persistConfig->GetPersistPrefix() , PERSIST_RETRIES_KEY , persistConfig->GetPersistRetries() , persistConfig->GetPersistWindow() ); snprintf( persist_zones_str, sizeof(persist_zones_str) - , "%s_%s=%s" + , "%s_%s = %s" , persistConfig->GetPersistPrefix() , PERSIST_ZONES_KEY , persistConfig->GetZoneFormat() ); snprintf( persist_config_buf, sizeof(persist_config_buf) - , "%s\n%s\n%s\n%s\n%s\n%s\n%s\n" + , "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n" , process_name_str , process_type_str , program_name_str + , program_args_str , requires_dtm_str , stdout_str , persist_retries_str @@ -4101,6 +4120,8 @@ bool persist_process_kill( CPersistConfig *persistConfig ) char outfile[MAX_PROCESS_PATH]; char persistRetries[MAX_PERSIST_VALUE_STR]; char persistZones[MAX_VALUE_SIZE_INT]; + char programArgs[MAX_VALUE_SIZE_INT]; + int programArgc = 0; int nid; int pnid; int lnodesCount = 0; @@ -4133,6 +4154,8 @@ bool persist_process_kill( CPersistConfig *persistConfig ) , i , process_type , processName + , programArgc + , programArgs , outfile , persistRetries , persistZones ); @@ -4152,6 +4175,8 @@ bool persist_process_kill( CPersistConfig *persistConfig ) , nid , process_type , processName + , programArgc + , programArgs , outfile , persistRetries , persistZones ); @@ -4168,6 +4193,8 @@ bool persist_process_kill( CPersistConfig *persistConfig ) , -1 , process_type , processName + , programArgc + , programArgs , outfile , persistRetries , persistZones ); @@ -4192,6 +4219,8 @@ bool persist_process_start( CPersistConfig *persistConfig ) bool debug = false; bool nowait = false; char processName[MAX_PROCESS_NAME]; + char programArgs[MAX_VALUE_SIZE_INT]; + char programNameAndArgs[MAX_PROCESS_PATH+MAX_VALUE_SIZE_INT]; char infile[MAX_PROCESS_PATH]; char outfile[MAX_PROCESS_PATH]; char persistRetries[MAX_PERSIST_VALUE_STR]; @@ -4199,6 +4228,7 @@ bool persist_process_start( CPersistConfig *persistConfig ) int nid; int pid; int pnid; + int programArgc = 0; int lnodesCount = 0; PROCESSTYPE process_type; int priority; @@ -4207,6 +4237,7 @@ bool persist_process_start( CPersistConfig *persistConfig ) nid = -1; priority = 0; processName[0] = '\0'; // The monitor will assign name if null + programArgs[0] = '\0'; infile[0] = '\0'; // The monitor's default infile is used outfile[0] = '\0'; // The monitor's default outfile is used process_type = ProcessType_Undefined; @@ -4233,6 +4264,8 @@ bool persist_process_start( CPersistConfig *persistConfig ) , i , process_type , processName + , programArgc + , programArgs , outfile , persistRetries , persistZones ); @@ -4241,6 +4274,17 @@ bool persist_process_start( CPersistConfig *persistConfig ) printf( "Persistent process %s already exists\n", processName); continue; } + if (programArgc) + { + sprintf( programNameAndArgs, "%s %s" + , persistConfig->GetProgramName() + , programArgs ); + } + else + { + sprintf( programNameAndArgs, "%s" + , persistConfig->GetProgramName() ); + } pid = start_process( &i , process_type , processName @@ -4249,7 +4293,8 @@ bool persist_process_start( CPersistConfig *persistConfig ) , nowait , infile , outfile - , (char *)persistConfig->GetProgramName() ); + , programNameAndArgs ); + //, (char *)persistConfig->GetProgramName() ); if (pid > 0) { printf( "Persistent process %s created\n", processName); @@ -4273,6 +4318,8 @@ bool persist_process_start( CPersistConfig *persistConfig ) , nid , process_type , processName + , programArgc + , programArgs , outfile , persistRetries , persistZones ); @@ -4281,6 +4328,17 @@ bool persist_process_start( CPersistConfig *persistConfig ) printf( "Persistent process %s already exists\n", processName); break; } + if (programArgc) + { + sprintf( programNameAndArgs, "%s %s" + , persistConfig->GetProgramName() + , programArgs ); + } + else + { + sprintf( programNameAndArgs, "%s" + , persistConfig->GetProgramName() ); + } pid = start_process( &nid , process_type , processName @@ -4289,7 +4347,7 @@ bool persist_process_start( CPersistConfig *persistConfig ) , nowait , infile , outfile - , (char *)persistConfig->GetProgramName() ); + , programNameAndArgs ); if (pid > 0) { printf( "Persistent process %s created\n", processName); @@ -4311,6 +4369,8 @@ bool persist_process_start( CPersistConfig *persistConfig ) , -1 , process_type , processName + , programArgc + , programArgs , outfile , persistRetries , persistZones ); @@ -4319,6 +4379,17 @@ bool persist_process_start( CPersistConfig *persistConfig ) printf( "Persistent process %s already exists\n", processName); break; } + if (programArgc) + { + sprintf( programNameAndArgs, "%s %s" + , persistConfig->GetProgramName() + , programArgs ); + } + else + { + sprintf( programNameAndArgs, "%s" + , persistConfig->GetProgramName() ); + } pid = start_process( &nid , process_type , processName @@ -4327,7 +4398,7 @@ bool persist_process_start( CPersistConfig *persistConfig ) , nowait , infile , outfile - , (char *)persistConfig->GetProgramName() ); + , programNameAndArgs ); if (pid > 0) { printf( "Persistent process %s created\n", processName); @@ -6930,9 +7001,12 @@ void node_up_cmd( char *cmd, char delimiter ) { if ( get_node_name( cmd_tail ) == 0 ) { - if ( copy_config_db( cmd_tail ) == 0 ) + if ( ClusterConfig.GetStorageType() == TCDBSQLITE) { - node_up( -1, cmd_tail, nowait ); + if ( copy_config_db( cmd_tail ) == 0 ) + { + node_up( -1, cmd_tail, nowait ); + } } } else diff --git a/core/sqf/monitor/linux/tcdb.cxx b/core/sqf/monitor/linux/tcdb.cxx new file mode 100644 index 0000000000..6f99195a0a --- /dev/null +++ b/core/sqf/monitor/linux/tcdb.cxx @@ -0,0 +1,478 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// @@@ 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 +#include +#include +#include + +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 ); +} diff --git a/core/sqf/monitor/linux/tcdb.h b/core/sqf/monitor/linux/tcdb.h new file mode 100644 index 0000000000..a9ee2c684b --- /dev/null +++ b/core/sqf/monitor/linux/tcdb.h @@ -0,0 +1,117 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// @@@ 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 +#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_ */ diff --git a/core/sqf/monitor/linux/sqliteconfig.cxx b/core/sqf/monitor/linux/tcdbsqlite.cxx similarity index 93% rename from core/sqf/monitor/linux/sqliteconfig.cxx rename to core/sqf/monitor/linux/tcdbsqlite.cxx index ea7ca1f4f6..d53f602e87 100644 --- a/core/sqf/monitor/linux/sqliteconfig.cxx +++ b/core/sqf/monitor/linux/tcdbsqlite.cxx @@ -29,36 +29,43 @@ using namespace std; +#include "tclog.h" +#include "tctrace.h" #include "trafconfig.h" -#include "trafconfiglog.h" -#include "trafconfigtrace.h" -#include "sqliteconfig.h" +#include "tcdbsqlite.h" + +#define MAX_PROCESS_PATH 256 /////////////////////////////////////////////////////////////////////////////// // Cluster Configuration /////////////////////////////////////////////////////////////////////////////// -CSqliteConfig::CSqliteConfig( void ) - : db_(NULL) +CTcdbSqlite::CTcdbSqlite( void ) + : CTcdbStore( TCDBSQLITE ) + , db_(NULL) { - const char method_name[] = "CSqliteConfig::CSqliteConfig"; + const char method_name[] = "CTcdbSqlite::CTcdbSqlite"; TRACE_ENTRY; + memcpy(&eyecatcher_, "TCSL", 4); + TRACE_EXIT; } -CSqliteConfig::~CSqliteConfig ( void ) +CTcdbSqlite::~CTcdbSqlite ( void ) { - const char method_name[] = "CSqliteConfig::~CSqliteConfig"; + const char method_name[] = "CTcdbSqlite::~CTcdbSqlite"; TRACE_ENTRY; + memcpy(&eyecatcher_, "tcsl", 4); + TRACE_EXIT; } // insert key into monRegKeyName table -int CSqliteConfig::AddRegistryKey( const char *key ) +int CTcdbSqlite::AddRegistryKey( const char *key ) { - const char method_name[] = "CSqliteConfig::AddRegistryKey"; + const char method_name[] = "CTcdbSqlite::AddRegistryKey"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -141,9 +148,9 @@ int CSqliteConfig::AddRegistryKey( const char *key ) } // insert key into monRegProcName table -int CSqliteConfig::AddRegistryProcess( const char *name ) +int CTcdbSqlite::AddRegistryProcess( const char *name ) { - const char method_name[] = "CSqliteConfig::AddRegistryProcess"; + const char method_name[] = "CTcdbSqlite::AddRegistryProcess"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -225,10 +232,10 @@ int CSqliteConfig::AddRegistryProcess( const char *name ) return( TCSUCCESS ); } -int CSqliteConfig::AddRegistryClusterData( const char *key - , const char *dataValue ) +int CTcdbSqlite::AddRegistryClusterData( const char *key + , const char *dataValue ) { - const char method_name[] = "CSqliteConfig::AddRegistryClusterData"; + const char method_name[] = "CTcdbSqlite::AddRegistryClusterData"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -331,11 +338,11 @@ int CSqliteConfig::AddRegistryClusterData( const char *key return( TCSUCCESS ); } -int CSqliteConfig::AddRegistryProcessData( const char *procName - , const char *key - , const char *dataValue ) +int CTcdbSqlite::AddRegistryProcessData( const char *procName + , const char *key + , const char *dataValue ) { - const char method_name[] = "CSqliteConfig::AddRegistryProcessData"; + const char method_name[] = "CTcdbSqlite::AddRegistryProcessData"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -461,11 +468,11 @@ int CSqliteConfig::AddRegistryProcessData( const char *procName return( TCSUCCESS ); } -int CSqliteConfig::AddUniqueString( int nid - , int id - , const char *uniqStr ) +int CTcdbSqlite::AddUniqueString( int nid + , int id + , const char *uniqStr ) { - const char method_name[] = "CSqliteConfig::AddUniqueString"; + const char method_name[] = "CTcdbSqlite::AddUniqueString"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -576,9 +583,9 @@ int CSqliteConfig::AddUniqueString( int nid return( TCSUCCESS ); } -int CSqliteConfig::Close( void ) +int CTcdbSqlite::Close( void ) { - const char method_name[] = "CSqliteConfig::Close"; + const char method_name[] = "CTcdbSqlite::Close"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -612,9 +619,9 @@ int CSqliteConfig::Close( void ) return( TCSUCCESS ); } -int CSqliteConfig::DeleteNodeData( int pnid ) +int CTcdbSqlite::DeleteNodeData( int pnid ) { - const char method_name[] = "CSqliteConfig::DeleteNodeData"; + const char method_name[] = "CTcdbSqlite::DeleteNodeData"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -763,9 +770,9 @@ int CSqliteConfig::DeleteNodeData( int pnid ) return( TCSUCCESS ); } -int CSqliteConfig::DeleteUniqueString( int nid ) +int CTcdbSqlite::DeleteUniqueString( int nid ) { - const char method_name[] = "CSqliteConfig::DeleteUniqueString"; + const char method_name[] = "CTcdbSqlite::DeleteUniqueString"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -847,9 +854,9 @@ int CSqliteConfig::DeleteUniqueString( int nid ) return( TCSUCCESS ); } -int CSqliteConfig::Initialize( void ) +int CTcdbSqlite::Initialize( void ) { - const char method_name[] = "CSqliteConfig::Initialize"; + const char method_name[] = "CTcdbSqlite::Initialize"; TRACE_ENTRY; if ( IsInitialized() ) @@ -927,10 +934,10 @@ int CSqliteConfig::Initialize( void ) return( TCSUCCESS ); } -int CSqliteConfig::GetNode( int nid - , node_configuration_t &nodeConfig ) +int CTcdbSqlite::GetNode( int nid + , node_configuration_t &nodeConfig ) { - const char method_name[] = "CSqliteConfig::GetNode"; + const char method_name[] = "CTcdbSqlite::GetNode"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -1071,10 +1078,10 @@ int CSqliteConfig::GetNode( int nid return( TCSUCCESS ); } -int CSqliteConfig::GetNode( const char *name - , node_configuration_t &nodeConfig ) +int CTcdbSqlite::GetNode( const char *name + , node_configuration_t &nodeConfig ) { - const char method_name[] = "CSqliteConfig::GetNode"; + const char method_name[] = "CTcdbSqlite::GetNode"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -1216,11 +1223,11 @@ int CSqliteConfig::GetNode( const char *name return( TCSUCCESS ); } -int CSqliteConfig::GetNodes( int &count - , int max - , node_configuration_t nodeConfig[] ) +int CTcdbSqlite::GetNodes( int &count + , int max + , node_configuration_t nodeConfig[] ) { - const char method_name[] = "CSqliteConfig::GetNodes"; + const char method_name[] = "CTcdbSqlite::GetNodes"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -1362,10 +1369,10 @@ int CSqliteConfig::GetNodes( int &count return( TCSUCCESS ); } -int CSqliteConfig::GetPNode( int pNid - , physical_node_configuration_t &pnodeConfig ) +int CTcdbSqlite::GetPNode( int pNid + , physical_node_configuration_t &pnodeConfig ) { - const char method_name[] = "CSqliteConfig::GetPNode"; + const char method_name[] = "CTcdbSqlite::GetPNode"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -1482,10 +1489,10 @@ int CSqliteConfig::GetPNode( int pNid return( TCSUCCESS ); } -int CSqliteConfig::GetPNode( const char *name - , physical_node_configuration_t &pnodeConfig ) +int CTcdbSqlite::GetPNode( const char *name + , physical_node_configuration_t &pnodeConfig ) { - const char method_name[] = "CSqliteConfig::GetPNode"; + const char method_name[] = "CTcdbSqlite::GetPNode"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -1600,11 +1607,11 @@ int CSqliteConfig::GetPNode( const char *name return( TCSUCCESS ); } -int CSqliteConfig::GetSNodes( int &count - , int max - , physical_node_configuration_t spareNodeConfig[] ) +int CTcdbSqlite::GetSNodes( int &count + , int max + , physical_node_configuration_t spareNodeConfig[] ) { - const char method_name[] = "CSqliteConfig::GetSNodes"; + const char method_name[] = "CTcdbSqlite::GetSNodes"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -1746,13 +1753,13 @@ int CSqliteConfig::GetSNodes( int &count return( TCSUCCESS ); } -int CSqliteConfig::GetSNodeData( int pnid - , const char *nodename - , int excfirstcore - , int exclastcore - , physical_node_configuration_t &spareNodeConfig ) +int CTcdbSqlite::GetSNodeData( int pnid + , const char *nodename + , int excfirstcore + , int exclastcore + , physical_node_configuration_t &spareNodeConfig ) { - const char method_name[] = "CSqliteConfig::GetSNodeData"; + const char method_name[] = "CTcdbSqlite::GetSNodeData"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -1888,10 +1895,10 @@ int CSqliteConfig::GetSNodeData( int pnid return( TCSUCCESS ); } -int CSqliteConfig::GetPersistProcess( const char *persistPrefix - , persist_configuration_t &persistConfig ) +int CTcdbSqlite::GetPersistProcess( const char *persistPrefix + , persist_configuration_t &persistConfig ) { - const char method_name[] = "CSqliteConfig::GetPersistProcess"; + const char method_name[] = "CTcdbSqlite::GetPersistProcess"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -2044,9 +2051,9 @@ int CSqliteConfig::GetPersistProcess( const char *persistPrefix return( TCSUCCESS ); } -int CSqliteConfig::GetPersistProcessKeys( const char *persistProcessKeys ) +int CTcdbSqlite::GetPersistProcessKeys( const char *persistProcessKeys ) { - const char method_name[] = "CSqliteConfig::GetPersistProcessKeys"; + const char method_name[] = "CTcdbSqlite::GetPersistProcessKeys"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -2141,11 +2148,11 @@ int CSqliteConfig::GetPersistProcessKeys( const char *persistProcessKeys ) return( TCSUCCESS ); } -int CSqliteConfig::GetRegistryClusterSet( int &count - , int max - , registry_configuration_t registryConfig[] ) +int CTcdbSqlite::GetRegistryClusterSet( int &count + , int max + , registry_configuration_t registryConfig[] ) { - const char method_name[] = "CSqliteConfig::GetRegistryClusterSet"; + const char method_name[] = "CTcdbSqlite::GetRegistryClusterSet"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -2269,11 +2276,11 @@ int CSqliteConfig::GetRegistryClusterSet( int &count return( TCSUCCESS ); } -int CSqliteConfig::GetRegistryProcessSet( int &count - , int max - , registry_configuration_t registryConfig[] ) +int CTcdbSqlite::GetRegistryProcessSet( int &count + , int max + , registry_configuration_t registryConfig[] ) { - const char method_name[] = "CSqliteConfig::GetRegistryProcessSet"; + const char method_name[] = "CTcdbSqlite::GetRegistryProcessSet"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -2405,9 +2412,9 @@ int CSqliteConfig::GetRegistryProcessSet( int &count return( TCSUCCESS ); } -int CSqliteConfig::GetUniqueString( int nid, int id, const char *uniqStr ) +int CTcdbSqlite::GetUniqueString( int nid, int id, const char *uniqStr ) { - const char method_name[] = "CSqliteConfig::GetUniqueString"; + const char method_name[] = "CTcdbSqlite::GetUniqueString"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -2526,11 +2533,11 @@ int CSqliteConfig::GetUniqueString( int nid, int id, const char *uniqStr ) return( TCSUCCESS ); } -int CSqliteConfig::GetUniqueStringId( int nid - , const char *uniqStr - , int &id ) +int CTcdbSqlite::GetUniqueStringId( int nid + , const char *uniqStr + , int &id ) { - const char method_name[] = "CSqliteConfig::GetUniqueStringId"; + const char method_name[] = "CTcdbSqlite::GetUniqueStringId"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -2650,9 +2657,9 @@ int CSqliteConfig::GetUniqueStringId( int nid return( TCSUCCESS ); } -int CSqliteConfig::GetUniqueStringIdMax( int nid, int &id ) +int CTcdbSqlite::GetUniqueStringIdMax( int nid, int &id ) { - const char method_name[] = "CSqliteConfig::GetUniqueStringIdMax"; + const char method_name[] = "CTcdbSqlite::GetUniqueStringIdMax"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -2748,14 +2755,14 @@ int CSqliteConfig::GetUniqueStringIdMax( int nid, int &id ) return( TCSUCCESS ); } -int CSqliteConfig::SaveLNodeData( int nid - , int pnid - , int firstCore - , int lastCore - , int processors - , int roles ) +int CTcdbSqlite::SaveLNodeData( int nid + , int pnid + , int firstCore + , int lastCore + , int processors + , int roles ) { - const char method_name[] = "CSqliteConfig::SaveLNodeData"; + const char method_name[] = "CTcdbSqlite::SaveLNodeData"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -2920,12 +2927,12 @@ int CSqliteConfig::SaveLNodeData( int nid return( TCSUCCESS ); } -int CSqliteConfig::SavePNodeData( const char *name - , int pnid - , int excludedFirstCore - , int excludedLastCore ) +int CTcdbSqlite::SavePNodeData( const char *name + , int pnid + , int excludedFirstCore + , int excludedLastCore ) { - const char method_name[] = "CSqliteConfig::SavePNodeData"; + const char method_name[] = "CTcdbSqlite::SavePNodeData"; TRACE_ENTRY; if ( !IsInitialized() ) @@ -3057,19 +3064,19 @@ int CSqliteConfig::SavePNodeData( const char *name return( TCSUCCESS ); } -void CSqliteConfig::SetLNodeData( int nid - , int pnid - , const char *nodename - , int excfirstcore - , int exclastcore - , int firstcore - , int lastcore - , int processors - , int roles - , node_configuration_t &nodeConfig ) +void CTcdbSqlite::SetLNodeData( int nid + , int pnid + , const char *nodename + , int excfirstcore + , int exclastcore + , int firstcore + , int lastcore + , int processors + , int roles + , node_configuration_t &nodeConfig ) { - const char method_name[] = "CSqliteConfig::SetLNodeData"; + const char method_name[] = "CTcdbSqlite::SetLNodeData"; TRACE_ENTRY; if ( TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST) ) @@ -3103,14 +3110,14 @@ void CSqliteConfig::SetLNodeData( int nid TRACE_EXIT; } -void CSqliteConfig::SetPNodeData( int pnid - , const char *nodename - , int excfirstcore - , int exclastcore - , physical_node_configuration_t &pnodeConfig ) +void CTcdbSqlite::SetPNodeData( int pnid + , const char *nodename + , int excfirstcore + , int exclastcore + , physical_node_configuration_t &pnodeConfig ) { - const char method_name[] = "CSqliteConfig::SetLNodeData"; + const char method_name[] = "CTcdbSqlite::SetLNodeData"; TRACE_ENTRY; if ( TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST) ) @@ -3133,11 +3140,11 @@ void CSqliteConfig::SetPNodeData( int pnid TRACE_EXIT; } -int CSqliteConfig::SetPersistProcessData( const char *persistkey - , const char *persistvalue - , persist_configuration_t &persistConfig ) +int CTcdbSqlite::SetPersistProcessData( const char *persistkey + , const char *persistvalue + , persist_configuration_t &persistConfig ) { - const char method_name[] = "CSqliteConfig::GetPersistProcessData"; + const char method_name[] = "CTcdbSqlite::GetPersistProcessData"; TRACE_ENTRY; char workValue[TC_PERSIST_KEY_MAX]; @@ -3180,6 +3187,14 @@ int CSqliteConfig::SetPersistProcessData( const char *persistkey , sizeof(persistConfig.program_name) ); goto done; } + pch = (char *) strstr( persistkey, PERSIST_PROGRAM_ARGS_KEY ); + if (pch != NULL) + { + strncpy( persistConfig.program_args + , workValue + , sizeof(persistConfig.program_args) ); + goto done; + } pch = (char *) strstr( persistkey, PERSIST_STDOUT_KEY ); if (pch != NULL) { @@ -3232,12 +3247,12 @@ int CSqliteConfig::SetPersistProcessData( const char *persistkey return( TCSUCCESS ); } -int CSqliteConfig::UpdatePNodeData( int pnid - , const char *name - , int excludedFirstCore - , int excludedLastCore ) +int CTcdbSqlite::UpdatePNodeData( int pnid + , const char *name + , int excludedFirstCore + , int excludedLastCore ) { - const char method_name[] = "CSqliteConfig::UpdatePNodeData"; + const char method_name[] = "CTcdbSqlite::UpdatePNodeData"; TRACE_ENTRY; if ( !IsInitialized() ) diff --git a/core/sqf/monitor/linux/sqliteconfig.h b/core/sqf/monitor/linux/tcdbsqlite.h similarity index 94% rename from core/sqf/monitor/linux/sqliteconfig.h rename to core/sqf/monitor/linux/tcdbsqlite.h index fdf9e673ab..5659f31692 100644 --- a/core/sqf/monitor/linux/sqliteconfig.h +++ b/core/sqf/monitor/linux/tcdbsqlite.h @@ -23,23 +23,20 @@ // /////////////////////////////////////////////////////////////////////////////// -#ifndef SQLITECONFIG_H_ -#define SQLITECONFIG_H_ +#ifndef TCDBSQLITE_H_ +#define TCDBSQLITE_H_ #include #include #include "trafconfig.h" +#include "tcdbstore.h" -#define MAX_PROCESS_PATH 256 - -#define SQLITE_DB_ACCESS_ERROR 101900101 - -class CSqliteConfig +class CTcdbSqlite : public CTcdbStore { public: - CSqliteConfig( void ); - ~CSqliteConfig( void ); + CTcdbSqlite( void ); + ~CTcdbSqlite( void ); int Close( void ); int AddRegistryKey( const char *key ); @@ -80,7 +77,7 @@ class CSqliteConfig , int &id ); int GetUniqueStringIdMax( int nid, int &id ); int Initialize( void ); - inline bool IsInitialized( void ) { return ( (db_ != NULL) ); } + inline bool IsInitialized( void ) { return( (db_ != NULL) ); } int SaveLNodeData( int nid , int pnid , int firstCore @@ -130,4 +127,4 @@ class CSqliteConfig }; -#endif /* SQLITECONFIG_H_ */ +#endif /* TCDBSQLITE_H_ */ diff --git a/core/sqf/monitor/linux/tcdbstore.cxx b/core/sqf/monitor/linux/tcdbstore.cxx new file mode 100644 index 0000000000..aed2469d9d --- /dev/null +++ b/core/sqf/monitor/linux/tcdbstore.cxx @@ -0,0 +1,55 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// @@@ 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 +#include +#include +#include + +using namespace std; + +#include "tclog.h" +#include "tctrace.h" +#include "tcdbstore.h" + +/////////////////////////////////////////////////////////////////////////////// +// Cluster Configuration +/////////////////////////////////////////////////////////////////////////////// + +CTcdbStore::CTcdbStore( TC_STORAGE_TYPE dbStorageType ) + : dbStorageType_(dbStorageType) +{ + const char method_name[] = "CTcdbStore::CTcdbStore"; + TRACE_ENTRY; + TRACE_EXIT; +} + +CTcdbStore::~CTcdbStore ( void ) +{ + const char method_name[] = "CTcdbStore::~CTcdbStore"; + TRACE_ENTRY; + TRACE_EXIT; +} + diff --git a/core/sqf/monitor/linux/tcdbstore.h b/core/sqf/monitor/linux/tcdbstore.h new file mode 100644 index 0000000000..50814e0666 --- /dev/null +++ b/core/sqf/monitor/linux/tcdbstore.h @@ -0,0 +1,113 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// @@@ 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 TCDBSTORE_H_ +#define TCDBSTORE_H_ + +#include "zookeeper/zookeeper.h" +#include "trafconfig.h" + +using namespace std; + + +// +// Trafodion Configuration Database Adaptor (CTcdbStore class) +// +// Implements common interface to storage classes used by the +// Trafodion Configuration API (trafconfig.cxx/.h). +// + +class CTcdbStore +{ +protected: + int eyecatcher_; // Debuggging aid -- leave as first + // member variable of the class +public: + + CTcdbStore( TC_STORAGE_TYPE dbStorageType ); + virtual ~CTcdbStore( void ); + + virtual int Close( void ) = 0; + virtual int AddRegistryKey( const char *key ) = 0; + virtual int AddRegistryProcess( const char *name ) = 0; + virtual int AddRegistryClusterData( const char *key + , const char *dataValue ) = 0; + virtual int AddRegistryProcessData( const char *procName + , const char *key + , const char *dataValue ) = 0; + virtual int AddUniqueString( int nid + , int id + , const char *uniqStr ) = 0; + virtual int DeleteNodeData( int pnid ) = 0; + virtual int DeleteUniqueString( int nid ) = 0; + virtual int GetNode( int nid + , node_configuration_t &nodeConfig ) = 0; + virtual int GetNode( const char *name + , node_configuration_t &nodeConfig ) = 0; + virtual int GetNodes( int &count + , int max + , node_configuration_t nodeConfig[] ) = 0; + virtual int GetPNode( int pnid + , physical_node_configuration_t &pnodeConfig ) = 0; + virtual int GetPNode( const char *name + , physical_node_configuration_t &pnodeConfig ) = 0; + virtual int GetSNodes( int &count + , int max + , physical_node_configuration_t pNodeConfig[] ) = 0; + virtual int GetPersistProcess( const char *persistPrefix + , persist_configuration_t &persistConfig ) = 0; + virtual int GetPersistProcessKeys( const char *persistProcessKeys ) = 0; + virtual int GetRegistryClusterSet( int &count + , int max + , registry_configuration_t registryConfig[] ) = 0; + virtual int GetRegistryProcessSet( int &count + , int max + , registry_configuration_t registryConfig[] ) = 0; + virtual int GetUniqueString( int nid, int id, const char *uniqStr ) = 0; + virtual int GetUniqueStringId( int nid + , const char *uniqStr + , int &id ) = 0; + virtual int GetUniqueStringIdMax( int nid, int &id ) = 0; + inline TC_STORAGE_TYPE GetStorageType( void ) { return( dbStorageType_ ); } + virtual int Initialize( void ) = 0; + virtual bool IsInitialized( void ) = 0; + virtual int SaveLNodeData( int nid + , int pnid + , int firstCore + , int lastCore + , int processors + , int roles ) = 0; + virtual int SavePNodeData( const char *name + , int pnid + , int excludedFirstCore + , int excludedLastCore ) = 0; + +protected: + TC_STORAGE_TYPE dbStorageType_; +private: +}; + + +#endif /* TCDBSTORE_H_ */ diff --git a/core/sqf/monitor/linux/tcdbzstore.cxx b/core/sqf/monitor/linux/tcdbzstore.cxx new file mode 100644 index 0000000000..4422e22f2b --- /dev/null +++ b/core/sqf/monitor/linux/tcdbzstore.cxx @@ -0,0 +1,2192 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// @@@ 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 +#include +#include + +using namespace std; + +#include "type2str.h" +#include "tclog.h" +#include "tctrace.h" +#include "trafconfig.h" +#include "tcdbzstore.h" + +CTcdbZstore::CTcdbZstore( void ) + : CTcdbStore( TCDBZOOKEEPER ) +{ + const char method_name[] = "CTcdbZstore::CTcdbZstore"; + TRACE_ENTRY; + + memcpy(&eyecatcher_, "TCZS", 4); + + TRACE_EXIT; +} + +CTcdbZstore::~CTcdbZstore ( void ) +{ + const char method_name[] = "CTcdbZstore::~CTcdbZstore"; + TRACE_ENTRY; + + memcpy(&eyecatcher_, "tczs", 4); + + TRACE_EXIT; +} + +int CTcdbZstore::AddRegistryKey( const char *key ) +{ + const char method_name[] = "CTcdbZstore::AddRegistryKey"; + TRACE_ENTRY; + + key = key; // Make compiler happy! + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + // Do nothing, the key (znode) will be added along with the value (data) + // on a subsequent method invocation of AddRegistryClusterData() + // or AddRegistryProcessData() + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::AddRegistryProcess( const char *procName ) +{ + const char method_name[] = "CTcdbZstore::AddRegistryProcess"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + // /TRAFODION_REGISTRY_PROCESS_ZNODE + // / + stringstream ss; + ss.str( "" ); + ss << regProcessZNodePath_ << "/" + << procName; + string znodePath(ss.str()); + + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Adding registry process znode: %s\n" + , method_name, __LINE__, znodePath.c_str()); + } + + int rc = zConfig_.CreateConfigZNode( znodePath.c_str(), NULL, 0 ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::AddRegistryClusterData( const char *key + , const char *value ) +{ + const char method_name[] = "CTcdbZstore::AddRegistryClusterData"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + // /TRAFODION_REGISTRY_CLUSTER_ZNODE + // / () + stringstream ss; + ss.str( "" ); + ss << regClusterZNodePath_ << "/" + << key; + string znodePath(ss.str()); + + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Adding registry cluster znode: %s (%s)\n" + , method_name, __LINE__, znodePath.c_str(), value); + } + + int rc = zConfig_.CreateConfigZNode( znodePath.c_str(), value, 0 ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::AddRegistryProcessData( const char *procName + , const char *key + , const char *value ) +{ + const char method_name[] = "CTcdbZstore::AddRegistryProcessData"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + // /TRAFODION_REGISTRY_PROCESS_ZNODE + // / + // / () + stringstream ss; + ss.str( "" ); + ss << regProcessZNodePath_ << "/" + << procName << "/" + << key; + string znodePath(ss.str()); + + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Adding registry process znode: %s (%s)\n" + , method_name, __LINE__, znodePath.c_str(), value); + } + + int rc = zConfig_.CreateConfigZNode( znodePath.c_str(), value, 0 ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::AddUniqueString( int nid + , int id + , const char *uniqueStr ) +{ + const char method_name[] = "CTcdbZstore::AddUniqueString"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + stringstream ss; + +#if 1 + // /TRAFODION_REGISTRY_USTRING_ZNODE + // / + // / () + // . . . + // / () + ss.str( "" ); + ss << regUStringZNodePath_ << "/" + << nid; + string znodePath(ss.str()); + + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Adding registry unique string znode: %s\n" + , method_name, __LINE__, znodePath.c_str()); + } + + rc = MakeConfigZNode( znodePath.c_str() ); + if ( rc && rc != ZNODEEXISTS ) + { + TRACE_EXIT; + return(rc); + } + + ss.str( "" ); + ss << regUStringZNodePath_ << "/" + << nid << "/" + << id; + znodePath = ss.str(); + +#else + // /TRAFODION_REGISTRY_USTRING_ZNODE + // / () + ss.str( "" ); + ss << regUStringZNodePath_ << "/" + << id; + string znodePath(ss.str()); + +#endif + + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Adding registry unique string znode: %s (%s)\n" + , method_name, __LINE__, znodePath.c_str(), uniqueStr); + } + + int rc = zConfig_.CreateConfigZNode( znodePath.c_str(), uniqueStr, 0 ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST)) + { + trace_printf("%s@%d inserting unique string nid=%d id=%d into " + "monRegUniqueStrings\n", method_name, __LINE__, + nid, id); + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::Close( void ) +{ + const char method_name[] = "CTcdbZstore::Close"; + TRACE_ENTRY; + + if ( ! IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + int rc = zConfig_.Close(); + + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper store session ended! (%s)\n" + , method_name, __LINE__, tc_errmsg( rc )); + } + + TRACE_EXIT; + return( rc ); +} + +int CTcdbZstore::DeleteNodeData( int pnid ) +{ + const char method_name[] = "CTcdbZstore::DeleteNodeData"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + // + // Get pnodesZNodePath_ children znodes + // znode=, data=(::) + // Scan each znode for matching + // Save matching pnode znode and + // Get clusterZNodePath_ children znodes + // znode=, data=() + // Scan each znode's data for matching + // Save matching cluster znode + // Get lnodesZNodePath_ children znodes + // znode=, data=(::::) + // Scan each znode's data for matching + // Save matching lnode znode + // Get snodesZNodePath_ children znodes + // znode=, data=() + // Scan each znode for matching + // Save matching snode znode + // + // Delete saved cluster znode + // Delete saved pnode znode + // Delete saved lnode znode + // Delete saved snode znode + // + + stringstream ss; + ss.str( "" ); + ss << lnodesZNodePath_ << "/" + << nid; + string znodePath(ss.str()); + + if (TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Deleting logical node znode: %s\n" + , method_name, __LINE__ + , znodePath.c_str() ); + } + + int rc = zConfig_.DeleteConfigZNode( znodePath.c_str() ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + if (TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d delete from lnode, pnode values (pNid=%d)\n" + , method_name, __LINE__ + , pnid ); + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::DeleteUniqueString( int nid ) +{ + const char method_name[] = "CTcdbZstore::DeleteUniqueString"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d delete from monRegUniqueStrings values (nid=%d)\n" + , method_name, __LINE__ + , nid ); + } + + // + // Get regUStringZNodePath_ children znodes + // znode=, data=() + // Loop on children + // Delete regUString znode + // + // NOTE: This will delete all ustrings on cluster, not just a give nid's + // + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::GetNode( int nid + , node_configuration_t &nodeConfig ) +{ + const char method_name[] = "CTcdbZstore::GetNode"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + // + // List a node's configuration by + // + // Get lnodesZNodePath_ children znodes + // znode=, data=(::::) + // Scan each lnodes znode for matching + // Save matching lnodes znode's data + // Get pnodesZNodePath_ children znodes + // znode=, data=(::) + // Scan each pnodes znode for matching + // Save matching pnode znode's data + // Return saved lnodes znode's and pnode znode's data + // + + int rc; + int firstcore = -1; + int lastcore = -1; + int excfirstcore = -1; + int exclastcore = -1; + int lnid = -1; + int pnid = -1; + int processors = 0; + int roles; + + SetLNodeData( lnid + , pnid + , nodename + , excfirstcore + , exclastcore + , firstcore + , lastcore + , processors + , roles + , nodeConfig ); + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::GetNode( const char *name + , node_configuration_t &nodeConfig ) +{ + const char method_name[] = "CTcdbZstore::GetNode"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + // + // List a node's configuration by + // + // Get clusterZNodePath_ children znodes + // znode=, data=() + // Scan each cluster znode for matching + // Save matching cluster znode's data + // Get pnodesZNodePath_ children znodes + // znode=, data=(::) + // Scan each pnodes znode for matching + // Save matching pnode znode's data + // Get lnodesZNodePath_ children znodes + // znode=, data=(::::) + // Scan each lnodes znode's data for matching + // Save matching lnodes znode's data + // Return saved lnodes znode's and pnode znode's data + // + + int rc; + int firstcore = -1; + int lastcore = -1; + int excfirstcore = -1; + int exclastcore = -1; + int nid = -1; + int pnid = -1; + int processors = 0; + int roles; + + pnid = sqlite3_column_int(prepStmt, 0); + nid = sqlite3_column_int(prepStmt, 1); + nodename = (const char *) sqlite3_column_text(prepStmt, 2); + firstcore = sqlite3_column_int(prepStmt, 3); + lastcore = sqlite3_column_int(prepStmt, 4); + excfirstcore = sqlite3_column_int(prepStmt, 5); + exclastcore = sqlite3_column_int(prepStmt, 6); + processors = sqlite3_column_int(prepStmt, 7); + roles = sqlite3_column_int(prepStmt, 8); + SetLNodeData( nid + , pnid + , nodename + , excfirstcore + , exclastcore + , firstcore + , lastcore + , processors + , roles + , nodeConfig ); + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::GetNodes( int &count + , int max + , node_configuration_t nodeConfig[] ) +{ + const char method_name[] = "CTcdbZstore::GetNodes"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + // + // List all logical nodes, limited by max + // + + sqlStmt = "select p.pNid, l.lNid, p.nodeName, l.firstCore, l.lastCore," + " p.excFirstCore, p.excLastCore, l.processors, l.roles" + " from pnode p, lnode l where p.pNid = l.pNid"; + + // + // Loop on lnodesZNodePath_ children + // Get lnodesZNodePath_ children znodes + // znode=, data=(::::) + // Scan each lnodes znode for matching + // Save matching lnodes znode's data + // Get pnodesZNodePath_ children znodes + // znode=, data=(::) + // Scan each pnodes znode for matching + // Save matching pnode znode's data + // Save lnodes znode's and pnode znode's data in nodeConfig[nodeCount] + // + + int rc; + int firstcore = -1; + int lastcore = -1; + int excfirstcore = -1; + int exclastcore = -1; + int nid = -1; + int pnid = -1; + int processors = 0; + int roles; + int nodeCount = 0; + + while ( 1 ) + { + if ( nodeCount < max ) + { + pnid = sqlite3_column_int(prepStmt, 0); + nid = sqlite3_column_int(prepStmt, 1); + nodename = (const char *) sqlite3_column_text(prepStmt, 2); + firstcore = sqlite3_column_int(prepStmt, 3); + lastcore = sqlite3_column_int(prepStmt, 4); + excfirstcore = sqlite3_column_int(prepStmt, 5); + exclastcore = sqlite3_column_int(prepStmt, 6); + processors = sqlite3_column_int(prepStmt, 7); + roles = sqlite3_column_int(prepStmt, 8); + SetLNodeData( nid + , pnid + , nodename + , excfirstcore + , exclastcore + , firstcore + , lastcore + , processors + , roles + , nodeConfig[nodeCount] ); + nodeCount++; + } + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::GetPNode( int pNid + , physical_node_configuration_t &pnodeConfig ) +{ + const char method_name[] = "CTcdbZstore::GetPNode"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + int rc; + int excfirstcore = -1; + int exclastcore = -1; + int pnid = -1; + + // + // List a node's physical configuration by + // + + sqlStmt = "select p.pNid, p.nodeName, p.excFirstCore, p.excLastCore" + " from pnode p where p.pNid = ?"; + + // + // Get pnodesZNodePath_/ znode + // znode=, data=(::) + // Save matching pnode znode's data + // Return saved pnode znode's data + // + + pnid = sqlite3_column_int(prepStmt, 0); + nodename = (const char *) sqlite3_column_text(prepStmt, 1); + excfirstcore = sqlite3_column_int(prepStmt, 2); + exclastcore = sqlite3_column_int(prepStmt, 3); + SetPNodeData( pnid + , nodename + , excfirstcore + , exclastcore + , pnodeConfig ); + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::GetPNode( const char *name + , physical_node_configuration_t &pnodeConfig ) +{ + const char method_name[] = "CTcdbZstore::GetPNode"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + int rc; + int excfirstcore = -1; + int exclastcore = -1; + int pnid = -1; + + // + // List a node's physical configuration by + // + + sqlStmt = "select p.pNid, p.nodeName, p.excFirstCore, p.excLastCore" + " from pnode p where p.nodeName = ?"; + + // + // Get clusterZNodePath_/ znode + // znode=, data=() + // Get pnodesZNodePath_/ znode + // znode=, data=(::) + // Save matching pnode znode's data + // Return saved pnode znode's data + // + + pnid = sqlite3_column_int(prepStmt, 0); + nodename = (const char *) sqlite3_column_text(prepStmt, 1); + excfirstcore = sqlite3_column_int(prepStmt, 2); + exclastcore = sqlite3_column_int(prepStmt, 3); + SetPNodeData( pnid + , nodename + , excfirstcore + , exclastcore + , pnodeConfig ); + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::GetSNodes( int &count + , int max + , physical_node_configuration_t spareNodeConfig[] ) +{ + const char method_name[] = "CTcdbZstore::GetSNodes"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + // + // List all spare nodes, limited by max + // + + sqlStmt = "select p.pNid, p.nodeName, p.excFirstCore, p.excLastCore," + " s.spNid " + " from pnode p, snode s where p.pNid = s.pNid"; + + // + // Loop on snodesZNodePath_ znodes + // Get pnodesZNodePath_/ znode's data + // znode=, data=(::) + // Save pnode znode's data IN spareNodeConfig[snodeCount] + // Loop on each snodesZNodePath_/ children + // Save in spareNodeConfig[snodeCount].spare_pnid[spareCount] + // + + int rc; + int pnid = -1; + int excfirstcore = -1; + int exclastcore = -1; + int snodeCount = 0; + + // Process spare nodes + while ( 1 ) + { + if ( snodeCount < max ) + { + pnid = sqlite3_column_int(prepStmt, 0); + nodename = (const char *) sqlite3_column_text(prepStmt, 1); + excfirstcore = sqlite3_column_int(prepStmt, 2); + exclastcore = sqlite3_column_int(prepStmt, 3); + if ( ! GetSNodeData( pnid + , nodename + , excfirstcore + , exclastcore + , spareNodeConfig[snodeCount] ) ) + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf) + , "[%s], Error: Invalid node configuration\n" + , method_name); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_CRIT, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + snodeCount++; + } + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::GetSNodeData( int pnid + , const char *nodename + , int excfirstcore + , int exclastcore + , physical_node_configuration_t &spareNodeConfig ) +{ + const char method_name[] = "CTcdbZstore::GetSNodeData"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + int rc; + const char *sqlStmt; + sqlite3_stmt *prepStmt = NULL; + + if ( TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST) ) + { + trace_printf( "%s@%d pnid=%d, name=%s, excluded cores=(%d:%d)\n" + , method_name, __LINE__ + , pnid + , nodename + , excfirstcore + , exclastcore ); + } + + spareNodeConfig.pnid = pnid; + strncpy( spareNodeConfig.node_name + , nodename + , sizeof(spareNodeConfig.node_name) ); + spareNodeConfig.excluded_first_core = excfirstcore; + spareNodeConfig.excluded_last_core = exclastcore; + + // Select all spared nodes configured for this spare node + sqlStmt = "select p.pNid, s.spNid" + " from pnode p, snode s" + " where p.pNid = s.pNid and p.pNid = ?"; + + rc = sqlite3_prepare_v2( db_ + , sqlStmt + , strlen(sqlStmt)+1 + , &prepStmt + , NULL); + if ( rc != SQLITE_OK ) + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf) + , "[%s] prepare (%s) failed, error: %s\n" + , method_name, sqlStmt, sqlite3_errmsg(db_) ); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_CRIT, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + else + { // Set pnid in prepared statement + rc = sqlite3_bind_int(prepStmt, 1, pnid ); + if ( rc != SQLITE_OK ) + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf), + "[%s] sqlite3_bind_int(pnid) failed, error: %s\n" + , method_name, sqlite3_errmsg(db_) ); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_CRIT, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + } + + int spnid; + int sparedpnid; + int spareCount = 0; + + // Process spare nodes + while ( 1 ) + { + rc = sqlite3_step( prepStmt ); + if ( rc == SQLITE_ROW ) + { // Process row + int colCount = sqlite3_column_count(prepStmt); + if ( TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST) ) + { + trace_printf("%s@%d sqlite3_column_count=%d\n", + method_name, __LINE__, colCount); + for (int i=0; i () + stringstream ss; + ss.str( "" ); + ss << regClusterZNodePath_; + string znodePath(ss.str()); + + int rc = zConfig_.GetConfigZNodeChildren( znodePath, ®Keys ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + if ( max == 0 ) + { + // Just return the count + entryNum = regKeys.count; + FreeStringVector( ®Keys ); + } + else if ( regKeys.count > 0 ) + { + for (int i = 0; i < regKeys.count ; i++ ) + { + if ( entryNum < max ) + { + // Get the value from: + // /trafodion/instance/registry/cluster/ () + rc = zConfig_.GetConfigZNodeData( regKeys.data[i] + , registryConfig[entryNum].value ) + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + strncpy( keyString, (const char *)regKeys.data[i], sizeof(keyString) ); + pch = (char *) strstr( keyString, TRAFODION_REGISTRY_CLUSTER_ZNODE ); + if (pch != NULL) + { + // Set key name + token1 = strtok( ++pch, delimBSlash ); + if (token1) + { + key = token1; + } + } + + if ( TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST) ) + { + trace_printf( "%s@%d entry %d: group=%s key=%s, value=%s\n" + , method_name, __LINE__ + , entryNum, group, key, value); + } + + strncpy( registryConfig[entryNum].scope, (const char *)group, TC_REGISTRY_KEY_MAX ); + strncpy( registryConfig[entryNum].key, (const char *)key, TC_REGISTRY_KEY_MAX ); + ++entryNum; + } + else + { + count = entryNum; + return( TCDBTRUNCATE ); + } + } + + FreeStringVector( ®Keys ); + } + + count = entryNum; + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::GetRegistryProcessSet( int &count + , int max + , registry_configuration_t registryConfig[] ) +{ + const char method_name[] = "CTcdbZstore::GetRegistryProcessSet"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Getting registry process set\n" + , method_name, __LINE__, znodePath.c_str()); + } + + char processString[TC_REGISTRY_KEY_MAX]; + char keyString[TC_REGISTRY_KEY_MAX]; + char *pch; + char *token1; + const char *group; + const char *key; + static const char *delimBSlash = "/"; + int entryNum = 0; + struct String_vector processNames; // Children znode paths + struct String_vector regKeys; // Children znode paths + + count = 0; + + // TRAFODION_REGISTRY_PROCESS_ZNODE + // / + // / () + stringstream ss; + ss.str( "" ); + ss << regClusterZNodePath_; + string znodePath(ss.str()); + + // /trafodion/instance/registry/process/ + int rc = zConfig_.GetConfigZNodeChildren( znodePath, &processNames ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + if ( processNames.count > 0 ) + { + strncpy( processString, (const char *)processNames.data[i], sizeof(processString) ); + pch = (char *) strstr( processString, TRAFODION_REGISTRY_PROCESS_ZNODE ); + if (pch != NULL) + { + // Set process name group + token1 = strtok( ++pch, delimBSlash ); + if (token1) + { + group = token1; + } + } + + // Get the keys for each process name + for (int i = 0; i < processNames.count ; i++ ) + { + // /trafodion/instance/registry/process// + int rc = zConfig_.GetConfigZNodeChildren( processNames.data[i], ®Keys ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + if ( max == 0 ) + { + // Just return the count + entryNum += regKeys.count; + FreeStringVector( ®Keys ); + } + else if ( regKeys.count > 0 ) + { + for (int j = 0; i < regKeys.count ; j++ ) + { + if ( entryNum < max ) + { + // Get the value from: + // /trafodion/instance/registry/process// () + rc = zConfig_.GetConfigZNodeData( regKeys.data[j] + , registryConfig[entryNum].value ) + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + strncpy( keyString, (const char *)regKeys.data[i], sizeof(keyString) ); + pch = (char *) strstr( keyString, TRAFODION_REGISTRY_CLUSTER_ZNODE ); + if (pch != NULL) + { + // Set key name + token1 = strtok( ++pch, delimBSlash ); + if (token1) + { + key = token1; + } + } + + if ( TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST) ) + { + trace_printf( "%s@%d entry %d: group=%s key=%s, value=%s\n" + , method_name, __LINE__ + , entryNum, group, key, value); + } + + strncpy( registryConfig[entryNum].scope, (const char *)group, TC_REGISTRY_KEY_MAX ); + strncpy( registryConfig[entryNum].key, (const char *)key, TC_REGISTRY_KEY_MAX ); + ++entryNum; + } + else + { + count = entryNum; + return( TCDBTRUNCATE ); + } + } + + FreeStringVector( ®Keys ); + } + } + + FreeStringVector( &processNames ); + } + + count = entryNum; + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::GetUniqueString( int nid, int id, const char *uniqStr ) +{ + const char method_name[] = "CTcdbZstore::GetUniqueString"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + stringstream ss; + ss.str( "" ); + +#if 1 + // /TRAFODION_REGISTRY_USTRING_ZNODE + // / + // / () + ss << regUStringZNodePath_ << "/" + << nid << "/" + << id; + string znodePath(ss.str()); + + // Get the value from: + // /trafodion/instance/registry/ustring// () +#else + // /TRAFODION_REGISTRY_USTRING_ZNODE + // / () + ss << regUStringZNodePath_ << "/" + << id; + string znodePath(ss.str()); + + // Get the value from: + // /trafodion/instance/registry/ustring/ () +#endif + + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Getting unique string: znodePath=%d\n" + , method_name, __LINE__, znodePath.c_str()); + } + + int rc = zConfig_.GetConfigZNodeData( znodePath.c_str(), uniqStr ) + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::GetUniqueStringId( int nid + , const char *uniqStr + , int &id ) +{ + const char method_name[] = "CTcdbZstore::GetUniqueStringId"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Getting unique string id: nid=%d string=%s\n" + , method_name, __LINE__, nid, uniqStr); + } + + char uStringValue[TC_UNIQUE_STRING_VALUE_MAX]; + char keyString[TC_REGISTRY_KEY_MAX]; + char *pch; + char *token1; + const char *key; + int diff; + static const char *delimBSlash = "/"; + struct String_vector regKeys; // Children znode paths + + stringstream ss; + ss.str( "" ); + +#if 1 + // /TRAFODION_REGISTRY_USTRING_ZNODE + // / + // / () + ss << regUStringZNodePath_ << "/" + << nid << "/" + << id; + string znodePath(ss.str()); + + // Get the value from: + // /trafodion/instance/registry/ustring// () +#else + // /TRAFODION_REGISTRY_USTRING_ZNODE + // / () + ss << regUStringZNodePath_ << "/" + << id; + string znodePath(ss.str()); + + // Get the value from: + // /trafodion/instance/registry/ustring/ () +#endif + + int rc = zConfig_.GetConfigZNodeChildren( znodePath, ®Keys ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + if ( regKeys.count > 0 ) + { + for (int i = 0; i < regKeys.count ; i++ ) + { + // Get the value from: + // /trafodion/instance/registry/ustring// () + // or + // /trafodion/instance/registry/ustring/ () + rc = zConfig_.GetConfigZNodeData( regKeys.data[i], uStringValue ) + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + if ( TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST) ) + { + trace_printf( "%s@%d znodePath=%s\nuniqStr=%s\nvalue=%s\n" + , method_name, __LINE__ + , regKeys.data[i], uniqStr, uStringValue); + } + + diff = strncpy( (const char *)uniqStr + , (const char *)uStringValue + , TC_UNIQUE_STRING_VALUE_MAX ); + if ( diff == 0 ) + { + // /trafodion/instance/registry/ustring/[/] () + strncpy( keyString, (const char *)regKeys.data[i], sizeof(keyString) ); + // /ustring[/]/ () + pch = (char *) strstr( keyString, TRAFODION_REGISTRY_USTRING_ZNODE ); + if (pch != NULL) + { +#if 1 + // /ustring// () + pch = strtok( ++pch, delimBSlash ); + if (pch != NULL) + { + // // () + // Set the id + token1 = strtok( ++pch, delimBSlash ); + if (token1) + { + key = token1; + } + } +#else + // /ustring/ () + // Set the id + token1 = strtok( ++pch, delimBSlash ); + if (token1) + { + key = token1; + } +#endif + } + } + } + + FreeStringVector( ®Keys ); + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::GetUniqueStringIdMax( int nid, int &id ) +{ + const char method_name[] = "CTcdbZstore::GetUniqueStringIdMax"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + int result = 0; + int rc; + const char *sqlStmt; + sqlStmt = "select max(id) from monRegUniqueStrings where nid=?"; + + sqlite3_stmt * prepStmt; + rc = sqlite3_prepare_v2( db_, sqlStmt, strlen(sqlStmt)+1, &prepStmt, + NULL); + if ( rc != SQLITE_OK ) + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf) + , "[%s] prepare (%s) failed, error: %s\n" + , method_name, sqlStmt, sqlite3_errmsg(db_) ); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_ERR, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + else + { + rc = sqlite3_bind_int( prepStmt, 1, nid ); + if ( rc != SQLITE_OK ) + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf), + "[%s] sqlite3_bind_int(nid) failed, error: %s\n" + , method_name, sqlite3_errmsg(db_) ); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_CRIT, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + + rc = sqlite3_step( prepStmt ); + + if ( rc == SQLITE_ROW ) + { + result = sqlite3_column_int(prepStmt, 0); + id = result; + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST)) + { + trace_printf("%s@%d found max(id)=%d for nid=%d in " + "monRegUniqueStrings\n", method_name, __LINE__, + result, nid); + } + } + else if ( rc == SQLITE_DONE ) + { + if ( prepStmt != NULL ) + { + sqlite3_finalize( prepStmt ); + } + return( TCDBNOEXIST ); + } + else + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf) + , "[%s] (%s) failed, nid=%d, error: %s\n" + , method_name, sqlStmt, nid, sqlite3_errmsg(db_) ); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_ERR, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + } + + if ( prepStmt != NULL ) + { + sqlite3_finalize( prepStmt ); + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::Initialize( void ) +{ + const char method_name[] = "CTcdbZstore::Initialize"; + TRACE_ENTRY; + + if ( IsInitialized() ) + { + return( TCALREADYINIT ); + } + + TRACE_EXIT; + return( zConfig_.InitializeZConfig() ); +} + +bool CTcdbZstore::IsInitialized( void ) +{ + return ( (ZHandle != 0) ); +} + +int CTcdbZstore::SaveLNodeData( int nid + , int pnid + , int firstCore + , int lastCore + , int processors + , int roles ) +{ + const char method_name[] = "CTcdbZstore::SaveLNodeData"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + stringstream ss; + ss.str( "" ); + ss << lnodesZNodePath_ << "/" + << nid; + string znodePath(ss.str()); + ss.str( "" ); + ss << pnid << ":" + << processors << ":" + << roles << ":" + << firstCore << ":" + << lastCore; + string znodeData(ss.str()); + + if (TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Adding logical node znode: %s\n" + " (pnid=%d, processors=%d, roles=%d, firstCore=%d, lastCore=%d )\n" + " (%s)\n" + , method_name, __LINE__ + , znodePath.c_str() + , pnid + , processors + , roles + , firstCore + , lastCore + , znodeData.c_str() ); + } + + int rc = zConfig_.CreateConfigZNode( znodePath.c_str(), znodeData.c_str(), 0 ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::SavePNodeData( const char *name + , int pnid + , int excludedFirstCore + , int excludedLastCore ) +{ + const char method_name[] = "CTcdbZstore::SavePNodeData"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + stringstream ss; + + // /TRAFODION_CLUSTER_ZNODE [physical node] + ss.str( "" ); + ss << clusterZNodePath_ << "/" + << name; + string znodePath(ss.str()); + + // / () + ss.str( "" ); + ss << pnid; + string znodeData(ss.str()); + + if (TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Adding cluster node znode: %s\n" + " (pNid=%d)\n" + " (%s)\n" + , method_name, __LINE__ + , znodePath.c_str() + , pnid + , znodeData.c_str() ); + } + + + int rc = zConfig_.CreateConfigZNode( znodePath.c_str(), znodeData.c_str(), 0 ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + // /TRAFODION_PNODES_ZNODE [physical node] + ss.str( "" ); + ss << pnodesZNodePath_ << "/" + << pnid; + znodePath = ss.str(); + + // / (::) + ss.str( "" ); + ss << name << ":" + << excludedFirstCore << ":" + << excludedLastCore; + znodeData = ss.str(); + + if (TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d Adding physical node znode: %s\n" + " (hostname=%s, excFirstCore=%d, excLastCore=%d)\n" + " (%s)\n" + , method_name, __LINE__ + , znodePath.c_str() + , name + , excludedFirstCore + , excludedLastCore + , znodeData.c_str() ); + } + + + int rc = zConfig_.CreateConfigZNode( znodePath.c_str(), znodeData.c_str(), 0 ); + if ( rc != ZOK ) + { + TRACE_EXIT; + return( TCDBOPERROR ); + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + +void CTcdbZstore::SetLNodeData( int nid + , int pnid + , const char *nodename + , int excfirstcore + , int exclastcore + , int firstcore + , int lastcore + , int processors + , int roles + , node_configuration_t &nodeConfig ) +{ + const char method_name[] = "CTcdbZstore::SetLNodeData"; + TRACE_ENTRY; + + if ( TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST) ) + { + 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__ + , nid + , pnid + , nodename + , excfirstcore + , exclastcore + , firstcore + , lastcore + , processors + , roles ); + } + + nodeConfig.nid = nid; + nodeConfig.pnid = pnid; + strncpy( nodeConfig.node_name + , nodename + , sizeof(nodeConfig.node_name) ); + nodeConfig.excluded_first_core = excfirstcore; + nodeConfig.excluded_last_core = exclastcore; + nodeConfig.first_core = firstcore; + nodeConfig.last_core = lastcore; + nodeConfig.processors = processors; + nodeConfig.roles = roles; + + TRACE_EXIT; +} + +void CTcdbZstore::SetPNodeData( int pnid + , const char *nodename + , int excfirstcore + , int exclastcore + , physical_node_configuration_t &pnodeConfig ) + +{ + const char method_name[] = "CTcdbZstore::SetLNodeData"; + TRACE_ENTRY; + + if ( TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST) ) + { + trace_printf( "%s@%d pnid=%d, name=%s, excluded cores=(%d:%d)\n" + , method_name, __LINE__ + , pnid + , nodename + , excfirstcore + , exclastcore ); + } + + pnodeConfig.pnid = pnid; + strncpy( pnodeConfig.node_name + , nodename + , sizeof(pnodeConfig.node_name) ); + pnodeConfig.excluded_first_core = excfirstcore; + pnodeConfig.excluded_last_core = exclastcore; + + TRACE_EXIT; +} + +int CTcdbZstore::SetPersistProcessData( const char *persistkey + , const char *persistvalue + , persist_configuration_t &persistConfig ) +{ + const char method_name[] = "CTcdbZstore::GetPersistProcessData"; + TRACE_ENTRY; + + char workValue[TC_PERSIST_KEY_MAX]; + char *pch; + char *token1; + char *token2; + static const char *delimNone = "\0"; + static const char *delimComma = ","; + + if ( TcTraceSettings & (TC_TRACE_PERSIST | TC_TRACE_REQUEST) ) + { + trace_printf( "%s@%d persistKey=%s, persistValue=%s\n" + , method_name, __LINE__ + , persistkey, persistvalue ); + } + + strncpy( workValue, persistvalue, sizeof(workValue) ); + + pch = (char *) strstr( persistkey, PERSIST_PROCESS_NAME_KEY ); + if (pch != NULL) + { + strncpy( persistConfig.process_name + , workValue + , sizeof(persistConfig.process_name) ); + goto done; + } + pch = (char *) strstr( persistkey, PERSIST_PROCESS_TYPE_KEY ); + if (pch != NULL) + { + strncpy( persistConfig.process_type + , workValue + , sizeof(persistConfig.process_type) ); + goto done; + } + pch = (char *) strstr( persistkey, PERSIST_PROGRAM_NAME_KEY ); + if (pch != NULL) + { + strncpy( persistConfig.program_name + , workValue + , sizeof(persistConfig.program_name) ); + goto done; + } + pch = (char *) strstr( persistkey, PERSIST_PROGRAM_ARGS_KEY ); + if (pch != NULL) + { + strncpy( persistConfig.program_args + , workValue + , sizeof(persistConfig.program_args) ); + goto done; + } + pch = (char *) strstr( persistkey, PERSIST_STDOUT_KEY ); + if (pch != NULL) + { + strncpy( persistConfig.std_out + , workValue + , sizeof(persistConfig.std_out) ); + goto done; + } + pch = (char *) strstr( persistkey, PERSIST_REQUIRES_DTM ); + if (pch != NULL) + { + persistConfig.requires_DTM = (strcasecmp(workValue,"Y") == 0) + ? true : false; + goto done; + } + pch = (char *) strstr( persistkey, PERSIST_RETRIES_KEY ); + if (pch != NULL) + { + // Set retries + token1 = strtok( workValue, delimComma ); + if (token1) + { + persistConfig.persist_retries = atoi(token1); + } + // Set time window + token2 = strtok( NULL, delimNone ); + if (token2) + { + persistConfig.persist_window = atoi(token2); + } + goto done; + } + pch = (char *) strstr( persistkey, PERSIST_ZONES_KEY ); + if (pch != NULL) + { + strncpy( persistConfig.persist_zones + , workValue + , sizeof(persistConfig.persist_zones) ); + goto done; + } + else + { + TRACE_EXIT; + return( TCDBCORRUPT ); + } + +done: + + TRACE_EXIT; + return( TCSUCCESS ); +} + +int CTcdbZstore::UpdatePNodeData( int pnid + , const char *name + , int excludedFirstCore + , int excludedLastCore ) +{ + const char method_name[] = "CTcdbZstore::UpdatePNodeData"; + TRACE_ENTRY; + + if ( !IsInitialized() ) + { + if (TcTraceSettings & (TC_TRACE_REGISTRY | TC_TRACE_REQUEST | TC_TRACE_INIT)) + { + trace_printf( "%s@%d Zookeeper is not initialized for access!\n" + , method_name, __LINE__); + } + TRACE_EXIT; + return( TCNOTINIT ); + } + + if (TcTraceSettings & (TC_TRACE_NODE | TC_TRACE_REQUEST)) + { + trace_printf( "%s@%d update pnode " + "nodeName=%s, excFirstCore=%d, excLastCore=%d\n" + "where pnid=%d)\n" + , method_name, __LINE__ + , name + , excludedFirstCore + , excludedLastCore + , pnid ); + } + + int rc; + const char *sqlStmt; + sqlStmt = "update or replace pnode " + " set nodeName = ?, excFirstCore = ?, excLastCore = ?" + " where pnode.pNid = :pNid"; + + sqlite3_stmt *prepStmt = NULL; + rc = sqlite3_prepare_v2( db_, sqlStmt, strlen(sqlStmt)+1, &prepStmt, NULL); + if ( rc != SQLITE_OK ) + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf) + , "[%s] prepare (%s) failed, error: %s\n" + , method_name, sqlStmt, sqlite3_errmsg(db_) ); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_ERR, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + else + { + rc = sqlite3_bind_text( prepStmt, + 1, + name, -1, SQLITE_STATIC ); + if ( rc != SQLITE_OK ) + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf) + , "[%s] sqlite3_bind_text(name) failed, error: %s\n" + , method_name, sqlite3_errmsg(db_) ); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_CRIT, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + rc = sqlite3_bind_int( prepStmt, + 2, + excludedFirstCore ); + if ( rc != SQLITE_OK ) + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf), + "[%s] sqlite3_bind_int(excludedFirstCore) failed, error: %s\n" + , method_name, sqlite3_errmsg(db_) ); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_CRIT, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + rc = sqlite3_bind_int( prepStmt, + 3, + excludedLastCore ); + if ( rc != SQLITE_OK ) + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf), + "[%s] sqlite3_bind_int(excludedLastCore) failed, error: %s\n" + , method_name, sqlite3_errmsg(db_) ); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_CRIT, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + rc = sqlite3_bind_int( prepStmt, + sqlite3_bind_parameter_index( prepStmt, ":pNid" ), + pnid ); + if ( rc != SQLITE_OK ) + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf), + "[%s] sqlite3_bind_int(:pNid) failed, error: %s\n" + , method_name, sqlite3_errmsg(db_) ); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_CRIT, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + + rc = sqlite3_step( prepStmt ); + if (( rc != SQLITE_DONE ) && ( rc != SQLITE_ROW ) + && ( rc != SQLITE_CONSTRAINT ) ) + { + char buf[TC_LOG_BUF_SIZE]; + snprintf( buf, sizeof(buf) + , "[%s] (%s) failed, error: %s\n" + " (nodeName=%s, excFirstCore=%d, excLastCore=%d) " + " where pNid=%d " + , method_name, sqlStmt, sqlite3_errmsg(db_) + , name, excludedFirstCore, excludedLastCore, pnid ); + TcLogWrite( SQLITE_DB_ACCESS_ERROR, TC_LOG_ERR, buf ); + TRACE_EXIT; + return( TCDBOPERROR ); + } + } + + if ( prepStmt != NULL ) + { + sqlite3_finalize( prepStmt ); + } + + TRACE_EXIT; + return( TCSUCCESS ); +} + diff --git a/core/sqf/monitor/linux/tcdbzstore.h b/core/sqf/monitor/linux/tcdbzstore.h new file mode 100644 index 0000000000..dc83f3e391 --- /dev/null +++ b/core/sqf/monitor/linux/tcdbzstore.h @@ -0,0 +1,130 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// @@@ 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 TCDBZSTORE_H_ +#define TCDBZSTORE_H_ + +#include +#include +#include +#include +#include "trafconfig.h" +#include "zconfig.h" +#include "tcdbstore.h" + +using namespace std; + +class CTcdbZstore : public CTcdbStore +{ +public: + + CTcdbZstore( void ); + ~CTcdbZstore( void ); + + int Close( void ); + int AddRegistryKey( const char *key ); + int AddRegistryProcess( const char *name ); + int AddRegistryClusterData( const char *key, const char *value ); + int AddRegistryProcessData( const char *procName + , const char *key + , const char *value ); + int AddUniqueString( int nid, int id, const char *uniqueStr ); + 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[] ); + 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 ); + +protected: +private: + int GetSNodeData( int pnid + , const char *nodename + , int excfirstcore + , int exclastcore + , physical_node_configuration_t &spareNodeConfig ); + void SetLNodeData( int nid + , int pnid + , const char *nodename + , int excfirstcore + , int exclastcore + , int firstcore + , int lastcore + , int processors + , int roles + , node_configuration_t &nodeConfig ); + void SetPNodeData( int pnid + , const char *nodename + , int excfirstcore + , int exclastcore + , physical_node_configuration_t &pnodeConfig ); + int SetPersistProcessData( const char *persistkey + , const char *persistvalue + , persist_configuration_t &persistConfig ); + int UpdatePNodeData( int pnid + , const char *name + , int excludedFirstCore + , int excludedLastCore ); + + CZConfig zConfig_; +}; + + +#endif /* TCDBZSTORE_H_ */ diff --git a/core/sqf/monitor/linux/trafconfiglog.cxx b/core/sqf/monitor/linux/tclog.cxx similarity index 98% rename from core/sqf/monitor/linux/trafconfiglog.cxx rename to core/sqf/monitor/linux/tclog.cxx index 99b9183a69..0aa3febd22 100644 --- a/core/sqf/monitor/linux/trafconfiglog.cxx +++ b/core/sqf/monitor/linux/tclog.cxx @@ -34,8 +34,8 @@ using namespace std; #include #include #include -#include "trafconfigtrace.h" -#include "trafconfiglog.h" +#include "tctrace.h" +#include "tclog.h" #define gettid() syscall(__NR_gettid) diff --git a/core/sqf/monitor/linux/trafconfiglog.h b/core/sqf/monitor/linux/tclog.h similarity index 94% rename from core/sqf/monitor/linux/trafconfiglog.h rename to core/sqf/monitor/linux/tclog.h index f1817aa224..e9ec64457b 100644 --- a/core/sqf/monitor/linux/trafconfiglog.h +++ b/core/sqf/monitor/linux/tclog.h @@ -23,8 +23,10 @@ // /////////////////////////////////////////////////////////////////////////////// -#ifndef TRAFCONFIGLOG_H_ -#define TRAFCONFIGLOG_H_ +#ifndef TCLOG_H_ +#define TCLOG_H_ + +#include "common/evl_sqlog_eventnum.h" using namespace std; @@ -41,4 +43,4 @@ using namespace std; int TcLogWrite(int event_type, int severity, char *evl_buf); -#endif +#endif /* TCLOG_H_ */ diff --git a/core/sqf/monitor/linux/trafconfigtrace.cxx b/core/sqf/monitor/linux/tctrace.cxx similarity index 87% rename from core/sqf/monitor/linux/trafconfigtrace.cxx rename to core/sqf/monitor/linux/tctrace.cxx index c8868daca3..c5dfe19297 100644 --- a/core/sqf/monitor/linux/trafconfigtrace.cxx +++ b/core/sqf/monitor/linux/tctrace.cxx @@ -31,7 +31,7 @@ using namespace std; -#include "trafconfigtrace.h" +#include "tctrace.h" #define TC_PROCESS_PATH_MAX 256 @@ -98,6 +98,7 @@ void CTrafConfigTrace::TraceInit( bool traceEnabled , const char *traceLevel , const char *pfname) { + bool pathnameUsed = false; char trace_file_name[TC_PROCESS_PATH_MAX]; char hostname[TC_PROCESS_PATH_MAX]; @@ -108,51 +109,61 @@ void CTrafConfigTrace::TraceInit( bool traceEnabled sprintf( hostname,"TC"); } - // Format default trace file name and remove any existing trace file. - if( getenv("SQ_VIRTUAL_NODES") ) - { - sprintf( trace_file_name,"%s/trafconfig.trace.%d.%s" - , getenv("MPI_TMPDIR") - , getpid() - , hostname); - } - else - { - sprintf( trace_file_name,"%s/trafconfig.trace.%s" - , getenv("MPI_TMPDIR") - , hostname); - } - - remove(trace_file_name); - if (pfname == NULL) { // Caller did not specify a trace file name, get name from // environment variable if specified. pfname = GetEnvStr(strTraceFile_); } + + if (pfname == NULL) + { // Use default prefix + pfname = "tctrace"; + } if (pfname != NULL) { // User specified trace file name - // Save the base trace file name for possible use later - traceFileBase_ = new char[strlen(pfname) + 1]; - strcpy(traceFileBase_, pfname); - - if ((strcmp(pfname, "STDOUT") == 0) - || strcmp(pfname, "STDERR") == 0) + if ( pfname[0] == '/') { + // Use filename passed in strcpy(trace_file_name, pfname); + pathnameUsed = true; } - else // Make user specified file name unique per node + else { - sprintf(trace_file_name,"%s/%s.%d.%s" - , getenv("MPI_TMPDIR") - , pfname - , getpid() - , hostname); + // Format default trace file name and remove any existing trace file. + if( getenv("SQ_VIRTUAL_NODES") ) + { + sprintf( trace_file_name,"%s/trafconfig.trace.%d.%s" + , getenv("MPI_TMPDIR") + , getpid() + , hostname); + } + else + { + sprintf( trace_file_name,"%s/trafconfig.trace.%s" + , getenv("MPI_TMPDIR") + , hostname); + } + + if ((strcmp(pfname, "STDOUT") == 0) + || strcmp(pfname, "STDERR") == 0) + { + strcpy(trace_file_name, pfname); + } + else // Make user specified file name unique per node + { + sprintf(trace_file_name,"%s/%s.%d.%s" + , getenv("MPI_TMPDIR") + , pfname + , getpid() + , hostname); + } } } + remove(trace_file_name); + // Get any trace settings that were specified via environment variables const char *value; @@ -188,11 +199,11 @@ void CTrafConfigTrace::TraceInit( bool traceEnabled { traceSettingsSaved_ = TcTraceSettings; - if (strlen( trace_file_name)) + if (pfname != NULL) { trace_init(trace_file_name, false, // don't append pid to file name - "trafconfig", // prefix + pathnameUsed?(char*)"":(char*)"trafconfig", // file prefix false); if (traceFileFb_ > 0) { diff --git a/core/sqf/monitor/linux/trafconfigtrace.h b/core/sqf/monitor/linux/tctrace.h similarity index 97% rename from core/sqf/monitor/linux/trafconfigtrace.h rename to core/sqf/monitor/linux/tctrace.h index 9a3d42bf06..66ff0f1389 100644 --- a/core/sqf/monitor/linux/trafconfigtrace.h +++ b/core/sqf/monitor/linux/tctrace.h @@ -20,8 +20,8 @@ // // @@@ END COPYRIGHT @@@ ********************************************************************/ -#ifndef TRAFCONFIGTRACE_H_ -#define TRAFCONFIGTRACE_H_ +#ifndef TCTRACE_H_ +#define TCTRACE_H_ #include "seabed/trace.h" @@ -100,4 +100,4 @@ class CTrafConfigTrace static const char *strTraceFileFb_; }; -#endif // TRAFCONFIG_H_ +#endif /* TCTRACE_H_ */ diff --git a/core/sqf/monitor/linux/testconf.cxx b/core/sqf/monitor/linux/testconf.cxx index b4609a6d1c..ea8b5c445d 100644 --- a/core/sqf/monitor/linux/testconf.cxx +++ b/core/sqf/monitor/linux/testconf.cxx @@ -197,7 +197,7 @@ int TestClusterConfig( void ) CPersistConfig *persistConfig; cpu_set_t coreMask; - printf( "BEGIN 'sqconfig.db' Test\n" ); + printf( "BEGIN Trafodion Configuration Test\n" ); gethostname(Node_name, MPI_MAX_PROCESSOR_NAME); if ( clusterConfig.Initialize() ) @@ -399,15 +399,15 @@ int TestClusterConfig( void ) } else { - printf( "FAILED 'sqconfig.db' Load\n" ); + printf( "FAILED Trafodion Configuration Load\n" ); } } else { - printf( "FAILED 'sqconfig.db' Initialize\n" ); + printf( "FAILED Trafodion Configuration Initialize\n" ); } - printf( "\nEND 'sqconfig.db' Test\n" ); + printf( "\nEND Trafodion Configuration Test\n" ); return( rc ); } diff --git a/core/sqf/monitor/linux/trafconf.cxx b/core/sqf/monitor/linux/trafconf.cxx index 9fff70a799..c77d9665bc 100644 --- a/core/sqf/monitor/linux/trafconf.cxx +++ b/core/sqf/monitor/linux/trafconf.cxx @@ -367,14 +367,15 @@ int DisplayPersistConfig( char *key ) { int rc = -1; bool foundConfig = false; - char persist_config_buf[MAX_VALUE_SIZE_INT]; - char process_name_str[MAX_TOKEN]; - char process_type_str[MAX_TOKEN]; - char program_name_str[MAX_TOKEN]; - char requires_dtm_str[MAX_TOKEN]; - char stdout_str[MAX_TOKEN]; - char persist_retries_str[MAX_TOKEN]; - char persist_zones_str[MAX_TOKEN]; + char persist_config_buf[TC_PERSIST_VALUE_MAX*2]; + char process_name_str[TC_PERSIST_VALUE_MAX]; + char process_type_str[TC_PERSIST_VALUE_MAX]; + char program_name_str[TC_PERSIST_VALUE_MAX]; + char program_args_str[TC_PERSIST_VALUE_MAX]; + char requires_dtm_str[TC_PERSIST_VALUE_MAX]; + char stdout_str[TC_PERSIST_VALUE_MAX]; + char persist_retries_str[TC_PERSIST_VALUE_MAX]; + char persist_zones_str[TC_PERSIST_VALUE_MAX]; CPersistConfig *persistConfig; if ( DisplayBeginEnd ) @@ -419,6 +420,13 @@ int DisplayPersistConfig( char *key ) , PERSIST_PROGRAM_NAME_KEY , persistConfig->GetProgramName() ); + snprintf( program_args_str, sizeof(program_args_str) + , "%s_%s = %s" + , persistConfig->GetPersistPrefix() + , PERSIST_PROGRAM_ARGS_KEY + , strlen(persistConfig->GetProgramArgs()) + ?persistConfig->GetProgramArgs():"" + ); snprintf( requires_dtm_str, sizeof(requires_dtm_str) , "%s_%s = %s" , persistConfig->GetPersistPrefix() @@ -446,10 +454,11 @@ int DisplayPersistConfig( char *key ) , persistConfig->GetZoneFormat() ); snprintf( persist_config_buf, sizeof(persist_config_buf) - , "%s\n%s\n%s\n%s\n%s\n%s\n%s\n" + , "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n" , process_name_str , process_type_str , program_name_str + , program_args_str , requires_dtm_str , stdout_str , persist_retries_str @@ -600,14 +609,14 @@ int main( int argc, char *argv[] ) if ( !ClusterConfig.Initialize() ) { - printf( "Failed to initialize 'sqconfig.db'!\n" ); + printf( "Failed to initialize Trafodion Configuration!\n" ); exit( EXIT_FAILURE ); } else { if ( !ClusterConfig.LoadConfig() ) { - printf( "Failed to load 'sqconfig.db'!\n" ); + printf( "Failed to load Trafodion Configuration!\n" ); exit( EXIT_FAILURE ); } } diff --git a/core/sqf/monitor/linux/trafconfig.cxx b/core/sqf/monitor/linux/trafconfig.cxx index 5194800451..5f9f95e117 100644 --- a/core/sqf/monitor/linux/trafconfig.cxx +++ b/core/sqf/monitor/linux/trafconfig.cxx @@ -25,14 +25,14 @@ using namespace std; -#include "sqliteconfig.h" -#include "trafconfigtrace.h" +#include "tcdb.h" +#include "tctrace.h" #include "trafconfig.h" bool TcTraceEnabled = false; CTrafConfigTrace TrafConfigTrace; -CSqliteConfig SqliteConfig; +CTcdb TrafConfigDb; /////////////////////////////////////////////////////////////////////////////// // Trafodion Configuration @@ -40,7 +40,7 @@ CSqliteConfig SqliteConfig; TC_Export int tc_close( void ) { - int rc = SqliteConfig.Close(); + int rc = TrafConfigDb.Close(); if (TcTraceEnabled) { @@ -76,15 +76,15 @@ TC_Export const char *tc_errmsg( int err ) return "Error undefined!"; } -TC_Export int tc_initialize( bool traceEnabled ) +TC_Export int tc_initialize( bool traceEnabled, const char *traceFileName ) { TcTraceEnabled = traceEnabled; if (TcTraceEnabled) { - TrafConfigTrace.TraceInit( TcTraceEnabled, "0", NULL ); + TrafConfigTrace.TraceInit( TcTraceEnabled, "0", traceFileName ); } - int rc = SqliteConfig.Initialize(); + int rc = TrafConfigDb.Initialize(); return( rc ); } @@ -93,12 +93,17 @@ TC_Export int tc_initialize( bool traceEnabled ) TC_Export int tc_delete_node( int nid , const char *node_name ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; node_configuration_t nodeConfig; if (node_name) { - rc = SqliteConfig.GetNode( node_name, nodeConfig ); + rc = TrafConfigDb.GetNode( node_name, nodeConfig ); if ( rc != TCSUCCESS) { return( rc ); @@ -106,7 +111,7 @@ TC_Export int tc_delete_node( int nid } else { - rc = SqliteConfig.GetNode( nid, nodeConfig ); + rc = TrafConfigDb.GetNode( nid, nodeConfig ); if ( rc != TCSUCCESS) { return( rc ); @@ -115,7 +120,7 @@ TC_Export int tc_delete_node( int nid if ( nodeConfig.nid != -1) { - rc = SqliteConfig.DeleteNodeData( nodeConfig.pnid ); + rc = TrafConfigDb.DeleteNodeData( nodeConfig.pnid ); } return( rc ); @@ -124,24 +129,34 @@ TC_Export int tc_delete_node( int nid TC_Export int tc_get_node( const char *node_name , node_configuration_t *node_config ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.GetNode( node_name, *node_config ); + rc = TrafConfigDb.GetNode( node_name, *node_config ); return( rc ); } TC_Export int tc_put_node( node_configuration_t *node_config ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.SavePNodeData( node_config->node_name + rc = TrafConfigDb.SavePNodeData( node_config->node_name , node_config->pnid , node_config->excluded_first_core , node_config->excluded_last_core ); if (rc == TCSUCCESS) { - rc = SqliteConfig.SaveLNodeData( node_config->nid + rc = TrafConfigDb.SaveLNodeData( node_config->nid , node_config->pnid , node_config->first_core , node_config->last_core @@ -155,18 +170,28 @@ TC_Export int tc_put_node( node_configuration_t *node_config ) TC_Export int tc_get_pnode( const char *node_name , physical_node_configuration_t *pnode_config ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.GetPNode( node_name, *pnode_config ); + rc = TrafConfigDb.GetPNode( node_name, *pnode_config ); return( rc ); } TC_Export int tc_put_pnode( physical_node_configuration_t *pnode_config ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.SavePNodeData( pnode_config->node_name + rc = TrafConfigDb.SavePNodeData( pnode_config->node_name , pnode_config->pnid , pnode_config->excluded_first_core , pnode_config->excluded_last_core ); @@ -178,6 +203,11 @@ TC_Export int tc_get_nodes( int *count , int max , node_configuration_t *node_config ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; if ( node_config == NULL ) @@ -185,7 +215,7 @@ TC_Export int tc_get_nodes( int *count max = 0; } - rc = SqliteConfig.GetNodes( *count, max, node_config ); + rc = TrafConfigDb.GetNodes( *count, max, node_config ); return( rc ); } @@ -194,6 +224,11 @@ TC_Export int tc_get_snodes( int *scount , int max , physical_node_configuration_t *pnode_config ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; if ( pnode_config == NULL ) @@ -201,13 +236,18 @@ TC_Export int tc_get_snodes( int *scount max = 0; } - rc = SqliteConfig.GetSNodes( *scount, max, pnode_config ); + rc = TrafConfigDb.GetSNodes( *scount, max, pnode_config ); return( rc ); } TC_Export int tc_delete_persist_keys( void ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCNOTIMPLEMENTED; // @@ -217,15 +257,25 @@ TC_Export int tc_delete_persist_keys( void ) TC_Export int tc_get_persist_keys( const char *persist_keys ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.GetPersistProcessKeys( persist_keys ); + rc = TrafConfigDb.GetPersistProcessKeys( persist_keys ); return( rc ); } TC_Export int tc_put_persist_keys( const char *persist_keys ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCNOTIMPLEMENTED; // @@ -235,6 +285,11 @@ TC_Export int tc_put_persist_keys( const char *persist_keys ) TC_Export int tc_delete_persist_process( const char *persist_key_prefix ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCNOTIMPLEMENTED; // @@ -245,9 +300,14 @@ TC_Export int tc_delete_persist_process( const char *persist_key_prefix ) TC_Export int tc_get_persist_process( const char *persist_key_prefix , persist_configuration_t *persist_config ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.GetPersistProcess( persist_key_prefix, *persist_config ); + rc = TrafConfigDb.GetPersistProcess( persist_key_prefix, *persist_config ); return( rc ); } @@ -255,6 +315,11 @@ TC_Export int tc_get_persist_process( const char *persist_key_prefix TC_Export int tc_put_persist_process( const char *persist_key_prefix , persist_configuration_t *persist_config ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCNOTIMPLEMENTED; // @@ -266,9 +331,14 @@ TC_Export int tc_get_registry_cluster_set( int *count , int max , registry_configuration_t *registry_config ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.GetRegistryClusterSet( *count, max, registry_config ); + rc = TrafConfigDb.GetRegistryClusterSet( *count, max, registry_config ); return( rc ); } @@ -277,45 +347,70 @@ TC_Export int tc_get_registry_process_set( int *count , int max , registry_configuration_t *registry_config ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.GetRegistryProcessSet( *count, max, registry_config ); + rc = TrafConfigDb.GetRegistryProcessSet( *count, max, registry_config ); return( rc ); } TC_Export int tc_get_registry_key( const char *key ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCNOTIMPLEMENTED; - //rc = SqliteConfig.GetRegistryKey( key ); + //rc = TrafConfigDb.GetRegistryKey( key ); return( rc ); } TC_Export int tc_put_registry_key( const char *key ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.AddRegistryKey( key ); + rc = TrafConfigDb.AddRegistryKey( key ); return( rc ); } TC_Export int tc_get_registry_process( const char *process_name ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCNOTIMPLEMENTED; - //rc = SqliteConfig.GetRegistryProcess( process_name ); + //rc = TrafConfigDb.GetRegistryProcess( process_name ); return( rc ); } TC_Export int tc_put_registry_process( const char *process_name ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.AddRegistryProcess( process_name ); + rc = TrafConfigDb.AddRegistryProcess( process_name ); return( rc ); } @@ -323,9 +418,14 @@ TC_Export int tc_put_registry_process( const char *process_name ) TC_Export int tc_get_registry_cluster_data( const char *key , const char *data ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCNOTIMPLEMENTED; - //rc = SqliteConfig.GetRegistryClusterData( key, data ); + //rc = TrafConfigDb.GetRegistryClusterData( key, data ); return( rc ); } @@ -333,9 +433,14 @@ TC_Export int tc_get_registry_cluster_data( const char *key TC_Export int tc_put_registry_cluster_data( const char *key , const char *data ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.AddRegistryClusterData( key, data ); + rc = TrafConfigDb.AddRegistryClusterData( key, data ); return( rc ); } @@ -344,9 +449,14 @@ TC_Export int tc_get_registry_process_data( const char *process_name , const char *key , const char *data ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCNOTIMPLEMENTED; - //rc = SqliteConfig.GetRegistryProcessData( process_name, key, data ); + //rc = TrafConfigDb.GetRegistryProcessData( process_name, key, data ); return( rc ); } @@ -355,18 +465,38 @@ TC_Export int tc_put_registry_process_data( const char *process_name , const char *key , const char *data ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.AddRegistryProcessData( process_name, key, data ); + rc = TrafConfigDb.AddRegistryProcessData( process_name, key, data ); return( rc ); } +TC_Export TC_STORAGE_TYPE tc_get_storage_type( void ) +{ + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCDBSTOREUNDEFINED ); + } + + return( TrafConfigDb.GetStorageType() ); +} + TC_Export int tc_delete_unique_strings( int nid ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.DeleteUniqueString( nid ); + rc = TrafConfigDb.DeleteUniqueString( nid ); return( rc ); } @@ -374,36 +504,56 @@ TC_Export int tc_delete_unique_strings( int nid ) TC_Export int tc_get_unique_string( int nid, int id, const char *unique_string ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.GetUniqueString( nid, id, unique_string ); + rc = TrafConfigDb.GetUniqueString( nid, id, unique_string ); return( rc ); } TC_Export int tc_put_unique_string( int nid, int id, const char *unique_string ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.AddUniqueString( nid, id, unique_string ); + rc = TrafConfigDb.AddUniqueString( nid, id, unique_string ); return( rc ); } TC_Export int tc_get_unique_string_id( int nid, const char *unique_string, int *id ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.GetUniqueStringId( nid, unique_string, *id ); + rc = TrafConfigDb.GetUniqueStringId( nid, unique_string, *id ); return( rc ); } TC_Export int tc_get_unique_string_id_max( int nid, int *id ) { + if ( ! TrafConfigDb.IsInitialized() ) + { + return( TCNOTINIT ); + } + int rc = TCDBOPERROR; - rc = SqliteConfig.GetUniqueStringIdMax( nid, *id ); + rc = TrafConfigDb.GetUniqueStringIdMax( nid, *id ); return( rc ); } diff --git a/core/sqf/monitor/linux/trafconfig.h b/core/sqf/monitor/linux/trafconfig.h index 0ef0693412..b1651a9acc 100644 --- a/core/sqf/monitor/linux/trafconfig.h +++ b/core/sqf/monitor/linux/trafconfig.h @@ -46,21 +46,35 @@ #define TC_PERSIST_PROCESSOR_NAME_MAX 128 #define TC_PERSIST_ROLES_MAX 128 #define TC_PERSIST_KEY_MAX 64 -#define TC_PERSIST_VALUE_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_SQLITE "SQLITE" +#define TC_STORE_POSTGRESQL "POSTGRESQL" +#define TC_STORE_ZOOKEEPER "ZOOKEEPER" + #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" +enum TC_STORAGE_TYPE { + TCDBSTOREUNDEFINED = 0 + , TCDBMYSQL = 1 // MySQL Database [TBD] + , TCDBPOSTGRESQL = 2 // PostgresQL Database [TBD] + , TCDBZOOKEEPER = 3 // Zookeeper + , TCDBSQLITE = 4 // Sqlite Database [deprecated] +}; + enum TC_ERRORS { TCSUCCESS = 0, // Successful operation TCNOTIMPLEMENTED = -1,// Not implemented @@ -108,6 +122,7 @@ typedef struct persist_configuration_s char process_name[TC_PERSIST_VALUE_MAX]; // Process name {[]} 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 {[]} bool requires_DTM; // True when process requires transaction support int persist_retries; // Process create retries @@ -122,7 +137,7 @@ TC_DIAG_UNUSED; TC_Export const char *tc_errmsg( int err ) TC_DIAG_UNUSED; -TC_Export int tc_initialize( bool traceEnabled ) +TC_Export int tc_initialize( bool traceEnabled, const char *traceFileName = NULL ) TC_DIAG_UNUSED; @@ -267,6 +282,10 @@ TC_Export int tc_put_registry_process_data( const char *process_name 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; diff --git a/core/sqf/monitor/linux/type2str.cxx b/core/sqf/monitor/linux/type2str.cxx new file mode 100644 index 0000000000..b0555a21ab --- /dev/null +++ b/core/sqf/monitor/linux/type2str.cxx @@ -0,0 +1,63 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// @@@ 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 +#include "zookeeper/zookeeper.h" +#include "type2str.h" + +const char *ZooConnectionTypeStr( int type ) +{ + if ( type == ZOO_CREATED_EVENT ) + return "ZOO_CREATED_EVENT"; + if ( type == ZOO_DELETED_EVENT ) + return "ZOO_DELETED_EVENT"; + if ( type == ZOO_CHANGED_EVENT ) + return "ZOO_CHANGED_EVENT"; + if ( type == ZOO_CHILD_EVENT ) + return "ZOO_CHILD_EVENT"; + if ( type == ZOO_SESSION_EVENT ) + return "ZOO_SESSION_EVENT"; + if ( type == ZOO_NOTWATCHING_EVENT ) + return "ZOO_NOTWATCHING_EVENT"; + + return "INVALID_TYPE"; +} + +const char *ZooConnectionStateStr( int state ) +{ + if ( state == 0 ) + return "CLOSED_STATE"; + if ( state == ZOO_EXPIRED_SESSION_STATE ) + return "EXPIRED_SESSION_STATE"; + if ( state == ZOO_AUTH_FAILED_STATE ) + return "AUTH_FAILED_STATE"; + if ( state == ZOO_CONNECTING_STATE ) + return "CONNECTING_STATE"; + if ( state == ZOO_ASSOCIATING_STATE ) + return "ASSOCIATING_STATE"; + if ( state == ZOO_CONNECTED_STATE ) + return "CONNECTED_STATE"; + + return "INVALID_STATE"; +} diff --git a/core/sqf/monitor/linux/type2str.h b/core/sqf/monitor/linux/type2str.h new file mode 100644 index 0000000000..f509a97060 --- /dev/null +++ b/core/sqf/monitor/linux/type2str.h @@ -0,0 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// @@@ 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 TYPE2STR_H_ +#define TYPE2STR_H_ + +const char *ZooConnectionTypeStr( int type ); +const char *ZooConnectionStateStr( int state ); +//const char *ZooErrorStr( int error ); -- use zerror(int c); + +#endif /* TYPE2STR_H_ */ + diff --git a/core/sqf/monitor/linux/watchdog.cxx b/core/sqf/monitor/linux/watchdog.cxx index 9875e68886..76c92acff6 100644 --- a/core/sqf/monitor/linux/watchdog.cxx +++ b/core/sqf/monitor/linux/watchdog.cxx @@ -515,7 +515,7 @@ void InitLocalIO( void ) if ( MyPNID == -1 ) { - CClusterConfig ClusterConfig; // 'sqconfig.db' objects + CClusterConfig ClusterConfig; // Configuration objects CPNodeConfig *pnodeConfig; CLNodeConfig *lnodeConfig; diff --git a/core/sqf/monitor/linux/zclient.cxx b/core/sqf/monitor/linux/zclient.cxx index ae2b15bc69..85258532df 100644 --- a/core/sqf/monitor/linux/zclient.cxx +++ b/core/sqf/monitor/linux/zclient.cxx @@ -20,6 +20,7 @@ // // @@@ END COPYRIGHT @@@ ********************************************************************/ +#include #include #include #include @@ -40,6 +41,7 @@ #include "monlogging.h" #include "reqqueue.h" #include "pnode.h" +#include "type2str.h" #include "zclient.h" // @@ -53,8 +55,9 @@ // The monitors register their znodes under the cluster znode #define ZCLIENT_CLUSTER_ZNODE "/cluster" -// zookeeper connection retry count -#define ZOOKEEPER_RETRY_COUNT 3 +// zookeeper connection retries +#define ZOOKEEPER_RETRY_COUNT 3 +#define ZOOKEEPER_RETRY_WAIT 1 // seconds using namespace std; @@ -117,70 +120,6 @@ static const char *ZClientStateStr( CZClient::ZClientState_t state ) return "ZClient State Invalid"; } -static const char *ZooConnectionTypeStr( int type ) -{ - if ( type == ZOO_CREATED_EVENT ) - return "ZOO_CREATED_EVENT"; - if ( type == ZOO_DELETED_EVENT ) - return "ZOO_DELETED_EVENT"; - if ( type == ZOO_CHANGED_EVENT ) - return "ZOO_CHANGED_EVENT"; - if ( type == ZOO_CHILD_EVENT ) - return "ZOO_CHILD_EVENT"; - if ( type == ZOO_SESSION_EVENT ) - return "ZOO_SESSION_EVENT"; - if ( type == ZOO_NOTWATCHING_EVENT ) - return "ZOO_NOTWATCHING_EVENT"; - - return "INVALID_TYPE"; -} - -static const char *ZooConnectionStateStr( int state ) -{ - if ( state == 0 ) - return "CLOSED_STATE"; - if ( state == ZOO_EXPIRED_SESSION_STATE ) - return "EXPIRED_SESSION_STATE"; - if ( state == ZOO_AUTH_FAILED_STATE ) - return "AUTH_FAILED_STATE"; - if ( state == ZOO_CONNECTING_STATE ) - return "CONNECTING_STATE"; - if ( state == ZOO_ASSOCIATING_STATE ) - return "ASSOCIATING_STATE"; - if ( state == ZOO_CONNECTED_STATE ) - return "CONNECTED_STATE"; - - return "INVALID_STATE"; -} - -const char *ZooErrorStr( int error ) -{ - if ( error == 0 ) - return "ZOK"; - if ( error == ZNONODE ) - return "ZNONODE"; - if ( error == ZNODEEXISTS ) - return "ZNODEEXISTS"; - if ( error == ZNOAUTH ) - return "ZNOAUTH"; - if ( error == ZNOCHILDRENFOREPHEMERALS ) - return "ZNOCHILDRENFOREPHEMERALS"; - if ( error == ZBADARGUMENTS ) - return "ZBADARGUMENTS"; - if ( error == ZINVALIDSTATE ) - return "ZINVALIDSTATE"; - if ( error == ZMARSHALLINGERROR ) - return "ZMARSHALLINGERROR"; - if ( error == ZCONNECTIONLOSS ) - return "ZCONNECTIONLOSS"; - if ( error == ZOPERATIONTIMEOUT ) - return "ZOPERATIONTIMEOUT"; - - static char errorStr[20]; - sprintf( errorStr, "%d", error ); - return errorStr; -} - void ZSessionWatcher( zhandle_t *zzh , int type , int state @@ -373,7 +312,7 @@ CZClient::CZClient( const char *quorumHosts char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], Failed ZClient initialization (%s)\n" - , method_name, ZooErrorStr(rc) ); + , method_name, zerror(rc) ); mon_log_write(MON_ZCLIENT_ZCLIENT_3, SQ_LOG_ERR, buf); abort(); } @@ -487,12 +426,14 @@ void CZClient::CheckMyZNode( void ) resetMyZNodeFailedTime_ = false; clock_gettime(CLOCK_REALTIME, &myZNodeFailedTime_); myZNodeFailedTime_.tv_sec += (GetSessionTimeout() * 2); +#if 0 if (trace_settings & (TRACE_INIT | TRACE_RECOVERY)) { trace_printf( "%s@%d" " - Resetting MyZnode Fail Time %ld(secs)\n" , method_name, __LINE__ , myZNodeFailedTime_.tv_sec ); } +#endif } if ( ! IsZNodeExpired( Node_name, zerr ) ) { @@ -507,7 +448,7 @@ void CZClient::CheckMyZNode( void ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], Zookeeper quorum comm error: %s - Handling my znode (%s) as expired! Node is going down.\n" - , method_name, ZooErrorStr(zerr), Node_name ); + , method_name, zerror(zerr), Node_name ); mon_log_write(MON_ZCLIENT_CHECKMYZNODE_1, SQ_LOG_ERR, buf); HandleMyNodeExpiration(); } @@ -597,7 +538,7 @@ int CZClient::GetClusterZNodes( String_vector *nodes ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], zoo_exists() for %s failed with error %s\n" - , method_name, trafCluster.c_str( ), ZooErrorStr(rc)); + , method_name, trafCluster.c_str( ), zerror(rc)); mon_log_write(MON_ZCLIENT_GETCLUSTERZNODES_2, SQ_LOG_ERR, buf); break; } @@ -660,7 +601,7 @@ int CZClient::GetZNodeData( string &monZnode, string &nodeName, int &pnid ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], zoo_get() for %s failed with error %s\n" - , method_name, monZnode.c_str( ), ZooErrorStr(rc)); + , method_name, monZnode.c_str( ), zerror(rc)); mon_log_write(MON_ZCLIENT_GETZNODEDATA_2, SQ_LOG_ERR, buf); } } @@ -669,7 +610,7 @@ int CZClient::GetZNodeData( string &monZnode, string &nodeName, int &pnid ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], zoo_exists() for %s failed with error %s\n" - , method_name, monZnode.c_str( ), ZooErrorStr(rc)); + , method_name, monZnode.c_str( ), zerror(rc)); mon_log_write(MON_ZCLIENT_GETZNODEDATA_3, SQ_LOG_ERR, buf); } @@ -755,8 +696,9 @@ int CZClient::InitializeZClient( void ) rc = MakeClusterZNodes(); - while ( rc != ZOK and retries < ZOOKEEPER_RETRY_COUNT) + while ( rc != ZOK && retries < ZOOKEEPER_RETRY_COUNT) { + sleep(ZOOKEEPER_RETRY_WAIT); retries++; rc = MakeClusterZNodes(); } @@ -788,11 +730,6 @@ bool CZClient::IsZNodeExpired( const char *nodeName, int &zerr ) zerr = ZOK; - if (trace_settings & (TRACE_INIT | TRACE_RECOVERY)) - { - trace_printf( "%s@%d monZnode=%s\n" - , method_name, __LINE__, monZnode.c_str() ); - } rc = zoo_exists( ZHandle, monZnode.c_str( ), 0, &stat ); if ( rc == ZNONODE ) { @@ -811,17 +748,12 @@ bool CZClient::IsZNodeExpired( const char *nodeName, int &zerr ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], zoo_exists() for %s failed with error %s\n" - , method_name, monZnode.c_str( ), ZooErrorStr(rc)); + , method_name, monZnode.c_str( ), zerror(rc)); mon_log_write(MON_ZCLIENT_ISZNODEEXPIRED_1, SQ_LOG_ERR, buf); } else if ( rc == ZOK ) { expired = false; - if (trace_settings & (TRACE_INIT | TRACE_RECOVERY)) - { - trace_printf( "%s@%d monZnode=%s exist\n" - , method_name, __LINE__, monZnode.c_str() ); - } } else { @@ -829,7 +761,7 @@ bool CZClient::IsZNodeExpired( const char *nodeName, int &zerr ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], zoo_exists() for %s failed with error %s\n" - , method_name, monZnode.c_str( ), ZooErrorStr(rc)); + , method_name, monZnode.c_str( ), zerror(rc)); mon_log_write(MON_ZCLIENT_ISZNODEEXPIRED_2, SQ_LOG_CRIT, buf); switch ( rc ) { @@ -891,7 +823,7 @@ int CZClient::MakeClusterZNodes( void ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], zoo_exists(%s) failed with error %s\n" - , method_name, rootDir.c_str(), ZooErrorStr(rc) ); + , method_name, rootDir.c_str(), zerror(rc) ); mon_log_write(MON_ZCLIENT_CHECKCLUSTERZNODES_1, SQ_LOG_ERR, buf); if (rc) return(rc); // Return the error break; @@ -925,7 +857,7 @@ int CZClient::MakeClusterZNodes( void ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], zoo_exists(%s) failed with error %s\n" - , method_name, instanceDir.c_str( ), ZooErrorStr(rc) ); + , method_name, instanceDir.c_str( ), zerror(rc) ); mon_log_write(MON_ZCLIENT_CHECKCLUSTERZNODES_2, SQ_LOG_ERR, buf); break; } @@ -959,7 +891,7 @@ int CZClient::MakeClusterZNodes( void ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], zoo_exists(%s) failed with error %s\n" - , method_name, clusterDir.c_str( ), ZooErrorStr(rc) ); + , method_name, clusterDir.c_str(), zerror(rc) ); mon_log_write(MON_ZCLIENT_CHECKCLUSTERZNODES_3, SQ_LOG_ERR, buf); break; } @@ -1171,7 +1103,7 @@ int CZClient::RegisterZNode( const char *znodePath , "[%s], zoo_create(%s) failed with error %s\n" , method_name , zpath.c_str() - , ZooErrorStr(rc) ); + , zerror(rc) ); mon_log_write(MON_ZCLIENT_REGISTERZNODE_1, SQ_LOG_ERR, buf); } if (trace_settings & (TRACE_INIT | TRACE_RECOVERY)) @@ -1255,7 +1187,7 @@ int CZClient::SetZNodeWatch( string &monZnode ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], zoo_get() for %s failed with error %s\n" - , method_name, monZnode.c_str( ), ZooErrorStr(rc)); + , method_name, monZnode.c_str( ), zerror(rc)); mon_log_write(MON_ZCLIENT_SETZNODEWATCH_1, SQ_LOG_ERR, buf); } } @@ -1264,7 +1196,7 @@ int CZClient::SetZNodeWatch( string &monZnode ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], zoo_exists() for %s failed with error %s\n" - , method_name, monZnode.c_str( ), ZooErrorStr(rc)); + , method_name, monZnode.c_str( ), zerror(rc)); mon_log_write(MON_ZCLIENT_SETZNODEWATCH_1, SQ_LOG_CRIT, buf); switch ( rc ) { @@ -1628,7 +1560,7 @@ int CZClient::WatchNodeDelete( const char *nodeName ) char buf[MON_STRING_BUF_SIZE]; snprintf( buf, sizeof(buf) , "[%s], zoo_delete(%s) failed with error %s\n" - , method_name, nodeName, ZooErrorStr(rc) ); + , method_name, nodeName, zerror(rc) ); mon_log_write(MON_ZCLIENT_WATCHNODEDELETE_3, SQ_LOG_CRIT, buf); switch ( rc ) { diff --git a/core/sqf/sqenvcom.sh b/core/sqf/sqenvcom.sh index 4e827fd2eb..f686b0c128 100644 --- a/core/sqf/sqenvcom.sh +++ b/core/sqf/sqenvcom.sh @@ -47,6 +47,9 @@ export PRODUCT_COPYRIGHT_HEADER="2015-2017 Apache Software Foundation" ############################################################## export TRAFODION_ENABLE_AUTHENTICATION=${TRAFODION_ENABLE_AUTHENTICATION:-NO} +# Uncomment Trafodion Configuration store type +#export TRAF_CONFIG_DBSTORE=Sqlite +#export TRAF_CONFIG_DBSTORE=Zookeeper # default SQ_IC to TCP if it is not set in sqenv.sh. Values are # IBV for infiniband, TCP for tcp @@ -695,6 +698,9 @@ export SQ_MON_EPOLL_RETRY_COUNT=16 # Default is 5 seconds. #export SQ_MON_ZCLIENT_MY_ZNODE_CHECKRATE=5 +# Trafodion Configuration Zookeeper store +#export TC_ZCONFIG_SESSION_TIMEOUT=120 + # set to 0 to disable phandle verifier export SQ_PHANDLE_VERIFIER=1 diff --git a/core/sqf/sql/scripts/createConfigDb b/core/sqf/sql/scripts/createConfigDb index 748f95e92b..0310651f68 100755 --- a/core/sqf/sql/scripts/createConfigDb +++ b/core/sqf/sql/scripts/createConfigDb @@ -109,7 +109,7 @@ create table monRegUniqueStrings -- Persist Data (monitor gensq.pl) create table monRegPersistData ( - keyName varchar(50) primary key, - valueName varchar(50) + keyName varchar(64) primary key, + valueName varchar(4096) ); diff --git a/core/sqf/sql/scripts/sqconfig.persist b/core/sqf/sql/scripts/sqconfig.persist index 90f1393db6..23f46e8528 100644 --- a/core/sqf/sql/scripts/sqconfig.persist +++ b/core/sqf/sql/scripts/sqconfig.persist @@ -23,6 +23,7 @@ begin persist # # The following PROCESS_TYPEs are persistent and have special process management: +# # DTM # TMID # SSMP @@ -30,6 +31,7 @@ begin persist # WDG # # Generic persistent processes are of PROCESS_TYPE: +# # PERSIST # @@ -38,6 +40,7 @@ PERSIST_PROCESS_KEYS = DTM,TMID,SSCP,SSMP,PSD,WDG DTM_PROCESS_NAME = $TM%nid+ DTM_PROCESS_TYPE = DTM DTM_PROGRAM_NAME = tm +DTM_PROGRAM_ARGS = DTM_REQUIRES_DTM = N DTM_STDOUT = stdout_DTM%nid DTM_PERSIST_RETRIES = 2,30 @@ -46,6 +49,7 @@ DTM_PERSIST_ZONES = %zid TMID_PROCESS_NAME = $TSID0 TMID_PROCESS_TYPE = TMID TMID_PROGRAM_NAME = idtmsrv +TMID_PROGRAM_ARGS = TMID_REQUIRES_DTM = N TMID_STDOUT = stdout_TSID0 TMID_PERSIST_RETRIES = 2,30 @@ -54,6 +58,7 @@ TMID_PERSIST_ZONES = %zid+ SSCP_PROCESS_NAME = $ZSC%nid+ SSCP_PROCESS_TYPE = PERSIST SSCP_PROGRAM_NAME = mxsscp +SSCP_PROGRAM_ARGS = SSCP_REQUIRES_DTM = Y SSCP_STDOUT = stdout_ZSC%nid SSCP_PERSIST_RETRIES = 10,60 @@ -62,6 +67,7 @@ SSCP_PERSIST_ZONES = %zid SSMP_PROCESS_NAME = $ZSM%nid+ SSMP_PROCESS_TYPE = SSMP SSMP_PROGRAM_NAME = mxssmp +SSMP_PROGRAM_ARGS = SSMP_REQUIRES_DTM = Y SSMP_STDOUT = stdout_ZSM%nid SSMP_PERSIST_RETRIES = 10,60 @@ -70,6 +76,7 @@ SSMP_PERSIST_ZONES = %zid PSD_PROCESS_NAME = $PSD%nid+ PSD_PROCESS_TYPE = PSD PSD_PROGRAM_NAME = pstartd +PSD_PROGRAM_ARGS = PSD_REQUIRES_DTM = N PSD_STDOUT = stdout_PSD%nid PSD_PERSIST_RETRIES = 10,60 @@ -78,6 +85,7 @@ PSD_PERSIST_ZONES = %zid WDG_PROCESS_NAME = $WDG%nid+ WDG_PROCESS_TYPE = WDG WDG_PROGRAM_NAME = sqwatchdog +WDG_PROGRAM_ARGS = WDG_REQUIRES_DTM = N WDG_STDOUT = stdout_WDG%nid WDG_PERSIST_RETRIES = 10,60 diff --git a/core/sqf/sql/scripts/sqpersist.pm b/core/sqf/sql/scripts/sqpersist.pm index 220eca7f78..cca14c6ff1 100644 --- a/core/sqf/sql/scripts/sqpersist.pm +++ b/core/sqf/sql/scripts/sqpersist.pm @@ -40,6 +40,7 @@ my $g_prefixSave; my $g_processName; my $g_processType; my $g_programName; +my $g_programArgs; my $g_requiresDtm; my $g_stdout; my $g_persistRetries; @@ -246,7 +247,7 @@ sub parseStatement { my $eq; ($eq, $s) = parseEq($s); if ($eq) { - if ($s =~ /([a-zA-Z0-0_]+)/) { + if ($s =~ /([a-zA-Z0-9_]+)/) { $g_programName = $1; $s =~ s:$1::; $g_opts |= 0x4; @@ -258,6 +259,27 @@ sub parseStatement { } } } + } elsif ($s =~ /(^[A-Z]+)(_PROGRAM_ARGS)\s*/) { + my $prefix = $1; + my $k = $2; + checkPrefix($prefix); + $s =~ s:$prefix$2\s*::; + if (validKey($prefix)) { + my $eq; + ($eq, $s) = parseEq($s); + if ($eq) { # ([a-zA-Z0-9_]+) + if ($s =~ /([a-zA-Z0-9\!-\/\:-\@\[-\`\{-\~\h10]*)/) { + $g_programArgs = $1; + $s =~ s:$1::; + $g_opts |= 0x80; + push(@g_dbList, $g_prefix . $k, $g_programArgs); + parseEnd($s); + } else { + displayStmt($g_ok); + print " Error: Expecting e.g. -t 1, but saw $s\n"; #T + } + } + } } elsif ($s =~ /(^[A-Z]+)(_REQUIRES_DTM)\s*/) { my $prefix = $1; my $k = $2; @@ -382,6 +404,7 @@ sub resetVars $g_processName = ''; $g_processType = ''; $g_programName = ''; + $g_programArgs = ''; $g_requiresDtm = 0; $g_stdout = ''; $g_persistRetries = ''; @@ -458,6 +481,11 @@ sub validatePrefix my $str = "_PERSIST_ZONES"; print " Error: missing $g_prefix$str\n"; #T } + if (($g_opts & 0x80) == 0) { + displayStmt($g_ok); + my $str = "_PROGRAM_ARGS"; + print " Error: missing $g_prefix$str\n"; #T + } resetVars(); } }