diff options
Diffstat (limited to 'ndb/src/common')
-rw-r--r-- | ndb/src/common/Makefile.am | 13 | ||||
-rw-r--r-- | ndb/src/common/Makefile_old (renamed from ndb/src/common/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/debugger/LogLevel.cpp | 19 | ||||
-rw-r--r-- | ndb/src/common/debugger/Makefile.am | 11 | ||||
-rw-r--r-- | ndb/src/common/debugger/Makefile_old (renamed from ndb/src/common/debugger/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/debugger/signaldata/BackupImpl.cpp | 2 | ||||
-rw-r--r-- | ndb/src/common/debugger/signaldata/CntrStart.cpp | 37 | ||||
-rw-r--r-- | ndb/src/common/debugger/signaldata/CreateTrig.cpp | 2 | ||||
-rw-r--r-- | ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp | 6 | ||||
-rw-r--r-- | ndb/src/common/debugger/signaldata/Makefile.am | 32 | ||||
-rw-r--r-- | ndb/src/common/debugger/signaldata/Makefile_old (renamed from ndb/src/common/debugger/signaldata/Makefile) | 1 | ||||
-rw-r--r-- | ndb/src/common/debugger/signaldata/ReadNodesConf.cpp | 24 | ||||
-rw-r--r-- | ndb/src/common/debugger/signaldata/SignalDataPrint.cpp | 8 | ||||
-rw-r--r-- | ndb/src/common/debugger/signaldata/SignalNames.cpp | 36 | ||||
-rw-r--r-- | ndb/src/common/debugger/signaldata/TuxMaint.cpp | 8 | ||||
-rw-r--r-- | ndb/src/common/editline/Makefile.am | 10 | ||||
-rw-r--r-- | ndb/src/common/editline/Makefile_old (renamed from ndb/src/common/editline/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/logger/Makefile.am | 11 | ||||
-rw-r--r-- | ndb/src/common/logger/Makefile_old (renamed from ndb/src/common/logger/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/Config.cpp | 59 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/Config.hpp | 22 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/ConfigInfo.cpp | 3988 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/ConfigInfo.hpp | 49 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/ConfigRetriever.cpp | 386 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/IPCConfig.cpp | 159 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/InitConfigFileParser.cpp | 191 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/InitConfigFileParser.hpp | 77 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/Makefile.am | 18 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/Makefile_old (renamed from ndb/src/common/mgmcommon/Makefile) | 3 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/printConfig/Makefile | 6 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/printConfig/printConfig.cpp | 11 | ||||
-rw-r--r-- | ndb/src/common/portlib/Makefile.am | 18 | ||||
-rw-r--r-- | ndb/src/common/portlib/Makefile_old (renamed from ndb/src/common/portlib/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbCondition.c (renamed from ndb/src/common/portlib/unix/NdbCondition.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbDaemon.c (renamed from ndb/src/common/portlib/unix/NdbDaemon.c) | 6 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbEnv.c (renamed from ndb/src/common/portlib/unix/NdbEnv.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbHost.c (renamed from ndb/src/common/portlib/unix/NdbHost.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbMem.c (renamed from ndb/src/common/portlib/unix/NdbMem.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbMutex.c (renamed from ndb/src/common/portlib/unix/NdbMutex.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbPortLibTest.cpp (renamed from ndb/src/common/portlib/test/NdbPortLibTest.cpp) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbSleep.c (renamed from ndb/src/common/portlib/unix/NdbSleep.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbTCP.c (renamed from ndb/src/common/portlib/unix/NdbTCP.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbThread.c (renamed from ndb/src/common/portlib/unix/NdbThread.c) | 9 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbTick.c (renamed from ndb/src/common/portlib/unix/NdbTick.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/gcc.cpp | 2 | ||||
-rw-r--r-- | ndb/src/common/portlib/memtest.c (renamed from ndb/src/common/portlib/memtest/memtest.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/mmslist.cpp (renamed from ndb/src/common/portlib/mmstest/mmslist.cpp) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/mmstest.cpp (renamed from ndb/src/common/portlib/mmstest/mmstest.cpp) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/munmaptest.cpp (renamed from ndb/src/common/portlib/memtest/munmaptest/munmaptest.cpp) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/memtest/Makefile (renamed from ndb/src/common/portlib/memtest/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/memtest/munmaptest/Makefile (renamed from ndb/src/common/portlib/memtest/munmaptest/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/Makefile (renamed from ndb/src/common/portlib/ose/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbCondition.c (renamed from ndb/src/common/portlib/ose/NdbCondition.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbConditionOSE.h (renamed from ndb/src/common/portlib/ose/NdbConditionOSE.h) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbEnv.c (renamed from ndb/src/common/portlib/ose/NdbEnv.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbHost.c (renamed from ndb/src/common/portlib/ose/NdbHost.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbMem.c (renamed from ndb/src/common/portlib/ose/NdbMem.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbMem_SoftOse.cpp (renamed from ndb/src/common/portlib/ose/NdbMem_SoftOse.cpp) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbMutex.c (renamed from ndb/src/common/portlib/ose/NdbMutex.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbOut.cpp (renamed from ndb/src/common/portlib/ose/NdbOut.cpp) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbSleep.c (renamed from ndb/src/common/portlib/ose/NdbSleep.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbTCP.c (renamed from ndb/src/common/portlib/ose/NdbTCP.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbThread.c (renamed from ndb/src/common/portlib/ose/NdbThread.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/ose/NdbTick.c (renamed from ndb/src/common/portlib/ose/NdbTick.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/test/Makefile (renamed from ndb/src/common/portlib/test/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/unix/Makefile_old (renamed from ndb/src/common/portlib/unix/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/win32/Makefile (renamed from ndb/src/common/portlib/win32/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/win32/NdbCondition.c (renamed from ndb/src/common/portlib/win32/NdbCondition.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/win32/NdbDaemon.c (renamed from ndb/src/common/portlib/win32/NdbDaemon.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/win32/NdbEnv.c (renamed from ndb/src/common/portlib/win32/NdbEnv.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/win32/NdbHost.c (renamed from ndb/src/common/portlib/win32/NdbHost.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/win32/NdbMem.c (renamed from ndb/src/common/portlib/win32/NdbMem.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/win32/NdbMutex.c (renamed from ndb/src/common/portlib/win32/NdbMutex.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/win32/NdbSleep.c (renamed from ndb/src/common/portlib/win32/NdbSleep.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/win32/NdbTCP.c (renamed from ndb/src/common/portlib/win32/NdbTCP.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/win32/NdbThread.c (renamed from ndb/src/common/portlib/win32/NdbThread.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/portlib/old_dirs/win32/NdbTick.c (renamed from ndb/src/common/portlib/win32/NdbTick.c) | 0 | ||||
-rw-r--r-- | ndb/src/common/transporter/Makefile.am | 22 | ||||
-rw-r--r-- | ndb/src/common/transporter/Makefile_old (renamed from ndb/src/common/transporter/Makefile) | 0 | ||||
-rw-r--r-- | ndb/src/common/transporter/Transporter.hpp | 2 | ||||
-rw-r--r-- | ndb/src/common/util/Base64.cpp | 161 | ||||
-rw-r--r-- | ndb/src/common/util/ConfigValues.cpp | 743 | ||||
-rw-r--r-- | ndb/src/common/util/Makefile.am | 17 | ||||
-rw-r--r-- | ndb/src/common/util/Makefile_old (renamed from ndb/src/common/util/Makefile) | 4 | ||||
-rw-r--r-- | ndb/src/common/util/NdbSqlUtil.cpp | 20 | ||||
-rw-r--r-- | ndb/src/common/util/Properties.cpp | 122 | ||||
-rw-r--r-- | ndb/src/common/util/md5_hash.cpp | 2 | ||||
-rw-r--r-- | ndb/src/common/util/new.cpp | 4 | ||||
-rw-r--r-- | ndb/src/common/util/socket_io.cpp | 6 | ||||
-rw-r--r-- | ndb/src/common/util/testConfigValues/Makefile | 12 | ||||
-rw-r--r-- | ndb/src/common/util/testConfigValues/testConfigValues.cpp | 122 | ||||
-rw-r--r-- | ndb/src/common/util/testProperties/Makefile | 5 | ||||
-rw-r--r-- | ndb/src/common/util/testProperties/testProperties.cpp | 11 |
93 files changed, 4235 insertions, 2242 deletions
diff --git a/ndb/src/common/Makefile.am b/ndb/src/common/Makefile.am new file mode 100644 index 00000000000..7fcf2cab636 --- /dev/null +++ b/ndb/src/common/Makefile.am @@ -0,0 +1,13 @@ +SUBDIRS = portlib debugger util logger transporter mgmcommon editline + +noinst_LTLIBRARIES = libcommon.la + +libcommon_la_SOURCES = +libcommon_la_LIBADD = \ + transporter/libtransporter.la \ + debugger/libtrace.la \ + debugger/signaldata/libsignaldataprint.la \ + mgmcommon/libmgmsrvcommon.la \ + portlib/libportlib.la \ + logger/liblogger.la \ + util/libgeneral.la diff --git a/ndb/src/common/Makefile b/ndb/src/common/Makefile_old index ebde75bf3ec..ebde75bf3ec 100644 --- a/ndb/src/common/Makefile +++ b/ndb/src/common/Makefile_old diff --git a/ndb/src/common/debugger/LogLevel.cpp b/ndb/src/common/debugger/LogLevel.cpp index 5348924bbbb..f9e2f318432 100644 --- a/ndb/src/common/debugger/LogLevel.cpp +++ b/ndb/src/common/debugger/LogLevel.cpp @@ -17,13 +17,14 @@ #include <LogLevel.hpp> const LogLevel::LogLevelCategoryName LogLevel::LOGLEVEL_CATEGORY_NAME[] = { - {"LogLevelStartup"}, - {"LogLevelShutdown"}, - {"LogLevelStatistic"}, - {"LogLevelCheckpoint"}, - {"LogLevelNodeRestart"}, - {"LogLevelConnection"}, - {"LogLevelError"}, - {"LogLevelInfo"}, - {"LogLevelGrep"} + { "LogLevelStartup" }, + { "LogLevelShutdown" }, + { "LogLevelStatistic" }, + { "LogLevelCheckpoint" }, + { "LogLevelNodeRestart" }, + { "LogLevelConnection" }, + { "LogLevelError" }, + { "LogLevelWarning" }, + { "LogLevelInfo" }, + { "LogLevelGrep" } }; diff --git a/ndb/src/common/debugger/Makefile.am b/ndb/src/common/debugger/Makefile.am new file mode 100644 index 00000000000..0278d0d2ba0 --- /dev/null +++ b/ndb/src/common/debugger/Makefile.am @@ -0,0 +1,11 @@ +SUBDIRS = signaldata + +noinst_LTLIBRARIES = libtrace.la + +libtrace_la_SOURCES = SignalLoggerManager.cpp DebuggerNames.cpp BlockNames.cpp LogLevel.cpp EventLogger.cpp GrepError.cpp + +include $(top_srcdir)/ndb/config/common.mk.am +include $(top_srcdir)/ndb/config/type_kernel.mk.am + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/ndb/src/common/debugger/Makefile b/ndb/src/common/debugger/Makefile_old index ac3a4475a54..ac3a4475a54 100644 --- a/ndb/src/common/debugger/Makefile +++ b/ndb/src/common/debugger/Makefile_old diff --git a/ndb/src/common/debugger/signaldata/BackupImpl.cpp b/ndb/src/common/debugger/signaldata/BackupImpl.cpp index be9e43e3df1..bdc34d614cf 100644 --- a/ndb/src/common/debugger/signaldata/BackupImpl.cpp +++ b/ndb/src/common/debugger/signaldata/BackupImpl.cpp @@ -24,7 +24,7 @@ printDEFINE_BACKUP_REQ(FILE * out, const Uint32 * data, Uint32 len, Uint16 bno){ sig->backupPtr, sig->backupId, sig->clientRef, sig->clientData); fprintf(out, " backupKey: [ %08x%08x ] DataLength: %d\n", sig->backupKey[0], sig->backupKey[1], sig->backupDataLen); - char buf[sig->nodes.TextLength + 1]; + char buf[_NDB_NODE_BITMASK_SIZE * 8 + 1]; fprintf(out, " Nodes: %s\n", sig->nodes.getText(buf)); return true; } diff --git a/ndb/src/common/debugger/signaldata/CntrStart.cpp b/ndb/src/common/debugger/signaldata/CntrStart.cpp new file mode 100644 index 00000000000..154013f40b0 --- /dev/null +++ b/ndb/src/common/debugger/signaldata/CntrStart.cpp @@ -0,0 +1,37 @@ +#include <signaldata/CntrStart.hpp> + +bool +printCNTR_START_REQ(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) { + const CntrStartReq * const sig = (CntrStartReq *)theData; + fprintf(output, " nodeId: %x\n", sig->nodeId); + fprintf(output, " startType: %x\n", sig->startType); + fprintf(output, " lastGci: %x\n", sig->lastGci); + return true; +} + +bool +printCNTR_START_REF(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) { + const CntrStartRef * const sig = (CntrStartRef *)theData; + fprintf(output, " errorCode: %x\n", sig->errorCode); + fprintf(output, " masterNodeId: %x\n", sig->masterNodeId); + return true; +} + +bool +printCNTR_START_CONF(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) { + const CntrStartConf * const sig = (CntrStartConf *)theData; + fprintf(output, " startType: %x\n", sig->startType); + fprintf(output, " startGci: %x\n", sig->startGci); + fprintf(output, " masterNodeId: %x\n", sig->masterNodeId); + fprintf(output, " noStartNodes: %x\n", sig->noStartNodes); + + char buf[32*NdbNodeBitmask::Size+1]; + fprintf(output, " startedNodes: %s\n", + BitmaskImpl::getText(NdbNodeBitmask::Size, sig->startedNodes, buf)); + fprintf(output, " startingNodes: %s\n", + BitmaskImpl::getText(NdbNodeBitmask::Size, sig->startingNodes, buf)); + return true; +} diff --git a/ndb/src/common/debugger/signaldata/CreateTrig.cpp b/ndb/src/common/debugger/signaldata/CreateTrig.cpp index d8360dec4d5..ddd45080cba 100644 --- a/ndb/src/common/debugger/signaldata/CreateTrig.cpp +++ b/ndb/src/common/debugger/signaldata/CreateTrig.cpp @@ -87,7 +87,7 @@ bool printCREATE_TRIG_REQ(FILE * output, const Uint32 * theData, Uint32 len, Uin fprintf(output, "Monitor all attributes: %s ", (sig->getMonitorAllAttributes())?"true":"false"); const AttributeMask& attributeMask = sig->getAttributeMask(); - char buf[attributeMask.TextLength + 1]; + char buf[MAXNROFATTRIBUTESINWORDS * 8 + 1]; fprintf(output, "Attribute mask: %s", attributeMask.getText(buf)); fprintf(output, "\n"); diff --git a/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp b/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp index ad9cb623c17..9b32fab87ba 100644 --- a/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp +++ b/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp @@ -59,10 +59,10 @@ printFSREADWRITEREQ(FILE * output, const Uint32 * theData, sig->numberOfPages); fprintf(output, " pageData: "); - + unsigned int i; switch(sig->getFormatFlag(sig->operationFlag)){ case FsReadWriteReq::fsFormatListOfPairs: - for (unsigned int i = 0; i < sig->numberOfPages*2; i += 2){ + for (i= 0; i < sig->numberOfPages*2; i += 2){ fprintf(output, " H\'%.8x, H\'%.8x\n", sig->data.pageData[i], sig->data.pageData[i + 1]); } @@ -72,7 +72,7 @@ printFSREADWRITEREQ(FILE * output, const Uint32 * theData, sig->data.pageData[1]); break; case FsReadWriteReq::fsFormatListOfMemPages: - for (unsigned int i = 0; i < (sig->numberOfPages + 1); i++){ + for (i= 0; i < (sig->numberOfPages + 1); i++){ fprintf(output, " H\'%.8x, ", sig->data.pageData[i]); } break; diff --git a/ndb/src/common/debugger/signaldata/Makefile.am b/ndb/src/common/debugger/signaldata/Makefile.am new file mode 100644 index 00000000000..0d6ed45dcef --- /dev/null +++ b/ndb/src/common/debugger/signaldata/Makefile.am @@ -0,0 +1,32 @@ + +noinst_LTLIBRARIES = libsignaldataprint.la + +libsignaldataprint_la_SOURCES = \ + TcKeyReq.cpp TcKeyConf.cpp TcKeyRef.cpp \ + TcRollbackRep.cpp \ + TupKey.cpp TupCommit.cpp LqhKey.cpp \ + FsOpenReq.cpp FsCloseReq.cpp FsRef.cpp FsConf.cpp FsReadWriteReq.cpp\ + SignalDataPrint.cpp SignalNames.cpp \ + ContinueB.cpp DihContinueB.cpp NdbfsContinueB.cpp \ + CloseComReqConf.cpp PackedSignal.cpp PrepFailReqRef.cpp \ + GCPSave.cpp DictTabInfo.cpp \ + AlterTable.cpp AlterTab.cpp \ + CreateTrig.cpp AlterTrig.cpp DropTrig.cpp \ + FireTrigOrd.cpp TrigAttrInfo.cpp \ + CreateIndx.cpp AlterIndx.cpp DropIndx.cpp TcIndx.cpp \ + IndxKeyInfo.cpp IndxAttrInfo.cpp \ + FsAppendReq.cpp ScanTab.cpp \ + BackupImpl.cpp BackupSignalData.cpp \ + UtilSequence.cpp UtilPrepare.cpp UtilDelete.cpp UtilExecute.cpp \ + LqhFrag.cpp DropTab.cpp PrepDropTab.cpp LCP.cpp MasterLCP.cpp \ + CopyGCI.cpp SystemError.cpp StartRec.cpp NFCompleteRep.cpp \ + FailRep.cpp DisconnectRep.cpp SignalDroppedRep.cpp \ + SumaImpl.cpp NdbSttor.cpp CreateFragmentation.cpp \ + UtilLock.cpp TuxMaint.cpp TupAccess.cpp AccLock.cpp \ + LqhTrans.cpp ReadNodesConf.cpp CntrStart.cpp + +include $(top_srcdir)/ndb/config/common.mk.am +include $(top_srcdir)/ndb/config/type_ndbapi.mk.am + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/ndb/src/common/debugger/signaldata/Makefile b/ndb/src/common/debugger/signaldata/Makefile_old index 5e86aaf97c0..bd00667b482 100644 --- a/ndb/src/common/debugger/signaldata/Makefile +++ b/ndb/src/common/debugger/signaldata/Makefile_old @@ -25,6 +25,7 @@ SOURCES = TcKeyReq.cpp TcKeyConf.cpp TcKeyRef.cpp \ CopyGCI.cpp SystemError.cpp StartRec.cpp NFCompleteRep.cpp \ FailRep.cpp DisconnectRep.cpp SignalDroppedRep.cpp \ SumaImpl.cpp NdbSttor.cpp CreateFragmentation.cpp \ + CntrStart.cpp ReadNodesConf.cpp \ UtilLock.cpp TuxMaint.cpp TupAccess.cpp AccLock.cpp \ LqhTrans.cpp diff --git a/ndb/src/common/debugger/signaldata/ReadNodesConf.cpp b/ndb/src/common/debugger/signaldata/ReadNodesConf.cpp new file mode 100644 index 00000000000..103f4a884f1 --- /dev/null +++ b/ndb/src/common/debugger/signaldata/ReadNodesConf.cpp @@ -0,0 +1,24 @@ +#include <signaldata/ReadNodesConf.hpp> + +bool +printREAD_NODES_CONF(FILE * output, const Uint32 * theData, + Uint32 len, Uint16 receiverBlockNo) { + const ReadNodesConf * const sig = (ReadNodesConf *)theData; + fprintf(output, " noOfNodes: %x\n", sig->noOfNodes); + fprintf(output, " ndynamicId: %x\n", sig->ndynamicId); + fprintf(output, " masterNodeId: %x\n", sig->masterNodeId); + + char buf[32*NdbNodeBitmask::Size+1]; + fprintf(output, " allNodes(defined): %s\n", + BitmaskImpl::getText(NdbNodeBitmask::Size, sig->allNodes, buf)); + fprintf(output, " inactiveNodes: %s\n", + BitmaskImpl::getText(NdbNodeBitmask::Size, sig->inactiveNodes, buf)); + fprintf(output, " clusterNodes: %s\n", + BitmaskImpl::getText(NdbNodeBitmask::Size, sig->clusterNodes, buf)); + fprintf(output, " startedNodes: %s\n", + BitmaskImpl::getText(NdbNodeBitmask::Size, sig->startedNodes, buf)); + fprintf(output, " startingNodes: %s\n", + BitmaskImpl::getText(NdbNodeBitmask::Size, sig->startingNodes, buf)); + return true; +} + diff --git a/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp b/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp index 2236d0c0af1..d49e316ad38 100644 --- a/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp +++ b/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp @@ -70,6 +70,8 @@ #include <signaldata/NdbSttor.hpp> #include <signaldata/CreateFragmentation.hpp> #include <signaldata/UtilLock.hpp> +#include <signaldata/CntrStart.hpp> +#include <signaldata/ReadNodesConf.hpp> #include <signaldata/TuxMaint.hpp> #include <signaldata/TupAccess.hpp> #include <signaldata/AccLock.hpp> @@ -240,6 +242,12 @@ SignalDataPrintFunctions[] = { ,{ GSN_UTIL_UNLOCK_REQ, printUTIL_UNLOCK_REQ } ,{ GSN_UTIL_UNLOCK_REF, printUTIL_UNLOCK_REF } ,{ GSN_UTIL_UNLOCK_CONF, printUTIL_UNLOCK_CONF } + ,{ GSN_CNTR_START_REQ, printCNTR_START_REQ } + ,{ GSN_CNTR_START_REF, printCNTR_START_REF } + ,{ GSN_CNTR_START_CONF, printCNTR_START_CONF } + + ,{ GSN_READ_NODESCONF, printREAD_NODES_CONF } + ,{ GSN_TUX_MAINT_REQ, printTUX_MAINT_REQ } ,{ GSN_TUP_READ_ATTRS, printTUP_READ_ATTRS } ,{ GSN_TUP_QUERY_TH, printTUP_QUERY_TH } diff --git a/ndb/src/common/debugger/signaldata/SignalNames.cpp b/ndb/src/common/debugger/signaldata/SignalNames.cpp index 4e5c8603db1..377a588dbb0 100644 --- a/ndb/src/common/debugger/signaldata/SignalNames.cpp +++ b/ndb/src/common/debugger/signaldata/SignalNames.cpp @@ -101,40 +101,23 @@ const GsnName SignalNames [] = { ,{ GSN_ADD_FRAGREQ, "ADD_FRAGREQ" } ,{ GSN_API_FAILCONF, "API_FAILCONF" } ,{ GSN_API_FAILREQ, "API_FAILREQ" } - ,{ GSN_APPL_CHANGEREP, "APPL_CHANGEREP" } - // ,{ GSN_APPL_ERROR, "APPL_ERROR" } - ,{ GSN_APPL_HB, "APPL_HB" } - ,{ GSN_APPL_HBREQ, "APPL_HBREQ" } - ,{ GSN_APPL_REGCONF, "APPL_REGCONF" } - ,{ GSN_APPL_REGREF, "APPL_REGREF" } - ,{ GSN_APPL_REGREQ, "APPL_REGREQ" } - ,{ GSN_APPL_RUN, "APPL_RUN" } - ,{ GSN_APPL_STARTCONF, "APPL_STARTCONF" } - ,{ GSN_APPL_STARTREG, "APPL_STARTREG" } ,{ GSN_CHECK_LCP_STOP, "CHECK_LCP_STOP" } ,{ GSN_CLOSE_COMCONF, "CLOSE_COMCONF" } ,{ GSN_CLOSE_COMREQ, "CLOSE_COMREQ" } ,{ GSN_CM_ACKADD, "CM_ACKADD" } - ,{ GSN_CM_ACKALARM, "CM_ACKALARM" } ,{ GSN_CM_ADD, "CM_ADD" } - ,{ GSN_CM_APPCHG, "CM_APPCHG" } + ,{ GSN_CM_ADD_REP, "CM_ADD_REP" } ,{ GSN_CM_HEARTBEAT, "CM_HEARTBEAT" } - ,{ GSN_CM_INFOCONF, "CM_INFOCONF" } - ,{ GSN_CM_INFOREQ, "CM_INFOREQ" } - ,{ GSN_CM_INIT, "CM_INIT" } ,{ GSN_CM_NODEINFOCONF, "CM_NODEINFOCONF" } ,{ GSN_CM_NODEINFOREF, "CM_NODEINFOREF" } ,{ GSN_CM_NODEINFOREQ, "CM_NODEINFOREQ" } ,{ GSN_CM_REGCONF, "CM_REGCONF" } ,{ GSN_CM_REGREF, "CM_REGREF" } ,{ GSN_CM_REGREQ, "CM_REGREQ" } - ,{ GSN_CM_RUN, "CM_RUN" } - ,{ GSN_CMVMI_CFGCONF, "CMVMI_CFGCONF" } - ,{ GSN_CMVMI_CFGREQ, "CMVMI_CFGREQ" } - ,{ GSN_CNTR_CHANGEREP, "CNTR_CHANGEREP" } - ,{ GSN_CNTR_MASTERCONF, "CNTR_MASTERCONF" } - ,{ GSN_CNTR_MASTERREF, "CNTR_MASTERREF" } - ,{ GSN_CNTR_MASTERREQ, "CNTR_MASTERREQ" } + ,{ GSN_CNTR_START_REQ, "CNTR_START_REQ" } + ,{ GSN_CNTR_START_REF, "CNTR_START_REF" } + ,{ GSN_CNTR_START_CONF, "CNTR_START_CONF" } + ,{ GSN_CNTR_START_REP, "CNTR_START_REP" } ,{ GSN_CNTR_WAITREP, "CNTR_WAITREP" } ,{ GSN_COMMIT, "COMMIT" } ,{ GSN_COMMIT_FAILCONF, "COMMIT_FAILCONF" } @@ -294,9 +277,6 @@ const GsnName SignalNames [] = { ,{ GSN_NEXT_SCANREQ, "NEXT_SCANREQ" } ,{ GSN_NEXTOPERATION, "NEXTOPERATION" } ,{ GSN_NF_COMPLETEREP, "NF_COMPLETEREP" } - ,{ GSN_NODE_STATESCONF, "NODE_STATESCONF" } - ,{ GSN_NODE_STATESREF, "NODE_STATESREF" } - ,{ GSN_NODE_STATESREQ, "NODE_STATESREQ" } ,{ GSN_OPEN_COMCONF, "OPEN_COMCONF" } ,{ GSN_OPEN_COMREF, "OPEN_COMREF" } ,{ GSN_OPEN_COMREQ, "OPEN_COMREQ" } @@ -318,8 +298,8 @@ const GsnName SignalNames [] = { ,{ GSN_SEND_PACKED, "SEND_PACKED" } ,{ GSN_SET_LOGLEVELORD, "SET_LOGLEVELORD" } ,{ GSN_SHRINKCHECK2, "SHRINKCHECK2" } - ,{ GSN_SIZEALT_ACK, "SIZEALT_ACK" } - ,{ GSN_SIZEALT_REP, "SIZEALT_REP" } + ,{ GSN_READ_CONFIG_REQ, "READ_CONFIG_REQ" } + ,{ GSN_READ_CONFIG_CONF, "READ_CONFIG_CONF" } ,{ GSN_SR_FRAGIDCONF, "SR_FRAGIDCONF" } ,{ GSN_SR_FRAGIDREF, "SR_FRAGIDREF" } ,{ GSN_SR_FRAGIDREQ, "SR_FRAGIDREQ" } @@ -396,7 +376,6 @@ const GsnName SignalNames [] = { ,{ GSN_UPDATE_TOCONF, "UPDATE_TOCONF" } ,{ GSN_UPDATE_TOREF, "UPDATE_TOREF" } ,{ GSN_UPDATE_TOREQ, "UPDATE_TOREQ" } - ,{ GSN_VOTE_MASTERORD, "VOTE_MASTERORD" } ,{ GSN_TUP_ALLOCREQ, "TUP_ALLOCREQ" } ,{ GSN_LQH_ALLOCREQ, "LQH_ALLOCREQ" } ,{ GSN_TUP_DEALLOCREQ, "TUP_DEALLOCREQ" } @@ -428,7 +407,6 @@ const GsnName SignalNames [] = { ,{ GSN_CHECKNODEGROUPSREQ, "CHECKNODEGROUPSREQ" } ,{ GSN_CHECKNODEGROUPSCONF, "CHECKNODEGROUPSCONF" } - ,{ GSN_ARBIT_CFG, "ARBIT_CFG" } ,{ GSN_ARBIT_PREPREQ, "ARBIT_PREPREQ" } ,{ GSN_ARBIT_PREPCONF, "ARBIT_PREPCONF" } ,{ GSN_ARBIT_PREPREF, "ARBIT_PREPREF" } diff --git a/ndb/src/common/debugger/signaldata/TuxMaint.cpp b/ndb/src/common/debugger/signaldata/TuxMaint.cpp index 06ac475382c..ba6a299b77d 100644 --- a/ndb/src/common/debugger/signaldata/TuxMaint.cpp +++ b/ndb/src/common/debugger/signaldata/TuxMaint.cpp @@ -24,10 +24,10 @@ printTUX_MAINT_REQ(FILE* output, const Uint32* theData, Uint32 len, Uint16 rbn) //const bool inOut = rbn & (1 << 15); const TuxMaintReq* const sig = (const TuxMaintReq*)theData; fprintf(output, " errorCode=%d\n", sig->errorCode); - fprintf(output, " table: id=%d", sig->tableId); - fprintf(output, " index: id=%d", sig->indexId); - fprintf(output, " fragment: id=%d\n", sig->fragId); - fprintf(output, " tuple: addr=0x%x version=%d\n", sig->tupAddr, sig->tupVersion); + fprintf(output, " table: id=%u", sig->tableId); + fprintf(output, " index: id=%u", sig->indexId); + fprintf(output, " fragment: id=%u\n", sig->fragId); + fprintf(output, " tuple: loc=%u.%u version=%u\n", sig->pageId, sig->pageOffset, sig->tupVersion); const Uint32 opCode = sig->opInfo & 0xFF; const Uint32 opFlag = sig->opInfo >> 8; switch (opCode ) { diff --git a/ndb/src/common/editline/Makefile.am b/ndb/src/common/editline/Makefile.am new file mode 100644 index 00000000000..4f53bdc6326 --- /dev/null +++ b/ndb/src/common/editline/Makefile.am @@ -0,0 +1,10 @@ + +noinst_LIBRARIES = libeditline.a + +libeditline_a_SOURCES = complete.c editline.c sysunix.c + +INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/ndb/include +DEFS = -DANSI_ARROWS -DHAVE_TCGETATTR -DSYS_UNIX + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/ndb/src/common/editline/Makefile b/ndb/src/common/editline/Makefile_old index 800df8f0f31..800df8f0f31 100644 --- a/ndb/src/common/editline/Makefile +++ b/ndb/src/common/editline/Makefile_old diff --git a/ndb/src/common/logger/Makefile.am b/ndb/src/common/logger/Makefile.am new file mode 100644 index 00000000000..0a48214c37c --- /dev/null +++ b/ndb/src/common/logger/Makefile.am @@ -0,0 +1,11 @@ + +noinst_LTLIBRARIES = liblogger.la + +liblogger_la_SOURCES = Logger.cpp LogHandlerList.cpp LogHandler.cpp \ + ConsoleLogHandler.cpp FileLogHandler.cpp SysLogHandler.cpp + +include $(top_srcdir)/ndb/config/common.mk.am +include $(top_srcdir)/ndb/config/type_ndbapi.mk.am + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/ndb/src/common/logger/Makefile b/ndb/src/common/logger/Makefile_old index 994eb86ba35..994eb86ba35 100644 --- a/ndb/src/common/logger/Makefile +++ b/ndb/src/common/logger/Makefile_old diff --git a/ndb/src/common/mgmcommon/Config.cpp b/ndb/src/common/mgmcommon/Config.cpp index 5492394ee4a..c0819b9f463 100644 --- a/ndb/src/common/mgmcommon/Config.cpp +++ b/ndb/src/common/mgmcommon/Config.cpp @@ -26,23 +26,17 @@ //***************************************************************************** Config::Config() { - m_info = new ConfigInfo(); -} - -Config::Config(const Config & org) : - Properties(org) { - - m_info = new ConfigInfo(); -} - -Config::Config(const Properties & org) : - Properties(org) { - - m_info = new ConfigInfo(); + m_oldConfig = 0; + m_configValues = 0; } Config::~Config() { - delete m_info; + if(m_configValues != 0){ + free(m_configValues); + } + + if(m_oldConfig != 0) + delete m_oldConfig; } /*****************************************************************************/ @@ -52,25 +46,33 @@ Config::printAllNameValuePairs(NdbOut &out, const Properties *prop, const char* s) const { Properties::Iterator it(prop); - const Properties * section = m_info->getInfo(s); + const Properties * section = m_info.getInfo(s); for (const char* n = it.first(); n != NULL; n = it.next()) { Uint32 int_value; const char* str_value; + Uint64 int_64; - if (m_info->getStatus(section, n) == ConfigInfo::INTERNAL) + if(!section->contains(n)) continue; - if (m_info->getStatus(section, n) == ConfigInfo::DEPRICATED) + if (m_info.getStatus(section, n) == ConfigInfo::INTERNAL) continue; - if (m_info->getStatus(section, n) == ConfigInfo::NOTIMPLEMENTED) + if (m_info.getStatus(section, n) == ConfigInfo::DEPRICATED) + continue; + if (m_info.getStatus(section, n) == ConfigInfo::NOTIMPLEMENTED) continue; out << n << ": "; - switch (m_info->getType(section, n)) { + switch (m_info.getType(section, n)) { case ConfigInfo::INT: MGM_REQUIRE(prop->get(n, &int_value)); out << int_value; break; + + case ConfigInfo::INT64: + MGM_REQUIRE(prop->get(n, &int_64)); + out << int_64; + break; case ConfigInfo::BOOL: MGM_REQUIRE(prop->get(n, &int_value)); @@ -92,6 +94,7 @@ Config::printAllNameValuePairs(NdbOut &out, /*****************************************************************************/ void Config::printConfigFile(NdbOut &out) const { +#if 0 Uint32 noOfNodes, noOfConnections, noOfComputers; MGM_REQUIRE(get("NoOfNodes", &noOfNodes)); MGM_REQUIRE(get("NoOfConnections", &noOfConnections)); @@ -172,15 +175,12 @@ void Config::printConfigFile(NdbOut &out) const { endl; } } -} - -const -ConfigInfo* Config::getConfigInfo() const { - return m_info; +#endif } Uint32 Config::getGenerationNumber() const { +#if 0 Uint32 ret; const Properties *prop = NULL; @@ -191,10 +191,14 @@ Config::getGenerationNumber() const { return ret; return 0; +#else + return 0; +#endif } int Config::setGenerationNumber(Uint32 gen) { +#if 0 Properties *prop = NULL; getCopy("SYSTEM", &prop); @@ -205,12 +209,16 @@ Config::setGenerationNumber(Uint32 gen) { return 0; } return -1; +#else + return -1; +#endif } bool Config::change(const BaseString §ion, const BaseString ¶m, const BaseString &value) { +#if 0 const char *name; Properties::Iterator it(this); @@ -252,4 +260,7 @@ Config::change(const BaseString §ion, } } return true; +#else + return false; +#endif } diff --git a/ndb/src/common/mgmcommon/Config.hpp b/ndb/src/common/mgmcommon/Config.hpp index 284256d9ed6..26fd53dbed2 100644 --- a/ndb/src/common/mgmcommon/Config.hpp +++ b/ndb/src/common/mgmcommon/Config.hpp @@ -17,7 +17,6 @@ #ifndef Config_H #define Config_H -#include <signaldata/ConfigParamId.hpp> #include <LogLevel.hpp> #include <kernel_types.h> @@ -25,6 +24,9 @@ #include <NdbOut.hpp> #include <ndb_limits.h> #include <Properties.hpp> +#include "ConfigInfo.hpp" + +class ConfigInfo; /** * @class Config @@ -38,14 +40,14 @@ * * The following categories (sections) of configuration parameters exists: * - COMPUTER, DB, MGM, API, TCP, SCI, SHM, OSE + * */ -class Config : public Properties { + +class Config { public: /** * Constructor which loads the object with an Properties object */ - Config(const Config & org); - Config(const Properties & org); Config(); virtual ~Config(); @@ -58,8 +60,6 @@ public: printConfigFile(ndb); } - const class ConfigInfo* getConfigInfo() const; - Uint32 getGenerationNumber() const; int setGenerationNumber(Uint32); @@ -69,7 +69,13 @@ public: const BaseString ¶m, const BaseString &value); + + /** + * Info + */ + const ConfigInfo * getConfigInfo() const { return &m_info;} private: + ConfigInfo m_info; void printAllNameValuePairs(NdbOut &out, const Properties *prop, @@ -78,7 +84,9 @@ private: /** * Information about parameters (min, max values etc) */ - const class ConfigInfo* m_info; +public: + Properties * m_oldConfig; + struct ndb_mgm_configuration * m_configValues; }; #endif // Config_H diff --git a/ndb/src/common/mgmcommon/ConfigInfo.cpp b/ndb/src/common/mgmcommon/ConfigInfo.cpp index da6024d946f..c2b5fdabf01 100644 --- a/ndb/src/common/mgmcommon/ConfigInfo.cpp +++ b/ndb/src/common/mgmcommon/ConfigInfo.cpp @@ -15,7 +15,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ConfigInfo.hpp" +#include <mgmapi_config_parameters.h> + #define MAX_LINE_LENGTH 255 +#define KEY_INTERNAL 0 /**************************************************************************** * Section names @@ -56,9 +59,12 @@ bool fixPortNumber(InitConfigFileParser::Context & ctx, const char *); bool fixShmkey(InitConfigFileParser::Context & ctx, const char *); bool checkDbConstraints(InitConfigFileParser::Context & ctx, const char *); bool checkConnectionConstraints(InitConfigFileParser::Context &, const char *); +bool fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data); bool fixHostname(InitConfigFileParser::Context & ctx, const char * data); bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data); bool fixExtConnection(InitConfigFileParser::Context & ctx, const char * data); +bool fixDepricated(InitConfigFileParser::Context & ctx, const char *); +bool saveInConfigValues(InitConfigFileParser::Context & ctx, const char *); const ConfigInfo::SectionRule ConfigInfo::m_SectionRules[] = { @@ -79,21 +85,12 @@ ConfigInfo::m_SectionRules[] = { { "TCP", fixPortNumber, 0 }, //{ "SHM", fixShmKey, 0 }, - - { "COMPUTER", applyDefaultValues, 0 }, - - { "DB", applyDefaultValues, 0 }, - { "API", applyDefaultValues, 0 }, - { "MGM", applyDefaultValues, 0 }, - { "REP", applyDefaultValues, 0 }, - { "EXTERNAL REP", applyDefaultValues, 0 }, - - { "TCP", applyDefaultValues, 0 }, - { "SHM", applyDefaultValues, 0 }, - { "SCI", applyDefaultValues, 0 }, - { "OSE", applyDefaultValues, 0 }, - { "DB", checkDbConstraints, 0 }, + { "DB", fixNodeHostname, 0 }, + { "API", fixNodeHostname, 0 }, + { "MGM", fixNodeHostname, 0 }, + { "REP", fixNodeHostname, 0 }, + //{ "EXTERNAL REP", fixNodeHostname, 0 }, { "TCP", fixNodeId, "NodeId1" }, { "TCP", fixNodeId, "NodeId2" }, @@ -103,6 +100,11 @@ ConfigInfo::m_SectionRules[] = { { "SCI", fixNodeId, "NodeId2" }, { "OSE", fixNodeId, "NodeId1" }, { "OSE", fixNodeId, "NodeId2" }, + + { "TCP", fixHostname, "HostName1" }, + { "TCP", fixHostname, "HostName2" }, + { "OSE", fixHostname, "HostName1" }, + { "OSE", fixHostname, "HostName2" }, /** * fixExtConnection must be after fixNodeId @@ -112,6 +114,12 @@ ConfigInfo::m_SectionRules[] = { { "SCI", fixExtConnection, 0 }, { "OSE", fixExtConnection, 0 }, + { "*", applyDefaultValues, "user" }, + { "*", fixDepricated, 0 }, + { "*", applyDefaultValues, "system" }, + + { "DB", checkDbConstraints, 0 }, + /** * checkConnectionConstraints must be after fixExtConnection */ @@ -120,24 +128,63 @@ ConfigInfo::m_SectionRules[] = { { "SCI", checkConnectionConstraints, 0 }, { "OSE", checkConnectionConstraints, 0 }, - { "COMPUTER", checkMandatory, 0 }, - { "DB", checkMandatory, 0 }, - { "API", checkMandatory, 0 }, - { "MGM", checkMandatory, 0 }, - { "REP", checkMandatory, 0 }, + { "*", checkMandatory, 0 }, + + { "DB", saveInConfigValues, 0 }, + { "API", saveInConfigValues, 0 }, + { "MGM", saveInConfigValues, 0 }, + { "REP", saveInConfigValues, 0 }, + + { "TCP", saveInConfigValues, 0 }, + { "SHM", saveInConfigValues, 0 }, + { "SCI", saveInConfigValues, 0 }, + { "OSE", saveInConfigValues, 0 } +}; +const int ConfigInfo::m_NoOfRules = sizeof(m_SectionRules)/sizeof(SectionRule); - { "TCP", checkMandatory, 0 }, - { "SHM", checkMandatory, 0 }, - { "SCI", checkMandatory, 0 }, - { "OSE", checkMandatory, 0 }, +/**************************************************************************** + * Config Rules declarations + ****************************************************************************/ +bool addNodeConnections(Vector<ConfigInfo::ConfigRuleSection>§ions, + struct InitConfigFileParser::Context &ctx, + const char * ruleData); + +const ConfigInfo::ConfigRule +ConfigInfo::m_ConfigRules[] = { + { addNodeConnections, 0 }, + { 0, 0 } +}; + +struct DepricationTransform { + const char * m_section; + const char * m_oldName; + const char * m_newName; + double m_add; + double m_mul; +}; - { "TCP", fixHostname, "HostName1" }, - { "TCP", fixHostname, "HostName2" }, - { "OSE", fixHostname, "HostName1" }, - { "OSE", fixHostname, "HostName2" }, +static +const DepricationTransform f_deprication[] = { + { "DB", "NoOfIndexPages", "IndexMemory", 0, 8192 } + ,{ "DB", "MemorySpaceIndexes", "IndexMemory", 0, 8192 } + ,{ "DB", "NoOfDataPages", "DataMemory", 0, 8192 } + ,{ "DB", "MemorySpaceTuples", "DataMemory", 0, 8192 } + ,{ "DB", "TransactionInactiveTimeBeforeAbort", "TransactionInactiveTimeout", + 0, 1 } + ,{ "TCP", "ProcessId1", "NodeId1", 0, 1} + ,{ "TCP", "ProcessId2", "NodeId2", 0, 1} + ,{ "TCP", "SendBufferSize", "SendBufferMemory", 0, 16384 } + ,{ "TCP", "MaxReceiveSize", "ReceiveBufferMemory", 0, 16384 } + + ,{ "SHM", "ProcessId1", "NodeId1", 0, 1} + ,{ "SHM", "ProcessId2", "NodeId2", 0, 1} + ,{ "SCI", "ProcessId1", "NodeId1", 0, 1} + ,{ "SCI", "ProcessId2", "NodeId2", 0, 1} + ,{ "OSE", "ProcessId1", "NodeId1", 0, 1} + ,{ "OSE", "ProcessId2", "NodeId2", 0, 1} + ,{ 0, 0, 0, 0, 0} }; -const int ConfigInfo::m_NoOfRules = sizeof(m_SectionRules)/sizeof(SectionRule); /** * The default constructors create objects with suitable values for the @@ -166,224 +213,340 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { /**************************************************************************** * COMPUTER - ****************************************************************************/ - - {"Id", - "Id", - "COMPUTER", - "Name of computer", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0}, - - {"HostName", - "HostName", - "COMPUTER", - "Hostname of computer (e.g. mysql.com)", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0x7FFFFFFF}, - - {"ByteOrder", - "ByteOrder", - "COMPUTER", - "Not yet implemented", - ConfigInfo::USED, // Actually not used, but since it is MANDATORY, - // we don't want any warning message - false, - ConfigInfo::STRING, - MANDATORY, // Big == 0, Little == 1, NotSet == 2 (?) - 0, - 0x7FFFFFFF}, + ***************************************************************************/ + { + KEY_INTERNAL, + "COMPUTER", + "COMPUTER", + "Computer section", + ConfigInfo::INTERNAL, + false, + ConfigInfo::SECTION, + 0, + 0, 0 }, + + { + KEY_INTERNAL, + "Id", + "COMPUTER", + "Name of computer", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + MANDATORY, + 0, + 0 }, + + { + KEY_INTERNAL, + "HostName", + "COMPUTER", + "Hostname of computer (e.g. alzato.com)", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + CFG_NODE_BYTE_ORDER, + "ByteOrder", + "COMPUTER", + "Not yet implemented", + ConfigInfo::USED, // Actually not used, but since it is MANDATORY, + // we don't want any warning message + false, + ConfigInfo::STRING, + MANDATORY, // Big == 0, Little == 1, NotSet == 2 (?) + 0, + 1 }, /**************************************************************************** - * DB - ****************************************************************************/ - - {"Id", - "Id", - "DB", - "Number identifying the database node (DB)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 1, - (MAX_NODES - 1)}, - - {"Type", - "Type", - "DB", - "Type of node (Should have value DB)", - ConfigInfo::INTERNAL, - false, - ConfigInfo::STRING, - 0, - 0, - 0}, - - {"NoOfReplicas", - "NoOfReplicas", - "DB", - "Number of copies of all data in the database (1-4)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 1, - 4}, - - {"MaxNoOfAttributes", - "MaxNoOfAttributes", - "DB", - "Total number of attributes stored in database. I.e. sum over all tables", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 1000, - 32, - 4096}, + * SYSTEM + ***************************************************************************/ + { + CFG_SECTION_SYSTEM, + "SYSTEM", + "SYSTEM", + "System section", + ConfigInfo::USED, + false, + ConfigInfo::SECTION, + CFG_SECTION_SYSTEM, + 0, + 0 }, + + { + CFG_SYS_NAME, + "Name", + "SYSTEM", + "Name of system (NDB Cluster)", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + MANDATORY, + 0, + 0 }, - {"MaxNoOfTables", - "MaxNoOfTables", - "DB", - "Total number of tables stored in the database", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 32, - 8, - 128}, + { + CFG_SYS_REPLICATION_ROLE, + "ReplicationRole", + "SYSTEM", + "Role in Global Replication (None, Primary, or Standby)", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0 }, - {"MaxNoOfIndexes", - "MaxNoOfIndexes", - "DB", - "Total number of indexes that can be defined in the system", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 128, - 0, - 2048}, - - {"MaxNoOfConcurrentIndexOperations", - "MaxNoOfConcurrentIndexOperations", - "DB", - "Total number of index operations that can execute simultaneously on one DB node", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 8192, - 0, - 1000000 + { + CFG_SYS_PRIMARY_MGM_NODE, + "PrimaryMGMNode", + "SYSTEM", + "Node id of Primary MGM node", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 0, + 0, + 0x7FFFFFFF }, + + { + CFG_SYS_CONFIG_GENERATION, + "ConfigGenerationNumber", + "SYSTEM", + "Configuration generation number", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 0, + 0, + 0x7FFFFFFF }, + + /*************************************************************************** + * DB + ***************************************************************************/ + { + CFG_SECTION_NODE, + "DB", + "DB", + "Node section", + ConfigInfo::USED, + false, + ConfigInfo::SECTION, + NODE_TYPE_DB, + 0, 0 }, - {"MaxNoOfTriggers", - "MaxNoOfTriggers", - "DB", - "Total number of triggers that can be defined in the system", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 768, - 0, - 2432}, - - {"MaxNoOfFiredTriggers", - "MaxNoOfFiredTriggers", - "DB", - "Total number of triggers that can fire simultaneously in one DB node", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 1000, - 0, - 1000000}, - - {"ExecuteOnComputer", - "ExecuteOnComputer", - "DB", - "String referencing an earlier defined COMPUTER", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0x7FFFFFFF}, + { + CFG_NODE_HOST, + "HostName", + "DB", + "Name of computer for this node", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_NODE_SYSTEM, + "System", + "DB", + "Name of system for this node", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_NODE_ID, + "Id", + "DB", + "Number identifying the database node (DB)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + MANDATORY, + 1, + (MAX_NODES - 1) }, + + { + CFG_DB_NO_REPLICAS, + "NoOfReplicas", + "DB", + "Number of copies of all data in the database (1-4)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + MANDATORY, + 1, + 2 }, + + { + CFG_DB_NO_ATTRIBUTES, + "MaxNoOfAttributes", + "DB", + "Total number of attributes stored in database. I.e. sum over all tables", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 1000, + 32, + 4096 }, - {"MaxNoOfSavedMessages", - "MaxNoOfSavedMessages", - "DB", - "Max number of error messages in error log and max number of trace files", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 25, - 0, - 0x7FFFFFFF}, - - {"LockPagesInMainMemory", - "LockPagesInMainMemory", - "DB", - "If set to yes, then NDB Cluster data will not be swapped out to disk", - ConfigInfo::USED, - true, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF}, - - {"SleepWhenIdle", - "SleepWhenIdle", - "DB", - "?", - ConfigInfo::DEPRICATED, - true, - ConfigInfo::BOOL, - true, - 0, - 0x7FFFFFFF}, - - {"NoOfSignalsToExecuteBetweenCommunicationInterfacePoll", - "NoOfSignalsToExecuteBetweenCommunicationInterfacePoll", - "DB", - "?", - ConfigInfo::DEPRICATED, - true, - ConfigInfo::INT, - 20, - 1, - 0x7FFFFFFF}, + { + CFG_DB_NO_TABLES, + "MaxNoOfTables", + "DB", + "Total number of tables stored in the database", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 32, + 8, + 128 }, - {"TimeBetweenWatchDogCheck", - "TimeBetweenWatchDogCheck", - "DB", - "Time between execution checks inside a database node", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 4000, - 70, - 0x7FFFFFFF}, - - {"StopOnError", - "StopOnError", - "DB", - "If set to N, the DB automatically restarts/recovers in case of node failure", - ConfigInfo::USED, - true, - ConfigInfo::BOOL, - true, - 0, - 0x7FFFFFFF}, - - { "RestartOnErrorInsert", + { + CFG_DB_NO_INDEXES, + "MaxNoOfIndexes", + "DB", + "Total number of indexes that can be defined in the system", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 128, + 0, + 2048 }, + + { + CFG_DB_NO_INDEX_OPS, + "MaxNoOfConcurrentIndexOperations", + "DB", + "Total number of index operations that can execute simultaneously on one DB node", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 8192, + 0, + 1000000 + }, + + { + CFG_DB_NO_TRIGGERS, + "MaxNoOfTriggers", + "DB", + "Total number of triggers that can be defined in the system", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 768, + 0, + 2432 }, + + { + CFG_DB_NO_TRIGGER_OPS, + "MaxNoOfFiredTriggers", + "DB", + "Total number of triggers that can fire simultaneously in one DB node", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 1000, + 0, + 1000000 }, + + { + KEY_INTERNAL, + "ExecuteOnComputer", + "DB", + "String referencing an earlier defined COMPUTER", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + CFG_DB_NO_SAVE_MSGS, + "MaxNoOfSavedMessages", + "DB", + "Max number of error messages in error log and max number of trace files", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 25, + 0, + 0x7FFFFFFF }, + + { + CFG_DB_MEMLOCK, + "LockPagesInMainMemory", + "DB", + "If set to yes, then NDB Cluster data will not be swapped out to disk", + ConfigInfo::USED, + true, + ConfigInfo::BOOL, + false, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "SleepWhenIdle", + "DB", + 0, + ConfigInfo::DEPRICATED, + true, + ConfigInfo::BOOL, + true, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "NoOfSignalsToExecuteBetweenCommunicationInterfacePoll", + "DB", + 0, + ConfigInfo::DEPRICATED, + true, + ConfigInfo::INT, + 20, + 1, + 0x7FFFFFFF }, + + { + CFG_DB_WATCHDOG_INTERVAL, + "TimeBetweenWatchDogCheck", + "DB", + "Time between execution checks inside a database node", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 4000, + 70, + 0x7FFFFFFF }, + + { + CFG_DB_STOP_ON_ERROR, + "StopOnError", + "DB", + "If set to N, the DB automatically restarts/recovers in case of node failure", + ConfigInfo::USED, + true, + ConfigInfo::BOOL, + true, + 0, + 0x7FFFFFFF }, + + { + CFG_DB_STOP_ON_ERROR_INSERT, "RestartOnErrorInsert", "DB", "See src/kernel/vm/Emulator.hpp NdbRestartType for details", @@ -394,41 +557,45 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { 0, 4 }, - {"MaxNoOfConcurrentOperations", - "MaxNoOfConcurrentOperations", - "DB", - "Max no of op:s on DB (op:s within a transaction are concurrently executed)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 8192, - 32, - 1000000}, - - {"MaxNoOfConcurrentTransactions", - "MaxNoOfConcurrentTransactions", - "DB", - "Max number of transaction executing concurrently on the DB node", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 4096, - 32, - 1000000}, - - {"MaxNoOfConcurrentScans", - "MaxNoOfConcurrentScans", - "DB", - "Max number of scans executing concurrently on the DB node", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 25, - 2, - 500}, - - {"TransactionBufferMemory", - "TransactionBufferMemory", + { + CFG_DB_NO_OPS, + "MaxNoOfConcurrentOperations", + "DB", + "Max no of op:s on DB (op:s within a transaction are concurrently executed)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 8192, + 32, + 1000000 }, + + { + CFG_DB_NO_TRANSACTIONS, + "MaxNoOfConcurrentTransactions", + "DB", + "Max number of transaction executing concurrently on the DB node", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 4096, + 32, + 1000000 }, + + { + CFG_DB_NO_SCANS, + "MaxNoOfConcurrentScans", + "DB", + "Max number of scans executing concurrently on the DB node", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 25, + 2, + 500 }, + + { + CFG_DB_TRANS_BUFFER_MEM, + "TransactionBufferMemory", "DB", "Dynamic buffer space (in bytes) for key and attribute data allocated for each DB node", ConfigInfo::USED, @@ -436,437 +603,442 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::INT, 1024000, 1024, - 0x7FFFFFFF}, + 0x7FFFFFFF }, - {"NoOfIndexPages", - "NoOfIndexPages", - "DB", - "Number of 8k byte pages on each DB node for storing indexes", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 3000, - 128, - 192000}, - - {"MemorySpaceIndexes", - "NoOfIndexPages", - "DB", - "Depricated", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 128, - 192000}, - - {"NoOfDataPages", - "NoOfDataPages", - "DB", - "Number of 8k byte pages on each DB node for storing data", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 10000, - 128, - 400000}, - - {"MemorySpaceTuples", - "NoOfDataPages", - "DB", - "Depricated", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 128, - 400000}, - - {"NoOfDiskBufferPages", - "NoOfDiskBufferPages", - "DB", - "?", - ConfigInfo::NOTIMPLEMENTED, - false, - ConfigInfo::INT, - 0, - 0, - 0}, - - {"MemoryDiskPages", - "NoOfDiskBufferPages", - "DB", - "?", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0}, - - {"NoOfFreeDiskClusters", - "NoOfFreeDiskClusters", - "DB", - "?", - ConfigInfo::NOTIMPLEMENTED, - false, - ConfigInfo::INT, - 0, - 0, - 0}, - - {"NoOfDiskClusters", - "NoOfDiskClusters", - "DB", - "?", - ConfigInfo::NOTIMPLEMENTED, - false, - ConfigInfo::INT, - 0, - 0, - 0x7FFFFFFF}, + { + CFG_DB_INDEX_MEM, + "IndexMemory", + "DB", + "Number bytes on each DB node allocated for storing indexes", + ConfigInfo::USED, + false, + ConfigInfo::INT64, + 3000 * 8192, + 128 * 8192, + ((Uint64)192000) * ((Uint64)8192) }, + + { + KEY_INTERNAL, + "NoOfIndexPages", + "DB", + "IndexMemory", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + 3000, + 128, + 192000 }, + + { + KEY_INTERNAL, + "MemorySpaceIndexes", + "DB", + "IndexMemory", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + UNDEFINED, + 128, + 192000 }, + + { + CFG_DB_DATA_MEM, + "DataMemory", + "DB", + "Number bytes on each DB node allocated for storing data", + ConfigInfo::USED, + false, + ConfigInfo::INT64, + 10000 * 8192, + 128 * 8192, + ((Uint64)400000) * ((Uint64)8192) }, + + { + KEY_INTERNAL, + "NoOfDataPages", + "DB", + "DataMemory", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + 10000, + 128, + 400000 }, + + { + KEY_INTERNAL, + "MemorySpaceTuples", + "DB", + "DataMemory", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + UNDEFINED, + 128, + 400000 }, - {"TimeToWaitAlive", - "TimeToWaitAlive", - "DB", - "Time to wait for other nodes to become alive during initial system start", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 25, - 2, - 4000}, - - {"HeartbeatIntervalDbDb", - "HeartbeatIntervalDbDb", - "DB", - "Time between DB-to-DB heartbeats. DB considered dead after 3 missed HBs", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 1500, - 10, - 0x7FFFFFFF}, - - {"HeartbeatIntervalDbApi", - "HeartbeatIntervalDbApi", - "DB", - "Time between API-to-DB heartbeats. API connection closed after 3 missed HBs", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 1500, - 100, - 0x7FFFFFFF}, - - {"TimeBetweenLocalCheckpoints", - "TimeBetweenLocalCheckpoints", - "DB", - "Time between taking snapshots of the database (expressed in 2log of bytes)", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 20, - 0, - 31}, - - {"TimeBetweenGlobalCheckpoints", - "TimeBetweenGlobalCheckpoints", - "DB", - "Time between doing group commit of transactions to disk", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 2000, - 10, - 32000}, - - {"NoOfFragmentLogFiles", - "NoOfFragmentLogFiles", - "DB", - "No of 16 Mbyte Redo log files in each of 4 file sets belonging to DB node", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 8, - 1, - 0x7FFFFFFF}, - - {"MaxNoOfOpenFiles", - "MaxNoOfOpenFiles", - "DB", - "Max number of files open per DB node.(One thread is created per file)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 40, - 20, - 256}, - - {"NoOfConcurrentCheckpointsDuringRestart", - "NoOfConcurrentCheckpointsDuringRestart", - "DB", - "?", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 1, - 1, - 4}, + { + CFG_DB_START_PARTIAL_TIMEOUT, + "StartPartialTimeout", + "DB", + "Time to wait before trying to start wo/ all nodes. 0=Wait forever", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 30000, + 0, + ~0 }, + + { + CFG_DB_START_PARTITION_TIMEOUT, + "StartPartitionedTimeout", + "DB", + "Time to wait before trying to start partitioned. 0=Wait forever", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 60000, + 0, + ~0 }, - {"TimeBetweenInactiveTransactionAbortCheck", - "TimeBetweenInactiveTransactionAbortCheck", - "DB", - "Time between inactive transaction checks", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 1000, - 1000, - 0x7FFFFFFF}, + { + CFG_DB_START_FAILURE_TIMEOUT, + "StartFailureTimeout", + "DB", + "Time to wait before terminating. 0=Wait forever", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 5*60000, + 0, + ~0 }, + + { + KEY_INTERNAL, + "TimeToWaitAlive", + "DB", + "Start{Partial/Partitioned/Failure}Time", + ConfigInfo::DEPRICATED, + true, + ConfigInfo::INT, + 25, + 2, + 4000 }, + + { + CFG_DB_HEARTBEAT_INTERVAL, + "HeartbeatIntervalDbDb", + "DB", + "Time between DB-DB heartbeats. DB considered dead after 3 missed HBs", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 1500, + 10, + 0x7FFFFFFF }, + + { + CFG_DB_API_HEARTBEAT_INTERVAL, + "HeartbeatIntervalDbApi", + "DB", + "Time between API-DB heartbeats. API connection closed after 3 missed HBs", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 1500, + 100, + 0x7FFFFFFF }, + + { + CFG_DB_LCP_INTERVAL, + "TimeBetweenLocalCheckpoints", + "DB", + "Time between taking snapshots of the database (expressed in 2log of bytes)", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 20, + 0, + 31 }, + + { + CFG_DB_GCP_INTERVAL, + "TimeBetweenGlobalCheckpoints", + "DB", + "Time between doing group commit of transactions to disk", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 2000, + 10, + 32000 }, + + { + CFG_DB_NO_REDOLOG_FILES, + "NoOfFragmentLogFiles", + "DB", + "No of 16 Mbyte Redo log files in each of 4 file sets belonging to DB node", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 8, + 1, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "MaxNoOfOpenFiles", + "DB", + "Max number of files open per DB node.(One thread is created per file)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 40, + 20, + 256 }, + - {"TransactionInactiveTimeout", - "TransactionInactiveTimeout", - "DB", - "Time application can wait before executing another transaction part (ms).\n" - "This is the time the transaction coordinator waits for the application\n" - "to execute or send another part (query, statement) of the transaction.\n" - "If the application takes too long time, the transaction gets aborted.\n" - "Timeout set to 0 means that we don't timeout at all on application wait.", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 3000, - 0, - 0x7FFFFFFF}, - - {"TransactionDeadlockDetectionTimeout", - "TransactionDeadlockDetectionTimeout", - "DB", - "Time transaction can be executing in a DB node (ms).\n" - "This is the time the transaction coordinator waits for each database node\n" - "of the transaction to execute a request. If the database node takes too\n" - "long time, the transaction gets aborted.", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 3000, - 50, - 0x7FFFFFFF}, - - {"TransactionInactiveTimeBeforeAbort", - "TransactionInactiveTimeBeforeAbort", - "DB", - "Time a transaction can be inactive before getting aborted (ms)", - ConfigInfo::DEPRICATED, - true, - ConfigInfo::INT, - 3000, - 20, - 0x7FFFFFFF}, - - {"NoOfConcurrentProcessesHandleTakeover", - "NoOfConcurrentProcessesHandleTakeover", - "DB", - "?", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 1, - 1, - 15}, + { + CFG_DB_TRANSACTION_CHECK_INTERVAL, + "TimeBetweenInactiveTransactionAbortCheck", + "DB", + "Time between inactive transaction checks", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 1000, + 1000, + 0x7FFFFFFF }, - {"NoOfConcurrentCheckpointsAfterRestart", - "NoOfConcurrentCheckpointsAfterRestart", - "DB", - "?", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 1, - 1, - 4}, + { + CFG_DB_TRANSACTION_INACTIVE_TIMEOUT, + "TransactionInactiveTimeout", + "DB", + "Time application can wait before executing another transaction part (ms).\n" + "This is the time the transaction coordinator waits for the application\n" + "to execute or send another part (query, statement) of the transaction.\n" + "If the application takes too long time, the transaction gets aborted.\n" + "Timeout set to 0 means that we don't timeout at all on application wait.", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 3000, + 0, + 0x7FFFFFFF }, + + { + CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT, + "TransactionDeadlockDetectionTimeout", + "DB", + "Time transaction can be executing in a DB node (ms).\n" + "This is the time the transaction coordinator waits for each database node\n" + "of the transaction to execute a request. If the database node takes too\n" + "long time, the transaction gets aborted.", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 3000, + 50, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "TransactionInactiveTimeBeforeAbort", + "DB", + "TransactionInactiveTimeout", + ConfigInfo::DEPRICATED, + true, + ConfigInfo::INT, + 3000, + 20, + 0x7FFFFFFF }, - {"NoOfDiskPagesToDiskDuringRestartTUP", - "NoOfDiskPagesToDiskDuringRestartTUP", - "DB", - "?", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 50, - 1, - 0x7FFFFFFF}, - - {"NoOfDiskPagesToDiskAfterRestartTUP", - "NoOfDiskPagesToDiskAfterRestartTUP", - "DB", - "?", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 10, - 1, - 0x7FFFFFFF}, - - {"NoOfDiskPagesToDiskDuringRestartACC", - "NoOfDiskPagesToDiskDuringRestartACC", - "DB", - "?", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 25, - 1, - 0x7FFFFFFF}, - - {"NoOfDiskPagesToDiskAfterRestartACC", - "NoOfDiskPagesToDiskAfterRestartACC", - "DB", - "?", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 5, - 1, - 0x7FFFFFFF}, + { + KEY_INTERNAL, + "NoOfDiskPagesToDiskDuringRestartTUP", + "DB", + "?", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 50, + 1, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "NoOfDiskPagesToDiskAfterRestartTUP", + "DB", + "?", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 10, + 1, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "NoOfDiskPagesToDiskDuringRestartACC", + "DB", + "?", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 25, + 1, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "NoOfDiskPagesToDiskAfterRestartACC", + "DB", + "?", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 5, + 1, + 0x7FFFFFFF }, - {"NoOfDiskClustersPerDiskFile", - "NoOfDiskClustersPerDiskFile", - "DB", - "?", - ConfigInfo::NOTIMPLEMENTED, - false, - ConfigInfo::INT, - 0, - 0, - 0x7FFFFFFF}, + + { + CFG_DB_DISCLESS, + "Discless", + "DB", + "Run wo/ disk", + ConfigInfo::USED, + true, + ConfigInfo::BOOL, + 0, + 0, + 1}, - {"NoOfDiskFiles", - "NoOfDiskFiles", - "DB", - "?", - ConfigInfo::NOTIMPLEMENTED, - false, - ConfigInfo::INT, - 0, - 0, - 0x7FFFFFFF}, - - {"ArbitrationTimeout", - "ArbitrationTimeout", - "DB", - "Max time (milliseconds) database partion waits for arbitration signal", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 1000, - 10, - 0x7FFFFFFF}, - - {"FileSystemPath", - "FileSystemPath", - "DB", - "Path to directory where the DB node stores its data (directory must exist)", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"LogLevelStartup", - "LogLevelStartup", - "DB", - "Node startup info printed on stdout", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 1, - 0, - 15}, + { + CFG_DB_ARBIT_TIMEOUT, + "ArbitrationTimeout", + "DB", + "Max time (milliseconds) database partion waits for arbitration signal", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 1000, + 10, + 0x7FFFFFFF }, + + { + CFG_DB_FILESYSTEM_PATH, + "FileSystemPath", + "DB", + "Path to directory where the DB node stores its data (directory must exist)", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_LOGLEVEL_STARTUP, + "LogLevelStartup", + "DB", + "Node startup info printed on stdout", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 1, + 0, + 15 }, - {"LogLevelShutdown", - "LogLevelShutdown", - "DB", - "Node shutdown info printed on stdout", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 0, - 0, - 15}, - - {"LogLevelStatistic", - "LogLevelStatistic", - "DB", - "Transaction, operation, transporter info printed on stdout", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 0, - 0, - 15}, - - {"LogLevelCheckpoint", - "LogLevelCheckpoint", - "DB", - "Local and Global checkpoint info printed on stdout", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 0, - 0, - 15}, - - {"LogLevelNodeRestart", - "LogLevelNodeRestart", - "DB", - "Node restart, node failure info printed on stdout", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 0, - 0, - 15}, - - {"LogLevelConnection", - "LogLevelConnection", - "DB", - "Node connect/disconnect info printed on stdout", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 0, - 0, - 15}, - - {"LogLevelError", - "LogLevelError", - "DB", - "Transporter, heartbeat errors printed on stdout", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 0, - 0, - 15}, - - {"LogLevelInfo", - "LogLevelInfo", - "DB", - "Heartbeat and log info printed on stdout", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 0, - 0, - 15}, + { + CFG_LOGLEVEL_SHUTDOWN, + "LogLevelShutdown", + "DB", + "Node shutdown info printed on stdout", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 0, + 0, + 15 }, + + { + CFG_LOGLEVEL_STATISTICS, + "LogLevelStatistic", + "DB", + "Transaction, operation, transporter info printed on stdout", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 0, + 0, + 15 }, + + { + CFG_LOGLEVEL_CHECKPOINT, + "LogLevelCheckpoint", + "DB", + "Local and Global checkpoint info printed on stdout", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 0, + 0, + 15 }, + + { + CFG_LOGLEVEL_NODERESTART, + "LogLevelNodeRestart", + "DB", + "Node restart, node failure info printed on stdout", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 0, + 0, + 15 }, + + { + CFG_LOGLEVEL_CONNECTION, + "LogLevelConnection", + "DB", + "Node connect/disconnect info printed on stdout", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 0, + 0, + 15 }, + + { + CFG_LOGLEVEL_ERROR, + "LogLevelError", + "DB", + "Transporter, heartbeat errors printed on stdout", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 0, + 0, + 15 }, + + { + CFG_LOGLEVEL_INFO, + "LogLevelInfo", + "DB", + "Heartbeat and log info printed on stdout", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 0, + 0, + 15 }, /** * Backup */ - { "ParallelBackups", + { + CFG_DB_PARALLEL_BACKUPS, "ParallelBackups", "DB", "Maximum number of parallel backups", @@ -877,7 +1049,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { 1, 1 }, - { "BackupMemory", + { + CFG_DB_BACKUP_MEM, "BackupMemory", "DB", "Total memory allocated for backups per node (in bytes)", @@ -888,7 +1061,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { 0, 0x7FFFFFFF }, - { "BackupDataBufferSize", + { + CFG_DB_BACKUP_DATA_BUFFER_MEM, "BackupDataBufferSize", "DB", "Default size of databuffer for a backup (in bytes)", @@ -899,7 +1073,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { 0, 0x7FFFFFFF }, - { "BackupLogBufferSize", + { + CFG_DB_BACKUP_LOG_BUFFER_MEM, "BackupLogBufferSize", "DB", "Default size of logbuffer for a backup (in bytes)", @@ -910,7 +1085,8 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { 0, 0x7FFFFFFF }, - { "BackupWriteSize", + { + CFG_DB_BACKUP_WRITE_SIZE, "BackupWriteSize", "DB", "Default size of filesystem writes made by backup (in bytes)", @@ -921,967 +1097,1098 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { 0, 0x7FFFFFFF }, - /**************************************************************************** + /*************************************************************************** * REP - ****************************************************************************/ - - {"Id", - "Id", - "REP", - "Number identifying replication node (REP)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 1, - (MAX_NODES - 1)}, - - {"Type", - "Type", - "REP", - "Type of node (Should have value REP)", - ConfigInfo::INTERNAL, - false, - ConfigInfo::STRING, - 0, - 0, - 0}, - - {"ExecuteOnComputer", - "ExecuteOnComputer", - "REP", - "String referencing an earlier defined COMPUTER", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0x7FFFFFFF}, + ***************************************************************************/ + { + CFG_SECTION_NODE, + "REP", + "REP", + "Node section", + ConfigInfo::USED, + false, + ConfigInfo::SECTION, + NODE_TYPE_REP, + 0, 0 + }, - /**************************************************************************** - * EXTERNAL REP - ****************************************************************************/ - - {"Id", - "Id", - "EXTERNAL REP", - "Number identifying external (i.e. in another NDB Cluster) replication node (REP)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 1, - (MAX_NODES - 1)}, - - {"Type", - "Type", - "EXTERNAL REP", - "Type of node (Should have value REP)", - ConfigInfo::INTERNAL, - false, - ConfigInfo::STRING, - 0, - 0, - 0}, - - {"System", - "System", - "EXTERNAL REP", - "System name of system hosting node", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - 0, - 0, - 0}, - - {"HeartbeatIntervalRepRep", - "HeartbeatIntervalRepRep", - "EXTERNAL REP", - "Time between REP-REP heartbeats. Connection closed after 3 missed HBs", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 3000, - 100, - 0x7FFFFFFF}, + { + CFG_NODE_HOST, + "HostName", + "REP", + "Name of computer for this node", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, - /**************************************************************************** + { + CFG_NODE_SYSTEM, + "System", + "REP", + "Name of system for this node", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_NODE_ID, + "Id", + "REP", + "Number identifying replication node (REP)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + MANDATORY, + 1, + (MAX_NODES - 1) }, + + { + KEY_INTERNAL, + "ExecuteOnComputer", + "REP", + "String referencing an earlier defined COMPUTER", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + CFG_REP_HEARTBEAT_INTERVAL, + "HeartbeatIntervalRepRep", + "REP", + "Time between REP-REP heartbeats. Connection closed after 3 missed HBs", + ConfigInfo::USED, + true, + ConfigInfo::INT, + 3000, + 100, + 0x7FFFFFFF }, + + /*************************************************************************** * API - ****************************************************************************/ - - {"Id", - "Id", - "API", - "Number identifying application node (API)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 1, - (MAX_NODES - 1)}, - - {"Type", - "Type", - "API", - "Type of node (Should have value API)", - ConfigInfo::INTERNAL, - false, - ConfigInfo::STRING, - 0, - 0, - 0}, - - {"ExecuteOnComputer", - "ExecuteOnComputer", - "API", - "String referencing an earlier defined COMPUTER", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0x7FFFFFFF}, - - {"MaxNoOfSavedMessages", - "MaxNoOfSavedMessages", - "API", - "Max number of error messages in error log and max number of trace files", - ConfigInfo::USED, - true, - ConfigInfo::INT, - 25, - 0, - 0x7FFFFFFF}, - - {"SleepWhenIdle", - "SleepWhenIdle", - "API", - "?", - ConfigInfo::DEPRICATED, - true, - ConfigInfo::BOOL, - true, - 0, - 0x7FFFFFFF}, - - {"ArbitrationRank", - "ArbitrationRank", - "API", - "If 0, then API is not arbitrator. Kernel selects arbitrators in order 1, 2", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 2, - 0, - 2}, - - {"ArbitrationDelay", - "ArbitrationDelay", - "API", - "When asked to arbitrate, arbitrator waits this long before voting (msec)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 0, - 0, - 0x7FFFFFFF}, + ***************************************************************************/ + { + CFG_SECTION_NODE, + "API", + "API", + "Node section", + ConfigInfo::USED, + false, + ConfigInfo::SECTION, + NODE_TYPE_API, + 0, 0 + }, + + { + CFG_NODE_HOST, + "HostName", + "API", + "Name of computer for this node", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_NODE_SYSTEM, + "System", + "API", + "Name of system for this node", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_NODE_ID, + "Id", + "API", + "Number identifying application node (API)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + MANDATORY, + 1, + (MAX_NODES - 1) }, + + { + KEY_INTERNAL, + "ExecuteOnComputer", + "API", + "String referencing an earlier defined COMPUTER", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + CFG_NODE_ARBIT_RANK, + "ArbitrationRank", + "API", + "If 0, then API is not arbitrator. Kernel selects arbitrators in order 1, 2", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 2, + 0, + 2 }, + + { + CFG_NODE_ARBIT_DELAY, + "ArbitrationDelay", + "API", + "When asked to arbitrate, arbitrator waits this long before voting (msec)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 0, + 0, + 0x7FFFFFFF }, /**************************************************************************** * MGM - ****************************************************************************/ - - {"Id", - "Id", - "MGM", - "Number identifying the management server node (MGM)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 1, - (MAX_NODES - 1)}, + ***************************************************************************/ + { + CFG_SECTION_NODE, + "MGM", + "MGM", + "Node section", + ConfigInfo::USED, + false, + ConfigInfo::SECTION, + NODE_TYPE_MGM, + 0, 0 + }, + + { + CFG_NODE_HOST, + "HostName", + "MGM", + "Name of computer for this node", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_NODE_SYSTEM, + "System", + "MGM", + "Name of system for this node", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_NODE_ID, + "Id", + "MGM", + "Number identifying the management server node (MGM)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + MANDATORY, + 1, + (MAX_NODES - 1) }, + + { + CFG_LOG_DESTINATION, + "LogDestination", + "MGM", + "String describing where logmessages are sent", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + 0, + 0, + 0x7FFFFFFF }, - {"Type", - "Type", - "MGM", - "Type of node (Should have value MGM)", - ConfigInfo::INTERNAL, - false, - ConfigInfo::STRING, - 0, - 0, - 0}, - - {"ExecuteOnComputer", - "ExecuteOnComputer", - "MGM", - "String referencing an earlier defined COMPUTER", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0x7FFFFFFF}, - - // SHOULD THIS REALLY BE DEFINABLE FOR MGM ??? - {"MaxNoOfSavedMessages", - "MaxNoOfSavedMessages", - "MGM", - "Max number of error messages in error log and max number of trace files", - ConfigInfo::DEPRICATED, - true, - ConfigInfo::INT, - 25, - 0, - 0x7FFFFFFF}, + { + KEY_INTERNAL, + "ExecuteOnComputer", + "MGM", + "String referencing an earlier defined COMPUTER", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + MANDATORY, + 0, + 0x7FFFFFFF }, - {"MaxNoOfSavedEvents", - "MaxNoOfSavedEvents", - "MGM", - "", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 100, - 0, - 0x7FFFFFFF}, - - {"PortNumber", - "PortNumber", - "MGM", - "Port number to give commands to/fetch configurations from management server", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 2200, - 0, - 0x7FFFFFFF}, - - {"PortNumberStats", - "PortNumberStats", - "MGM", - "Port number used to get statistical information from a management server", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 2199, - 0, - 0x7FFFFFFF}, - - {"ArbitrationRank", - "ArbitrationRank", - "MGM", - "If 0, then MGM is not arbitrator. Kernel selects arbitrators in order 1, 2", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 2, - 0, - 2}, - - {"ArbitrationDelay", - "ArbitrationDelay", - "MGM", - "", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 0, - 0, - 0x7FFFFFFF}, - - /***************************************************************************** - * SYSTEM - ****************************************************************************/ - - {"Name", - "Name", - "SYSTEM", - "Name of system (NDB Cluster)", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0}, - - {"ReplicationRole", - "ReplicationRole", - "SYSTEM", - "Role in Global Replication (None, Primary, or Standby)", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0}, - - {"LogDestination", - "LogDestination", - "MGM", - "String describing where logmessages are sent", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - 0, - 0, - 0x7FFFFFFF}, - - {"PrimaryMGMNode", - "PrimaryMGMNode", - "SYSTEM", - "Node id of Primary MGM node", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 0, - 0, - 0x7FFFFFFF}, - - {"ConfigGenerationNumber", - "ConfigGenerationNumber", - "SYSTEM", - "Configuration generation number", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 0, - 0, - 0x7FFFFFFF}, - - {"Name", - "Name", - "EXTERNAL SYSTEM", - "Name of external system (another NDB Cluster)", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0}, - - /***************************************************************************** + { + KEY_INTERNAL, + "MaxNoOfSavedEvents", + "MGM", + "", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 100, + 0, + 0x7FFFFFFF }, + + { + CFG_MGM_PORT, + "PortNumber", + "MGM", + "Port number to give commands to/fetch configurations from management server", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 2200, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "PortNumberStats", + "MGM", + "Port number used to get statistical information from a management server", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 2199, + 0, + 0x7FFFFFFF }, + + { + CFG_NODE_ARBIT_RANK, + "ArbitrationRank", + "MGM", + "If 0, then MGM is not arbitrator. Kernel selects arbitrators in order 1, 2", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 2, + 0, + 2 }, + + { + CFG_NODE_ARBIT_DELAY, + "ArbitrationDelay", + "MGM", + "", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 0, + 0, + 0x7FFFFFFF }, + + /**************************************************************************** * TCP - ****************************************************************************/ - - {"Type", - "Type", - "TCP", - "", - ConfigInfo::INTERNAL, - false, - ConfigInfo::STRING, - 0, - 0, - 0x7FFFFFFF}, - - {"HostName1", - "HostName1", - "TCP", - "Name of computer on one side of the connection", - ConfigInfo::INTERNAL, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"HostName2", - "HostName2", - "TCP", - "Name of computer on one side of the connection", - ConfigInfo::INTERNAL, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"NodeId1", - "NodeId1", - "TCP", - "Id of node (DB, API or MGM) on one side of the connection", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0x7FFFFFFF}, - - {"ProcessId1", - "NodeId1", - "TCP", - "Depricated", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"NodeId2", - "NodeId2", - "TCP", - "Id of node (DB, API or MGM) on one side of the connection", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0x7FFFFFFF}, - - {"ProcessId2", - "NodeId2", - "TCP", - "Depricated", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"IpAddress1", - "HostName1", - "TCP", - "IP address of first node in connection.", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"IpAddress2", - "HostName2", - "TCP", - "IP address of second node in connection.", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0}, - - {"SendSignalId", - "SendSignalId", - "TCP", - "Sends id in each signal. Used in trace files.", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - true, - 0, - 0x7FFFFFFF}, - - {"Compression", - "Compression", - "TCP", - "If compression is enabled, then all signals between nodes are compressed", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF}, - - {"Checksum", - "Checksum", - "TCP", - "If checksum is enabled, all signals between nodes are checked for errors", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF}, - - {"PortNumber", - "PortNumber", - "TCP", - "Port used for this transporter", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 0, - 0x7FFFFFFF}, - - {"SendBufferSize", - "SendBufferSize", - "TCP", - "Size of buffer for signals sent from this node (in no of signals)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 16, - 1, - 0x7FFFFFFF}, + ***************************************************************************/ + { + CFG_SECTION_CONNECTION, + "TCP", + "TCP", + "Connection section", + ConfigInfo::USED, + false, + ConfigInfo::SECTION, + CONNECTION_TYPE_TCP, + 0, 0 + }, + + { + CFG_TCP_HOSTNAME_1, + "HostName1", + "TCP", + "Name/IP of computer on one side of the connection", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_TCP_HOSTNAME_2, + "HostName2", + "TCP", + "Name/IP of computer on one side of the connection", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_1, + "NodeId1", + "TCP", + "Id of node (DB, API or MGM) on one side of the connection", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "ProcessId1", + "TCP", + "NodeId1", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_2, + "NodeId2", + "TCP", + "Id of node (DB, API or MGM) on one side of the connection", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "ProcessId2", + "TCP", + "NodeId2", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "IpAddress1", + "TCP", + "HostName1", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "IpAddress2", + "TCP", + "HostName2", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0 }, + + { + CFG_CONNECTION_SEND_SIGNAL_ID, + "SendSignalId", + "TCP", + "Sends id in each signal. Used in trace files.", + ConfigInfo::USED, + false, + ConfigInfo::BOOL, + true, + 0, + 0x7FFFFFFF }, + + + { + CFG_CONNECTION_CHECKSUM, + "Checksum", + "TCP", + "If checksum is enabled, all signals between nodes are checked for errors", + ConfigInfo::USED, + false, + ConfigInfo::BOOL, + false, + 0, + 0x7FFFFFFF }, + + { + CFG_TCP_SERVER_PORT, + "PortNumber", + "TCP", + "Port used for this transporter", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 2202, + 0, + 0x7FFFFFFF }, + + { + CFG_TCP_SEND_BUFFER_SIZE, + "SendBufferMemory", + "TCP", + "Bytes of buffer for signals sent from this node", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 16 * 16384, + 1 * 16384, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "SendBufferSize", + "TCP", + "SendBufferMemory", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + 16, + 1, + 0x7FFFFFFF }, - {"MaxReceiveSize", - "MaxReceiveSize", - "TCP", - "Size of buffer for signals received by this node (in no of signals)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 4, - 1, - 0x7FFFFFFF}, - - {"Proxy", - "Proxy", - "TCP", - "", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0}, - - /***************************************************************************** - * SHM - ****************************************************************************/ - - {"Type", - "Type", - "SHM", - "", - ConfigInfo::INTERNAL, - false, - ConfigInfo::STRING, - 0, - 0, - 0x7FFFFFFF}, + { + CFG_TCP_RECEIVE_BUFFER_SIZE, + "ReceiveBufferMemory", + "TCP", + "Bytes of buffer for signals received by this node", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 4 * 16384, + 1 * 16384, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "MaxReceiveSize", + "TCP", + "ReceiveBufferMemory", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + 4, + 1, + 0x7FFFFFFF }, + + { + CFG_TCP_PROXY, + "Proxy", + "TCP", + "", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0 }, + + { + KEY_INTERNAL, + "Compression", + "TCP", + 0, + ConfigInfo::DEPRICATED, + false, + ConfigInfo::BOOL, + false, + 0, + 0x7FFFFFFF }, + + + { + CFG_CONNECTION_NODE_1_SYSTEM, + "NodeId1_System", + "TCP", + "System for node 1 in connection", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_2_SYSTEM, + "NodeId2_System", + "TCP", + "System for node 2 in connection", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, - {"NodeId1", - "NodeId1", - "SHM", - "Id of node (DB, API or MGM) on one side of the connection", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0x7FFFFFFF}, + + /**************************************************************************** + * SHM + ***************************************************************************/ + { + CFG_SECTION_CONNECTION, + "SHM", + "SHM", + "Connection section", + ConfigInfo::USED, + false, + ConfigInfo::SECTION, + CONNECTION_TYPE_SHM, + 0, 0 + }, + + { + CFG_CONNECTION_NODE_1, + "NodeId1", + "SHM", + "Id of node (DB, API or MGM) on one side of the connection", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + MANDATORY, + 0, + 0x7FFFFFFF }, - {"ProcessId1", - "NodeId1", - "SHM", - "Depricated", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0x7FFFFFFF}, + { + KEY_INTERNAL, + "ProcessId1", + "SHM", + "NodeId1", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, - {"NodeId2", - "NodeId2", - "SHM", - "Id of node (DB, API or MGM) on one side of the connection", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - MANDATORY, - 0, - 0x7FFFFFFF}, + { + CFG_CONNECTION_NODE_2, + "NodeId2", + "SHM", + "Id of node (DB, API or MGM) on one side of the connection", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + MANDATORY, + 0, + 0x7FFFFFFF }, - {"ProcessId2", - "NodeId2", - "SHM", - "Depricated", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0x7FFFFFFF}, + { + KEY_INTERNAL, + "ProcessId2", + "SHM", + "NodeId1", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, - {"SendSignalId", - "SendSignalId", - "SHM", - "Sends id in each signal. Used in trace files.", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF}, + { + CFG_CONNECTION_SEND_SIGNAL_ID, + "SendSignalId", + "SHM", + "Sends id in each signal. Used in trace files.", + ConfigInfo::USED, + false, + ConfigInfo::BOOL, + false, + 0, + 0x7FFFFFFF }, - {"Compression", - "Compression", - "SHM", - "If compression is enabled, then all signals between nodes are compressed", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF}, - {"Checksum", - "Checksum", - "SHM", - "If checksum is enabled, all signals between nodes are checked for errors", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - true, - 0, - 0x7FFFFFFF}, + { + CFG_CONNECTION_CHECKSUM, + "Checksum", + "SHM", + "If checksum is enabled, all signals between nodes are checked for errors", + ConfigInfo::USED, + false, + ConfigInfo::BOOL, + true, + 0, + 0x7FFFFFFF }, - {"ShmKey", - "ShmKey", - "SHM", - "A shared memory key", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 0, - 0x7FFFFFFF }, + { + CFG_SHM_KEY, + "ShmKey", + "SHM", + "A shared memory key", + ConfigInfo::USED, + false, + ConfigInfo::INT, + MANDATORY, + 0, + 0x7FFFFFFF }, - {"ShmSize", - "ShmSize", - "SHM", - "Size of shared memory segment", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 1048576, - 4096, - 0x7FFFFFFF}, + { + CFG_SHM_BUFFER_MEM, + "ShmSize", + "SHM", + "Size of shared memory segment", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 1048576, + 4096, + 0x7FFFFFFF }, - /***************************************************************************** + { + KEY_INTERNAL, + "Compression", + "SHM", + 0, + ConfigInfo::DEPRICATED, + false, + ConfigInfo::BOOL, + false, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_1_SYSTEM, + "NodeId1_System", + "SHM", + "System for node 1 in connection", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_2_SYSTEM, + "NodeId2_System", + "SHM", + "System for node 2 in connection", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + /**************************************************************************** * SCI - ****************************************************************************/ - - {"NodeId1", - "NodeId1", - "SCI", - "Id of node (DB, API or MGM) on one side of the connection", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 0, - 0x7FFFFFFF}, - - {"ProcessId1", - "NodeId1", - "SCI", - "Depricated", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"NodeId2", - "NodeId2", - "SCI", - "Id of node (DB, API or MGM) on one side of the connection", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 0, - 0x7FFFFFFF}, - - {"ProcessId2", - "NodeId2", - "SCI", - "Depricated", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"SciId0", - "SciId0", - "SCI", - "Local SCI-node id for adapter 0 (a computer can have two adapters)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 0, - 0x7FFFFFFF}, - - {"SciId1", - "SciId1", - "SCI", - "Local SCI-node id for adapter 1 (a computer can have two adapters)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 0, - 0x7FFFFFFF}, - - {"SendSignalId", - "SendSignalId", - "SCI", - "Sends id in each signal. Used in trace files.", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - true, - 0, - 0x7FFFFFFF}, - - {"Compression", - "Compression", - "SCI", - "If compression is enabled, then all signals between nodes are compressed", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF}, - - {"Checksum", - "Checksum", - "SCI", - "If checksum is enabled, all signals between nodes are checked for errors", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF}, - - {"SendLimit", - "SendLimit", - "SCI", - "Transporter send buffer contents are sent when this no of bytes is buffered", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 2048, - 512, - 0x7FFFFFFF}, - - {"SharedBufferSize", - "SharedBufferSize", - "SCI", - "Size of shared memory segment", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 1048576, - 262144, - 0x7FFFFFFF}, - - {"Node1_NoOfAdapters", - "Node1_NoOfAdapters", - "SCI", - "", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"Node2_NoOfAdapters", - "Node2_NoOfAdapters", - "SCI", - "", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"Node1_Adapter", - "Node1_Adapter", - "SCI", - "", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"Node2_Adapter", - "Node2_Adapter", - "SCI", - "", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - /***************************************************************************** + ***************************************************************************/ + { + CFG_SECTION_CONNECTION, + "SCI", + "SCI", + "Connection section", + ConfigInfo::USED, + false, + ConfigInfo::SECTION, + CONNECTION_TYPE_SCI, + 0, 0 + }, + + { + CFG_CONNECTION_NODE_1, + "NodeId1", + "SCI", + "Id of node (DB, API or MGM) on one side of the connection", + ConfigInfo::USED, + false, + ConfigInfo::INT, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "ProcessId1", + "SCI", + "NodeId1", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_2, + "NodeId2", + "SCI", + "Id of node (DB, API or MGM) on one side of the connection", + ConfigInfo::USED, + false, + ConfigInfo::INT, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "ProcessId2", + "SCI", + "NodeId2", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_SCI_ID_0, + "SciId0", + "SCI", + "Local SCI-node id for adapter 0 (a computer can have two adapters)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + CFG_SCI_ID_1, + "SciId1", + "SCI", + "Local SCI-node id for adapter 1 (a computer can have two adapters)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_SEND_SIGNAL_ID, + "SendSignalId", + "SCI", + "Sends id in each signal. Used in trace files.", + ConfigInfo::USED, + false, + ConfigInfo::BOOL, + true, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_CHECKSUM, + "Checksum", + "SCI", + "If checksum is enabled, all signals between nodes are checked for errors", + ConfigInfo::USED, + false, + ConfigInfo::BOOL, + false, + 0, + 0x7FFFFFFF }, + + { + CFG_SCI_SEND_LIMIT, + "SendLimit", + "SCI", + "Transporter send buffer contents are sent when this no of bytes is buffered", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 2048, + 512, + 0x7FFFFFFF }, + + { + CFG_SCI_BUFFER_MEM, + "SharedBufferSize", + "SCI", + "Size of shared memory segment", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 1048576, + 262144, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "Node1_NoOfAdapters", + "SCI", + 0, + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "Node2_NoOfAdapters", + "SCI", + 0, + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "Node1_Adapter", + "SCI", + 0, + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "Node2_Adapter", + "SCI", + 0, + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "Compression", + "SCI", + 0, + ConfigInfo::DEPRICATED, + false, + ConfigInfo::BOOL, + false, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_1_SYSTEM, + "NodeId1_System", + "SCI", + "System for node 1 in connection", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_2_SYSTEM, + "NodeId2_System", + "SCI", + "System for node 2 in connection", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + /**************************************************************************** * OSE - ****************************************************************************/ - - {"Type", - "Type", - "OSE", - "", - ConfigInfo::INTERNAL, - false, - ConfigInfo::STRING, - 0, - 0, - 0x7FFFFFFF}, - - {"HostName1", - "HostName1", - "OSE", - "Name of computer on one side of the connection", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"HostName2", - "HostName2", - "OSE", - "Name of computer on one side of the connection", - ConfigInfo::USED, - false, - ConfigInfo::STRING, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"NodeId1", - "NodeId1", - "OSE", - "Id of node (DB, API or MGM) on one side of the connection", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 0, - 0x7FFFFFFF}, - - {"ProcessId1", - "NodeId1", - "OSE", - "Depricated", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"NodeId2", - "NodeId2", - "OSE", - "Id of node (DB, API or MGM) on one side of the connection", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 0, - 0x7FFFFFFF}, - - {"ProcessId2", - "NodeId2", - "OSE", - "Depricated", - ConfigInfo::USED, - false, - ConfigInfo::INT, - MANDATORY, - 0, - 0x7FFFFFFF}, - - {"SendSignalId", - "SendSignalId", - "OSE", - "Sends id in each signal. Used in trace files.", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - true, - 0, - 0x7FFFFFFF}, - - {"Compression", - "Compression", - "OSE", - "If compression is enabled, then all signals between nodes are compressed", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF}, - - {"Checksum", - "Checksum", - "OSE", - "If checksum is enabled, all signals between nodes are checked for errors", - ConfigInfo::USED, - false, - ConfigInfo::BOOL, - false, - 0, - 0x7FFFFFFF}, - - // Should not be part of OSE ? - {"SharedBufferSize", - "SharedBufferSize", - "OSE", - "?", - ConfigInfo::DEPRICATED, - false, - ConfigInfo::INT, - UNDEFINED, - 2000, - 0x7FFFFFFF}, - - {"PrioASignalSize", - "PrioASignalSize", - "OSE", - "Size of priority A signals (in bytes)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 1000, - 0, - 0x7FFFFFFF}, - - {"PrioBSignalSize", - "PrioBSignalSize", - "OSE", - "Size of priority B signals (in bytes)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 1000, - 0, - 0x7FFFFFFF}, - - {"ReceiveArraySize", - "ReceiveArraySize", - "OSE", - "Number of OSE signals checked for correct ordering (in no of OSE signals)", - ConfigInfo::USED, - false, - ConfigInfo::INT, - 10, - 0, - 0x7FFFFFFF} + ***************************************************************************/ + { + CFG_SECTION_CONNECTION, + "OSE", + "OSE", + "Connection section", + ConfigInfo::USED, + false, + ConfigInfo::SECTION, + CONNECTION_TYPE_OSE, + 0, 0 + }, + + { + CFG_OSE_HOSTNAME_1, + "HostName1", + "OSE", + "Name of computer on one side of the connection", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_OSE_HOSTNAME_2, + "HostName2", + "OSE", + "Name of computer on one side of the connection", + ConfigInfo::USED, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_1, + "NodeId1", + "OSE", + "Id of node (DB, API or MGM) on one side of the connection", + ConfigInfo::USED, + false, + ConfigInfo::INT, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "ProcessId1", + "OSE", + "NodeId1", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_2, + "NodeId2", + "OSE", + "Id of node (DB, API or MGM) on one side of the connection", + ConfigInfo::USED, + false, + ConfigInfo::INT, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "ProcessId2", + "OSE", + "NodeId2", + ConfigInfo::DEPRICATED, + false, + ConfigInfo::INT, + MANDATORY, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_SEND_SIGNAL_ID, + "SendSignalId", + "OSE", + "Sends id in each signal. Used in trace files.", + ConfigInfo::USED, + false, + ConfigInfo::BOOL, + true, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_CHECKSUM, + "Checksum", + "OSE", + "If checksum is enabled, all signals between nodes are checked for errors", + ConfigInfo::USED, + false, + ConfigInfo::BOOL, + false, + 0, + 0x7FFFFFFF }, + + { + CFG_OSE_PRIO_A_SIZE, + "PrioASignalSize", + "OSE", + "Size of priority A signals (in bytes)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 1000, + 0, + 0x7FFFFFFF }, + + { + CFG_OSE_PRIO_B_SIZE, + "PrioBSignalSize", + "OSE", + "Size of priority B signals (in bytes)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 1000, + 0, + 0x7FFFFFFF }, + + { + CFG_OSE_RECEIVE_ARRAY_SIZE, + "ReceiveArraySize", + "OSE", + "Number of OSE signals checked for correct ordering (in no of OSE signals)", + ConfigInfo::USED, + false, + ConfigInfo::INT, + 10, + 0, + 0x7FFFFFFF }, + + { + KEY_INTERNAL, + "Compression", + "OSE", + 0, + ConfigInfo::DEPRICATED, + false, + ConfigInfo::BOOL, + false, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_1_SYSTEM, + "NodeId1_System", + "OSE", + "System for node 1 in connection", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, + + { + CFG_CONNECTION_NODE_2_SYSTEM, + "NodeId2_System", + "OSE", + "System for node 2 in connection", + ConfigInfo::INTERNAL, + false, + ConfigInfo::STRING, + UNDEFINED, + 0, + 0x7FFFFFFF }, }; const int ConfigInfo::m_NoOfParams = sizeof(m_ParamInfo) / sizeof(ParamInfo); @@ -1908,21 +2215,21 @@ ConfigInfo::ConfigInfo() { newsection.setCaseInsensitiveNames(true); m_info.put(param._section, &newsection); } - + // Get copy of section m_info.getCopy(param._section, §ion); // Create pinfo (parameter info) entry Properties pinfo; + pinfo.put("Id", param._paramId); pinfo.put("Fname", param._fname); - pinfo.put("Pname", param._pname); pinfo.put("Description", param._description); pinfo.put("Updateable", param._updateable); pinfo.put("Type", param._type); pinfo.put("Status", param._status); - pinfo.put("Default", param._default); - pinfo.put("Min", param._min); - pinfo.put("Max", param._max); + pinfo.put64("Default", param._default); + pinfo.put64("Min", param._min); + pinfo.put64("Max", param._max); // Check that pinfo is really new if (section->get(param._fname, &oldpinfo)) { @@ -1937,8 +2244,8 @@ ConfigInfo::ConfigInfo() { // Replace section with modified section m_info.put(param._section, section, true); - - { + + if(param._type != ConfigInfo::SECTION){ Properties * p; if(!m_systemDefaults.getCopy(param._section, &p)){ p = new Properties(); @@ -1947,26 +2254,28 @@ ConfigInfo::ConfigInfo() { if(param._type != STRING && param._default != UNDEFINED && param._default != MANDATORY){ - require(p->put(param._pname, param._default)); + require(p->put(param._fname, param._default)); } require(m_systemDefaults.put(param._section, p, true)); delete p; } } - + for (int i=0; i<m_NoOfParams; i++) { if(m_ParamInfo[i]._section == NULL){ - ndbout << "Check that each pname has an fname failed." << endl; - ndbout << "Parameter \"" << m_ParamInfo[i]._pname - << "\" does not exist in section \"" - << m_ParamInfo[i]._section << "\"." << endl; + ndbout << "Check that each entry has a section failed." << endl; + ndbout << "Parameter \"" << m_ParamInfo[i]._fname << endl; ndbout << "Edit file " << __FILE__ << "." << endl; exit(-1); } + + if(m_ParamInfo[i]._type == ConfigInfo::SECTION) + continue; + const Properties * p = getInfo(m_ParamInfo[i]._section); - if (!p || !p->contains(m_ParamInfo[i]._pname)) { + if (!p || !p->contains(m_ParamInfo[i]._fname)) { ndbout << "Check that each pname has an fname failed." << endl; - ndbout << "Parameter \"" << m_ParamInfo[i]._pname + ndbout << "Parameter \"" << m_ParamInfo[i]._fname << "\" does not exist in section \"" << m_ParamInfo[i]._section << "\"." << endl; ndbout << "Edit file " << __FILE__ << "." << endl; @@ -2002,16 +2311,27 @@ ConfigInfo::getDefaults(const char * section) const { } static -Uint32 +Uint64 getInfoInt(const Properties * section, const char* fname, const char * type){ - Uint32 val; + Uint32 val32; const Properties * p; - if (section->get(fname, &p) && p->get(type, &val)) { - return val; + if (section->get(fname, &p) && p->get(type, &val32)) { + return val32; + } + + Uint64 val64; + if(p && p->get(type, &val64)){ + return val64; } + + section->print(); + if(section->get(fname, &p)){ + p->print(); + } + warning(type, fname); - return val; + return 0; } static @@ -2027,27 +2347,22 @@ getInfoString(const Properties * section, return val; } -Uint32 +Uint64 ConfigInfo::getMax(const Properties * section, const char* fname) const { return getInfoInt(section, fname, "Max"); } -Uint32 +Uint64 ConfigInfo::getMin(const Properties * section, const char* fname) const { return getInfoInt(section, fname, "Min"); } -Uint32 +Uint64 ConfigInfo::getDefault(const Properties * section, const char* fname) const { return getInfoInt(section, fname, "Default"); } const char* -ConfigInfo::getPName(const Properties * section, const char* fname) const { - return getInfoString(section, fname, "Pname"); -} - -const char* ConfigInfo::getDescription(const Properties * section, const char* fname) const { return getInfoString(section, fname, "Description"); @@ -2063,8 +2378,8 @@ ConfigInfo::isSection(const char * section) const { bool ConfigInfo::verify(const Properties * section, const char* fname, - Uint32 value) const { - Uint32 min, max; min = max + 1; + Uint64 value) const { + Uint64 min, max; min = max + 1; min = getInfoInt(section, fname, "Min"); max = getInfoInt(section, fname, "Max"); @@ -2104,7 +2419,6 @@ void ConfigInfo::print(const char* section) const { Properties::Iterator it(sec); for (const char* n = it.first(); n != NULL; n = it.next()) { // Skip entries with different F- and P-names - if (strcmp(n, getPName(sec, n))) continue; if (getStatus(sec, n) == ConfigInfo::INTERNAL) continue; if (getStatus(sec, n) == ConfigInfo::DEPRICATED) continue; if (getStatus(sec, n) == ConfigInfo::NOTIMPLEMENTED) continue; @@ -2114,7 +2428,7 @@ void ConfigInfo::print(const char* section) const { void ConfigInfo::print(const Properties * section, const char* parameter) const { - ndbout << getPName(section, parameter); + ndbout << parameter; // ndbout << getDescription(section, parameter) << endl; switch (getType(section, parameter)) { case ConfigInfo::BOOL: @@ -2133,6 +2447,7 @@ void ConfigInfo::print(const Properties * section, break; case ConfigInfo::INT: + case ConfigInfo::INT64: ndbout << " (Non-negative Integer)" << endl; ndbout << getDescription(section, parameter) << endl; if (getDefault(section, parameter) == MANDATORY) { @@ -2157,6 +2472,8 @@ void ConfigInfo::print(const Properties * section, } ndbout << endl; break; + case ConfigInfo::SECTION: + break; } } @@ -2189,6 +2506,39 @@ transformNode(InitConfigFileParser::Context & ctx, const char * data){ } bool +fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data){ + + const char * compId; + if(!ctx.m_currentSection->get("ExecuteOnComputer", &compId)){ + ctx.reportError("Parameter \"ExecuteOnComputer\" missing from section " + "[%s] starting at line: %d", + ctx.fname, ctx.m_sectionLineno); + return false; + } + + const Properties * computer; + char tmp[255]; + snprintf(tmp, sizeof(tmp), "Computer_%s", compId); + if(!ctx.m_config->get(tmp, &computer)){ + ctx.reportError("Computer \"%s\" not declared" + "- [%s] starting at line: %d", + compId, ctx.fname, ctx.m_sectionLineno); + return false; + } + + const char * hostname; + if(!computer->get("HostName", &hostname)){ + ctx.reportError("HostName missing in [COMPUTER] (Id: %d) " + " - [%s] starting at line: %d", + compId, ctx.fname, ctx.m_sectionLineno); + return false; + } + + require(ctx.m_currentSection->put("HostName", hostname)); + return true; +} + +bool transformExtNode(InitConfigFileParser::Context & ctx, const char * data){ Uint32 id; @@ -2301,6 +2651,7 @@ applyDefaultValues(InitConfigFileParser::Context & ctx, Properties::Iterator it(defaults); for(const char * name = it.first(); name != NULL; name = it.next()){ + ConfigInfo::Status st = ctx.m_info->getStatus(ctx.m_currentInfo, name); if(!ctx.m_currentSection->contains(name)){ switch (ctx.m_info->getType(ctx.m_currentInfo, name)){ case ConfigInfo::INT: @@ -2310,12 +2661,20 @@ applyDefaultValues(InitConfigFileParser::Context & ctx, ctx.m_currentSection->put(name, val); break; } + case ConfigInfo::INT64:{ + Uint64 val = 0; + ::require(defaults->get(name, &val)); + ctx.m_currentSection->put64(name, val); + break; + } case ConfigInfo::STRING:{ const char * val; ::require(defaults->get(name, &val)); ctx.m_currentSection->put(name, val); break; } + case ConfigInfo::SECTION: + break; } } } @@ -2325,9 +2684,13 @@ applyDefaultValues(InitConfigFileParser::Context & ctx, bool applyDefaultValues(InitConfigFileParser::Context & ctx, const char * data){ - applyDefaultValues(ctx, ctx.m_userDefaults); - applyDefaultValues(ctx, ctx.m_systemDefaults); - + if(strcmp(data, "user") == 0) + applyDefaultValues(ctx, ctx.m_userDefaults); + else if (strcmp(data, "system") == 0) + applyDefaultValues(ctx, ctx.m_systemDefaults); + else + return false; + return true; } @@ -2343,11 +2706,9 @@ checkMandatory(InitConfigFileParser::Context & ctx, const char * data){ ::require(ctx.m_currentInfo->get(name, &info)); Uint32 val; if(info->get("Default", &val) && val == MANDATORY){ - const char * pname; const char * fname; - ::require(info->get("Pname", &pname)); ::require(info->get("Fname", &fname)); - if(!ctx.m_currentSection->contains(pname)){ + if(!ctx.m_currentSection->contains(fname)){ ctx.reportError("Mandatory parameter %s missing from section " "[%s] starting at line: %d", fname, ctx.fname, ctx.m_sectionLineno); @@ -2364,13 +2725,13 @@ checkMandatory(InitConfigFileParser::Context & ctx, const char * data){ * Transform a string "NodeidX" (e.g. "uppsala.32") * into a Uint32 "NodeIdX" (e.g. 32) and a string "SystemX" (e.g. "uppsala"). */ -bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data){ - +bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data) +{ char buf[] = "NodeIdX"; buf[6] = data[sizeof("NodeI")]; char sysbuf[] = "SystemX"; sysbuf[6] = data[sizeof("NodeI")]; const char* nodeId; require(ctx.m_currentSection->get(buf, &nodeId)); - + char tmpLine[MAX_LINE_LENGTH]; strncpy(tmpLine, nodeId, MAX_LINE_LENGTH); char* token1 = strtok(tmpLine, "."); @@ -2391,7 +2752,6 @@ bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data){ require(ctx.m_currentSection->put(buf, id, true)); require(ctx.m_currentSection->put(sysbuf, token1)); } - return true; } @@ -2493,20 +2853,12 @@ fixHostname(InitConfigFileParser::Context & ctx, const char * data){ if(!ctx.m_currentSection->contains(data)){ Uint32 id = 0; require(ctx.m_currentSection->get(buf, &id)); - + const Properties * node; require(ctx.m_config->get("Node", id, &node)); - const char * compId; - require(node->get("ExecuteOnComputer", &compId)); - - const Properties * computer; - char tmp[255]; - snprintf(tmp, sizeof(tmp), "Computer_%s", compId); - require(ctx.m_config->get(tmp, &computer)); - const char * hostname; - require(computer->get("HostName", &hostname)); + require(node->get("HostName", &hostname)); require(ctx.m_currentSection->put(data, hostname)); } return true; @@ -2522,9 +2874,9 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ Uint32 adder = 0; ctx.m_userProperties.get("PortNumberAdder", &adder); Uint32 base = 0; - if(!ctx.m_userDefaults->get("PortNumber", &base) && + if(!(ctx.m_userDefaults && ctx.m_userDefaults->get("PortNumber", &base)) && !ctx.m_systemDefaults->get("PortNumber", &base)){ - return true; + return false; } ctx.m_currentSection->put("PortNumber", base + adder); adder++; @@ -2627,3 +2979,265 @@ checkConnectionConstraints(InitConfigFileParser::Context & ctx, const char *){ } return true; } + +static +bool +transform(InitConfigFileParser::Context & ctx, + Properties & dst, + const char * oldName, + const char * newName, + double add, double mul){ + + if(ctx.m_currentSection->contains(newName)){ + ctx.reportError("Both %s and %s specified" + " - [%s] starting at line: %d", + oldName, newName, + ctx.fname, ctx.m_sectionLineno); + return false; + } + + PropertiesType oldType; + require(ctx.m_currentSection->getTypeOf(oldName, &oldType)); + ConfigInfo::Type newType = ctx.m_info->getType(ctx.m_currentInfo, newName); + if(!((oldType == PropertiesType_Uint32 || oldType == PropertiesType_Uint64) + && (newType == ConfigInfo::INT || newType == ConfigInfo::INT64))){ + ctx.reportError("Unable to handle type conversion w.r.t deprication %s %s" + "- [%s] starting at line: %d", + oldName, newName, + ctx.fname, ctx.m_sectionLineno); + return false; + } + Uint64 oldVal; + require(ctx.m_currentSection->get(oldName, &oldVal)); + + Uint64 newVal = (Uint64)(oldVal * mul + add); + if(!ctx.m_info->verify(ctx.m_currentInfo, newName, newVal)){ + ctx.reportError("Unable to handle deprication, new value not within bounds" + "%s %s - [%s] starting at line: %d", + oldName, newName, + ctx.fname, ctx.m_sectionLineno); + return false; + } + + if(newType == ConfigInfo::INT){ + require(dst.put(newName, (Uint32)newVal)); + } else { + require(dst.put64(newName, newVal)); + } + return true; +} + +bool +fixDepricated(InitConfigFileParser::Context & ctx, const char * data){ + /** + * Transform old values to new values + * Transform new values to old values (backward compatible) + */ + Properties tmp; + Properties::Iterator it(ctx.m_currentSection); + for (const char* name = it.first(); name != NULL; name = it.next()) { + const DepricationTransform * p = &f_deprication[0]; + while(p->m_section != 0){ + if(strcmp(p->m_section, ctx.fname) == 0){ + double mul = p->m_mul; + double add = p->m_add; + if(strcmp(name, p->m_oldName) == 0){ + if(!transform(ctx, tmp, name, p->m_newName, add, mul)){ + return false; + } + } else if(strcmp(name, p->m_newName) == 0) { + if(!transform(ctx, tmp, name, p->m_oldName, -add/mul,1.0/mul)){ + return false; + } + } + } + p++; + } + } + + Properties::Iterator it2(&tmp); + for (const char* name = it2.first(); name != NULL; name = it2.next()) { + PropertiesType type; + require(tmp.getTypeOf(name, &type)); + switch(type){ + case PropertiesType_Uint32:{ + Uint32 val; + require(tmp.get(name, &val)); + ::require(ctx.m_currentSection->put(name, val)); + break; + } + case PropertiesType_char:{ + const char * val; + require(tmp.get(name, &val)); + ::require(ctx.m_currentSection->put(name, val)); + break; + } + case PropertiesType_Uint64:{ + Uint64 val; + require(tmp.get(name, &val)); + ::require(ctx.m_currentSection->put64(name, val)); + break; + } + case PropertiesType_Properties: + default: + abort(); + } + } + return true; +} + +bool +saveInConfigValues(InitConfigFileParser::Context & ctx, const char * data){ + const Properties * sec; + if(!ctx.m_currentInfo->get(ctx.fname, &sec)){ + abort(); + return false; + } + + do { + const char *secName; + Uint32 id, status, typeVal; + require(sec->get("Fname", &secName)); + require(sec->get("Id", &id)); + require(sec->get("Status", &status)); + require(sec->get("Default", &typeVal)); + + if(id == KEY_INTERNAL || status == ConfigInfo::INTERNAL){ + ndbout_c("skipping section %s", ctx.fname); + break; + } + + Uint32 no = 0; + ctx.m_userProperties.get("$Section", id, &no); + ctx.m_userProperties.put("$Section", id, no+1, true); + + ctx.m_configValues.openSection(id, no); + ctx.m_configValues.put(CFG_TYPE_OF_SECTION, typeVal); + + Properties::Iterator it(ctx.m_currentSection); + for (const char* n = it.first(); n != NULL; n = it.next()) { + const Properties * info; + if(!ctx.m_currentInfo->get(n, &info)) + continue; + + Uint32 id = 0; + info->get("Id", &id); + + if(id == KEY_INTERNAL) + continue; + + bool ok = true; + PropertiesType type; + require(ctx.m_currentSection->getTypeOf(n, &type)); + switch(type){ + case PropertiesType_Uint32:{ + Uint32 val; + require(ctx.m_currentSection->get(n, &val)); + ok = ctx.m_configValues.put(id, val); + break; + } + case PropertiesType_Uint64:{ + Uint64 val; + require(ctx.m_currentSection->get(n, &val)); + ok = ctx.m_configValues.put64(id, val); + break; + } + case PropertiesType_char:{ + const char * val; + require(ctx.m_currentSection->get(n, &val)); + ok = ctx.m_configValues.put(id, val); + break; + } + default: + abort(); + } + } + ctx.m_configValues.closeSection(); + } while(0); + return true; +} + +bool +addNodeConnections(Vector<ConfigInfo::ConfigRuleSection>§ions, + struct InitConfigFileParser::Context &ctx, + const char * ruleData) +{ + Properties * props= ctx.m_config; + Properties p_connections; + Properties p_connections2; + + for (Uint32 i = 0;; i++){ + const Properties * tmp; + Uint32 nodeId1, nodeId2; + + if(!props->get("Connection", i, &tmp)) break; + + if(!tmp->get("NodeId1", &nodeId1)) continue; + p_connections.put("", nodeId1, nodeId1); + if(!tmp->get("NodeId2", &nodeId2)) continue; + p_connections.put("", nodeId2, nodeId2); + + p_connections2.put("", nodeId1 + nodeId2<<16, nodeId1); + p_connections2.put("", nodeId2 + nodeId1<<16, nodeId2); + } + + Uint32 nNodes; + ctx.m_userProperties.get("NoOfNodes", &nNodes); + + Properties p_db_nodes; + Properties p_api_mgm_nodes; + + Uint32 i_db= 0, i_api_mgm= 0; + for (Uint32 i= 0, n= 0; n < nNodes; i++){ + const Properties * tmp; + if(!props->get("Node", i, &tmp)) continue; + n++; + + const char * type; + if(!tmp->get("Type", &type)) continue; + + if (strcmp(type,"DB") == 0) + p_db_nodes.put("", i_db++, i); + else if (strcmp(type,"API") == 0 || + strcmp(type,"MGM") == 0) + p_api_mgm_nodes.put("", i_api_mgm++, i); + } + + Uint32 nodeId1, nodeId2, dummy; + + for (Uint32 i= 0; p_db_nodes.get("", i, &nodeId1); i++){ + for (Uint32 j= i+1;; j++){ + if(!p_db_nodes.get("", j, &nodeId2)) break; + if(!p_connections2.get("", nodeId1+nodeId2<<16, &dummy)) { + ConfigInfo::ConfigRuleSection s; + s.m_sectionType= BaseString("TCP"); + s.m_sectionData= new Properties; + char buf[16]; + snprintf(buf, sizeof(buf), "%u", nodeId1); + s.m_sectionData->put("NodeId1", buf); + snprintf(buf, sizeof(buf), "%u", nodeId2); + s.m_sectionData->put("NodeId2", buf); + sections.push_back(s); + } + } + } + + for (Uint32 i= 0; p_api_mgm_nodes.get("", i, &nodeId1); i++){ + if(!p_connections.get("", nodeId1, &dummy)) { + for (Uint32 j= 0;; j++){ + if(!p_db_nodes.get("", j, &nodeId2)) break; + ConfigInfo::ConfigRuleSection s; + s.m_sectionType= BaseString("TCP"); + s.m_sectionData= new Properties; + char buf[16]; + snprintf(buf, sizeof(buf), "%u", nodeId1); + s.m_sectionData->put("NodeId1", buf); + snprintf(buf, sizeof(buf), "%u", nodeId2); + s.m_sectionData->put("NodeId2", buf); + sections.push_back(s); + } + } + } + + return true; +} diff --git a/ndb/src/common/mgmcommon/ConfigInfo.hpp b/ndb/src/common/mgmcommon/ConfigInfo.hpp index 43041a3f772..79c17b436fe 100644 --- a/ndb/src/common/mgmcommon/ConfigInfo.hpp +++ b/ndb/src/common/mgmcommon/ConfigInfo.hpp @@ -27,8 +27,8 @@ * A MANDATORY parameters must be specified in the config file * An UNDEFINED parameter may or may not be specified in the config file */ -static const Uint32 MANDATORY = ~0; // Default value for mandatory params. -static const Uint32 UNDEFINED = (~0)-1; // Default value for undefined params. +static const Uint64 MANDATORY = ~0; // Default value for mandatory params. +static const Uint64 UNDEFINED = (~0)-1; // Default value for undefined params. /** * @class ConfigInfo @@ -38,27 +38,27 @@ static const Uint32 UNDEFINED = (~0)-1; // Default value for undefined params. */ class ConfigInfo { public: - enum Type {BOOL, INT, STRING}; - enum Status {USED, ///< Active - DEPRICATED, ///< Can be, but should not be used anymore - NOTIMPLEMENTED, ///< Can not be used currently. Is ignored. - INTERNAL ///< Not configurable by the user + enum Type { BOOL, INT, INT64, STRING, SECTION }; + enum Status { USED, ///< Active + DEPRICATED, ///< Can be, but shouldn't + NOTIMPLEMENTED, ///< Is ignored. + INTERNAL ///< Not configurable by the user }; /** * Entry for one configuration parameter */ struct ParamInfo { + Uint32 _paramId; const char* _fname; - const char* _pname; const char* _section; const char* _description; Status _status; bool _updateable; Type _type; - Uint32 _default; - Uint32 _min; - Uint32 _max; + Uint64 _default; + Uint64 _min; + Uint64 _max; }; /** @@ -71,6 +71,21 @@ public: const char * m_ruleData; }; + /** + * Entry for config rule + */ + struct ConfigRuleSection { + BaseString m_sectionType; + Properties * m_sectionData; + }; + + struct ConfigRule { + bool (* m_configRule)(Vector<ConfigRuleSection>&, + struct InitConfigFileParser::Context &, + const char * m_ruleData); + const char * m_ruleData; + }; + ConfigInfo(); /** @@ -84,16 +99,15 @@ public: * * @note Result is not defined if section/name are wrong! */ - bool verify(const Properties* section, const char* fname, Uint32 value) const; + bool verify(const Properties* secti, const char* fname, Uint64 value) const; bool isSection(const char*) const; - const char* getPName(const Properties * section, const char* fname) const; - const char* getDescription(const Properties * section, const char* fname) const; + const char* getDescription(const Properties * sec, const char* fname) const; Type getType(const Properties * section, const char* fname) const; Status getStatus(const Properties* section, const char* fname) const; - Uint32 getMin(const Properties * section, const char* fname) const; - Uint32 getMax(const Properties * section, const char* fname) const; - Uint32 getDefault(const Properties * section, const char* fname) const; + Uint64 getMin(const Properties * section, const char* fname) const; + Uint64 getMax(const Properties * section, const char* fname) const; + Uint64 getDefault(const Properties * section, const char* fname) const; const Properties * getInfo(const char * section) const; const Properties * getDefaults(const char * section) const; @@ -114,6 +128,7 @@ private: public: static const SectionRule m_SectionRules[]; + static const ConfigRule m_ConfigRules[]; static const int m_NoOfRules; }; diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp index 04dc5466bbc..d2c622593de 100644 --- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp +++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp @@ -33,6 +33,12 @@ #include <socket_io.h> #include <NdbConfig.h> +#include <NdbAutoPtr.hpp> + +#include <mgmapi.h> +#include <mgmapi_config_parameters.h> +#include <ConfigValues.hpp> +#include <NdbHost.h> //**************************************************************************** //**************************************************************************** @@ -83,41 +89,10 @@ ConfigRetriever::init(bool onlyNodeId) { //**************************************************************************** //**************************************************************************** - -Properties * -ConfigRetriever::getConfig(const char * nodeType, int versionId) { - Properties * p = getConfig(versionId); - - if (p == 0) { - char err_buf[255]; - snprintf(err_buf, sizeof(err_buf), - "No configuration retrieved for this %s node ", nodeType); - setError(CR_ERROR, err_buf); - return 0; - } - - const Uint32 nodeId = _ownNodeId; - - if (strcmp(nodeType, "DB") == 0) { - if (!verifyProperties("DB", p, nodeId, versionId)) return 0; - } else if (strcmp(nodeType, "API") == 0) { - if (!verifyProperties("API", p, nodeId, versionId)) return 0; - } else if (strcmp(nodeType, "REP") == 0) { - if (!verifyProperties("REP", p, nodeId, versionId)) return 0; - } else if (strcmp(nodeType, "MGM") == 0) { - if (!verifyProperties("MGM", p, nodeId, versionId)) return 0; - } else { - return 0; - } - - return p; -} - - //**************************************************************************** //**************************************************************************** -Properties * -ConfigRetriever::getConfig(int verId) { +struct ndb_mgm_configuration* +ConfigRetriever::getConfig(int verId, int nodeType) { int res = init(); if (res == -1) { @@ -125,7 +100,7 @@ ConfigRetriever::getConfig(int verId) { } if (_localConfig->items == 0){ - setError(CR_ERROR, "No Management Servers configured in local config file"); + setError(CR_ERROR,"No Management Servers configured in local config file"); return 0; } @@ -136,14 +111,13 @@ ConfigRetriever::getConfig(int verId) { Uint32 type = CR_ERROR; for (int i = 0; i<_localConfig->items; i++){ MgmtSrvrId * m = _localConfig->ids[i]; - Properties * p = 0; - const Uint32 nodeId = _ownNodeId; + struct ndb_mgm_configuration * p = 0; switch(m->type){ case MgmId_TCP: - p = getConfig(m->data.tcp.remoteHost, m->data.tcp.port, nodeId, verId); + p = getConfig(m->data.tcp.remoteHost, m->data.tcp.port, verId); break; case MgmId_File: - p = getConfig(m->data.file.filename, nodeId, verId); + p = getConfig(m->data.file.filename, verId); break; default: setError(CR_ERROR, "Unknown error type"); @@ -151,6 +125,10 @@ ConfigRetriever::getConfig(int verId) { } if (p != 0) { + if(!verifyConfig(p, nodeType)){ + free(p); + return 0; + } return p; } if(latestErrorType == CR_RETRY) @@ -161,110 +139,49 @@ ConfigRetriever::getConfig(int verId) { REPORT_WARNING("Failed to retrieve cluster configuration"); ndbout << "(Cause of failure: " << getErrorString() << ")" << endl; ndbout << "Attempt " << retry << " of " << retry_max << ". " - << "Trying again in "<<retry_interval<<" seconds..." << endl << endl; + << "Trying again in "<< retry_interval <<" seconds..." + << endl << endl; NdbSleep_SecSleep(retry_interval); } else { break; } retry++; - + } while (retry <= retry_max); return 0; } -int global_ndb_check = 0; // set to one in ndb main; -Properties * +ndb_mgm_configuration * ConfigRetriever::getConfig(const char * mgmhost, - unsigned int port, - Uint32 nodeId, + short port, int versionId){ - const int socketTimeout = 10000; - int result; - const NDB_SOCKET_TYPE sockfd = socket(AF_INET, SOCK_STREAM, 0); - if (sockfd == NDB_INVALID_SOCKET) { - setError(CR_RETRY, "Could not create socket to Management Server"); + + NdbMgmHandle h; + h = ndb_mgm_create_handle(); + if (h == NULL) { + setError(CR_ERROR, "Unable to allocate mgm handle"); return 0; } - char err_buf[255]; - struct sockaddr_in servaddr; - memset(&servaddr, 0, sizeof(servaddr)); - servaddr.sin_family = AF_INET; - servaddr.sin_port = htons(port); - // Convert ip address presentation format to numeric format - result = Ndb_getInAddr(&servaddr.sin_addr, mgmhost); - if (result != 0) { - snprintf(err_buf, sizeof(err_buf), - "Name lookup failed: host \"%s\"", mgmhost); - setError(CR_ERROR, err_buf); + BaseString tmp; + tmp.assfmt("%s:%d", mgmhost, port); + if (ndb_mgm_connect(h, tmp.c_str()) != 0) { + setError(CR_RETRY, ndb_mgm_get_latest_error_desc(h)); + ndb_mgm_destroy_handle(&h); return 0; } - result = connect(sockfd, (struct sockaddr*) &servaddr, sizeof(servaddr)); - if (result == -1) { - snprintf(err_buf, sizeof(err_buf), - "Failed to connect to \"%s:%d\"", mgmhost, port); - setError(CR_RETRY, err_buf); - NDB_CLOSE_SOCKET(sockfd); - return 0; + ndb_mgm_configuration * conf = ndb_mgm_get_configuration(h, versionId); + if(conf == 0){ + setError(CR_ERROR, ndb_mgm_get_latest_error_desc(h)); } - - if(println_socket(sockfd, 1000, "GET CONFIG %d %d" , - versionId, nodeId) != 0){ - NDB_CLOSE_SOCKET(sockfd); - setError(CR_ERROR, "IO error, write"); - return 0; - } - - char buf[255]; - { - const int tmp = readln_socket(sockfd, socketTimeout, buf, 255); - if(tmp == -1){ - NDB_CLOSE_SOCKET(sockfd); - setError(CR_ERROR, "IO error, read"); - return 0; - } - if(tmp == 0){ - snprintf(err_buf, 256, - "IO error, failed request: " - "GET CONFIG %d %d", versionId, nodeId); - NDB_CLOSE_SOCKET(sockfd); - setError(CR_ERROR, err_buf); - return 0; - } - } + ndb_mgm_disconnect(h); + ndb_mgm_destroy_handle(&h); - int status, version, node, bytes, bytesUU; - if(sscanf(buf, "GET CONFIG %d %d %d %d %d", - &status, &version, &node, &bytes, &bytesUU) != 5){ - NDB_CLOSE_SOCKET(sockfd); - snprintf(err_buf, sizeof(err_buf), - "Invalid response: %s", buf); - setError(CR_ERROR, err_buf); - return 0; - } - - if(status != 0){ - NDB_CLOSE_SOCKET(sockfd); - if (status == 1){ - snprintf(err_buf, sizeof(err_buf), - "Management Server: Requested version id is invalid"); - } else if (status == 2){ - snprintf(err_buf, sizeof(err_buf), - "Management Server: Node with id %d has not been specified", - nodeId); - } else if (status == 3){ - snprintf(err_buf, sizeof(err_buf), "Management Server: Internal error"); - } else { - snprintf(err_buf, sizeof(err_buf), - "Management Server returned unknown error: %d", status); - } - setError(CR_ERROR, err_buf); - return 0; - } - + return conf; +#if 0 bool compatible; if (global_ndb_check) compatible = ndbCompatible_ndb_mgmt(versionId, version); @@ -278,90 +195,11 @@ ConfigRetriever::getConfig(const char * mgmhost, setError(CR_ERROR, err_buf); return 0; } - - if(node != (int)nodeId){ - NDB_CLOSE_SOCKET(sockfd); - snprintf(err_buf, sizeof(err_buf), "Management Server: Invalid node id. " - "Node id from server: %d Own node id: %d", node, nodeId); - setError(CR_ERROR, err_buf); - return 0; - } - - if(readln_socket(sockfd, socketTimeout, buf, 255) == -1){ - NDB_CLOSE_SOCKET(sockfd); - setError(CR_ERROR, "IO error, read"); - return 0; - } - - if(strncmp("begin", buf, strlen("begin")) != 0){ - NDB_CLOSE_SOCKET(sockfd); - snprintf(err_buf, sizeof(err_buf), - "Invalid response: %s", buf); - setError(CR_ERROR, err_buf); - return 0; - } - - char* bufUU = new char[bytesUU]; - int read = 0; - int start = 0; - do { - if((read = read_socket(sockfd, socketTimeout, &bufUU[start], bytesUU-start)) == -1){ - delete[] bufUU; - NDB_CLOSE_SOCKET(sockfd); - setError(CR_ERROR, "IO error, read(bufUU)"); - return 0; - } - start += read; - } while(start < bytesUU); - - Uint32 * buf2 = new Uint32[bytes/4+1]; // Properties byte size - char * dst = (char *)buf2; - int sz = 0; - start = 0; - - for (int i = 0; i < bytesUU; i++) { - if (bufUU[i] == '\n') { - bufUU[i] = 0; - if (bufUU[i-1] == '\r') { - bufUU[i-1] = 0; - } - sz = uudecode_mem(dst, bytes, &bufUU[start]); - dst += sz; - start = i + 1; // Next row - } - } - - delete[] bufUU; - - if(sz < 0){ - delete []buf2; - NDB_CLOSE_SOCKET(sockfd); - setError(CR_ERROR, "IO error, sz < 0"); - return 0; - } - - Properties * p = new Properties(); - if(!p->unpack(buf2, bytes+4)){ - snprintf(buf, sizeof(buf), "Error while unpacking %d,%d", - p->getPropertiesErrno(), - p->getOSErrno()); - setError(CR_ERROR, buf); - delete []buf2; - delete p; - return 0; - } - delete []buf2; - - NDB_CLOSE_SOCKET(sockfd); - - return p; - +#endif } -Properties * -ConfigRetriever::getConfig(const char * filename, - Uint32 nodeId, - int versionId){ +ndb_mgm_configuration * +ConfigRetriever::getConfig(const char * filename, int versionId){ struct stat sbuf; const int res = stat(filename, &sbuf); @@ -389,74 +227,19 @@ ConfigRetriever::getConfig(const char * filename, return 0; } - Properties * p = new Properties(); - if(!p->unpack(buf2, bytes+4)){ + ConfigValuesFactory cvf; + if(!cvf.unpack(buf2, bytes)){ char buf[255]; - snprintf(buf, sizeof(buf), "Error while unpacking %d,%d", - p->getPropertiesErrno(), - p->getOSErrno()); + snprintf(buf, sizeof(buf), "Error while unpacking"); setError(CR_ERROR, buf); delete []buf2; - delete p; return 0; } delete [] buf2; - return p; + return (ndb_mgm_configuration*)cvf.m_cfg; } -bool -ConfigRetriever::verifyProperties(const char* nodeType, Properties * p, - Uint32 nodeId, int versionId){ - - Uint32 t = 0; - const Properties *tmp; - const char *type; - - if (p == 0) return false; - - bool compatible = false; - if (p->get("Version", &t)) - if (global_ndb_check) - compatible = ndbCompatible_ndb_mgmt(versionId, t); - else - compatible = ndbCompatible_api_mgmt(versionId, t); - - if(!compatible){ // if(!p->get("Version", &t) || versionId != (int)t){ - setError(CR_ERROR, "Invalid configuration version"); - delete p; - return false; - } - - if(!p->get("LocalNodeId", &t) || nodeId != t){ - setError(CR_ERROR, "Invalid node identity in configuration"); - delete p; - return false; - } - - if(!p->get("Node", nodeId, &tmp)){ - setError(CR_ERROR, "Internal error while processing configuration"); - ndbout_c("nodeId = %d", nodeId); - p->print(); - delete p; - return false; - } - - if(!tmp->get("Type", &type) || strcmp(type, nodeType)) { - if (!(!strcmp(type, "REP") && !strcmp(nodeType, "API"))) { - char buf[1024]; - snprintf(buf, sizeof(buf), - "Configuration error: Node with id %d is not of type %s.\n" - "Check local config file: %s", nodeId, nodeType, - _localConfigFileName); - setError(CR_ERROR, buf); - return false; - } - } - - return true; -} - void ConfigRetriever::setError(ErrorType et, const char * s){ if(errorString != 0){ @@ -509,3 +292,82 @@ ConfigRetriever::setDefaultConnectString(const char * defaultConnectString) { m_defaultConnectString = 0; } } + +bool +ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, + int type){ + char buf[255]; + ndb_mgm_configuration_iterator * it; + it = ndb_mgm_create_configuration_iterator((struct ndb_mgm_configuration *)conf, CFG_SECTION_NODE); + + if(it == 0){ + snprintf(buf, 255, "Unable to create config iterator"); + setError(CR_ERROR, buf); + return false; + + } + NdbAutoPtr<ndb_mgm_configuration_iterator> ptr(it); + + if(ndb_mgm_find(it, CFG_NODE_ID, getOwnNodeId()) != 0){ + snprintf(buf, 255, "Unable to find node with id: %d", getOwnNodeId()); + setError(CR_ERROR, buf); + return false; + } + + const char * hostname; + if(ndb_mgm_get_string_parameter(it, CFG_NODE_HOST, &hostname)){ + snprintf(buf, 255, "Unable to get hostname(%d) from config",CFG_NODE_HOST); + setError(CR_ERROR, buf); + return false; + } + + char localhost[MAXHOSTNAMELEN]; + if(NdbHost_GetHostName(localhost) != 0){ + snprintf(buf, 255, "Unable to own hostname"); + setError(CR_ERROR, buf); + return false; + } + + do { + if(strcasecmp(hostname, localhost) == 0) + break; + + if(strcasecmp(hostname, "localhost") == 0) + break; + + struct in_addr local, config; + bool b1 = false, b2 = false, b3 = false; + b1 = Ndb_getInAddr(&local, localhost) == 0; + b2 = Ndb_getInAddr(&config, hostname) == 0; + b3 = memcmp(&local, &config, sizeof(local)) == 0; + + if(b1 && b2 && b3) + break; + + b1 = Ndb_getInAddr(&local, "localhost") == 0; + b3 = memcmp(&local, &config, sizeof(local)) == 0; + if(b1 && b2 && b3) + break; + + snprintf(buf, 255, "Local hostname(%s) and config hostname(%s) dont match", + localhost, hostname); + setError(CR_ERROR, buf); + return false; + } while(false); + + unsigned int _type; + if(ndb_mgm_get_int_parameter(it, CFG_TYPE_OF_SECTION, &_type)){ + snprintf(buf, 255, "Unable to get type of node(%d) from config", + CFG_TYPE_OF_SECTION); + setError(CR_ERROR, buf); + return false; + } + + if(_type != type){ + snprintf(buf, 255, "Supplied node type(%d) and config node type(%d) " + " don't match", type, _type); + setError(CR_ERROR, buf); + return false; + } + return true; +} diff --git a/ndb/src/common/mgmcommon/IPCConfig.cpp b/ndb/src/common/mgmcommon/IPCConfig.cpp index f75cf806cc0..ba5fe7ace80 100644 --- a/ndb/src/common/mgmcommon/IPCConfig.cpp +++ b/ndb/src/common/mgmcommon/IPCConfig.cpp @@ -17,10 +17,14 @@ #include "IPCConfig.hpp" #include <NdbOut.hpp> #include <NdbHost.h> + #include <TransporterDefinitions.hpp> #include <TransporterRegistry.hpp> #include <Properties.hpp> +#include <mgmapi_configuration.hpp> +#include <mgmapi_config_parameters.h> + #if defined DEBUG_TRANSPORTER #define DEBUG(t) ndbout << __FILE__ << ":" << __LINE__ << ":" << t << endl; #else @@ -334,3 +338,158 @@ IPCConfig::getNodeType(NodeId id) const { return out; } + +Uint32 +IPCConfig::configureTransporters(Uint32 nodeId, + const class ndb_mgm_configuration & config, + class TransporterRegistry & tr){ + + Uint32 noOfTransportersCreated = 0; + ndb_mgm_configuration_iterator iter(config, CFG_SECTION_CONNECTION); + + for(iter.first(); iter.valid(); iter.next()){ + + Uint32 nodeId1, nodeId2, remoteNodeId; + if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1)) continue; + if(iter.get(CFG_CONNECTION_NODE_2, &nodeId2)) continue; + + if(nodeId1 != nodeId && nodeId2 != nodeId) continue; + remoteNodeId = (nodeId == nodeId1 ? nodeId2 : nodeId1); + + Uint32 sendSignalId = 1; + Uint32 checksum = 1; + if(iter.get(CFG_CONNECTION_SEND_SIGNAL_ID, &sendSignalId)) continue; + if(iter.get(CFG_CONNECTION_CHECKSUM, &checksum)) continue; + + Uint32 type = ~0; + if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue; + + switch(type){ + case CONNECTION_TYPE_SHM:{ + SHM_TransporterConfiguration conf; + conf.localNodeId = nodeId; + conf.remoteNodeId = remoteNodeId; + conf.byteOrder = 0; + conf.compression = 0; + conf.checksum = checksum; + conf.signalId = sendSignalId; + + if(iter.get(CFG_SHM_KEY, &conf.shmKey)) break; + if(iter.get(CFG_SHM_BUFFER_MEM, &conf.shmSize)) break; + + if(!tr.createTransporter(&conf)){ + ndbout << "Failed to create SHM Transporter from: " + << conf.localNodeId << " to: " << conf.remoteNodeId << endl; + } else { + noOfTransportersCreated++; + } + break; + } + case CONNECTION_TYPE_SCI:{ + SCI_TransporterConfiguration conf; + conf.localNodeId = nodeId; + conf.remoteNodeId = remoteNodeId; + conf.byteOrder = 0; + conf.compression = 0; + conf.checksum = checksum; + conf.signalId = sendSignalId; + + if(iter.get(CFG_SCI_SEND_LIMIT, &conf.sendLimit)) break; + if(iter.get(CFG_SCI_BUFFER_MEM, &conf.bufferSize)) break; + + if(nodeId == nodeId1){ + if(iter.get(CFG_SCI_NODE1_ADAPTERS, &conf.nLocalAdapters)) break; + if(iter.get(CFG_SCI_NODE2_ADAPTERS, &conf.nRemoteAdapters)) break; + if(iter.get(CFG_SCI_NODE2_ADAPTER0, &conf.remoteSciNodeId0)) break; + if(conf.nRemoteAdapters > 1){ + if(iter.get(CFG_SCI_NODE2_ADAPTER1, &conf.remoteSciNodeId1)) break; + } + } else { + if(iter.get(CFG_SCI_NODE2_ADAPTERS, &conf.nLocalAdapters)) break; + if(iter.get(CFG_SCI_NODE1_ADAPTERS, &conf.nRemoteAdapters)) break; + if(iter.get(CFG_SCI_NODE1_ADAPTER0, &conf.remoteSciNodeId0)) break; + if(conf.nRemoteAdapters > 1){ + if(iter.get(CFG_SCI_NODE1_ADAPTER1, &conf.remoteSciNodeId1)) break; + } + } + + if(!tr.createTransporter(&conf)){ + ndbout << "Failed to create SCI Transporter from: " + << conf.localNodeId << " to: " << conf.remoteNodeId << endl; + } else { + noOfTransportersCreated++; + continue; + } + } + case CONNECTION_TYPE_TCP:{ + TCP_TransporterConfiguration conf; + + const char * host1, * host2; + if(iter.get(CFG_TCP_HOSTNAME_1, &host1)) break; + if(iter.get(CFG_TCP_HOSTNAME_2, &host2)) break; + + if(iter.get(CFG_TCP_SERVER_PORT, &conf.port)) break; + if(iter.get(CFG_TCP_SEND_BUFFER_SIZE, &conf.sendBufferSize)) break; + if(iter.get(CFG_TCP_RECEIVE_BUFFER_SIZE, &conf.maxReceiveSize)) break; + + const char * proxy; + if (!iter.get(CFG_TCP_PROXY, &proxy)) { + if (strlen(proxy) > 0 && nodeId2 == nodeId) { + // TODO handle host:port + conf.port = atoi(proxy); + } + } + + conf.localNodeId = nodeId; + conf.remoteNodeId = remoteNodeId; + conf.localHostName = (nodeId == nodeId1 ? host1 : host2); + conf.remoteHostName = (nodeId == nodeId1 ? host2 : host1); + conf.byteOrder = 0; + conf.compression = 0; + conf.checksum = checksum; + conf.signalId = sendSignalId; + + if(!tr.createTransporter(&conf)){ + ndbout << "Failed to create TCP Transporter from: " + << nodeId << " to: " << remoteNodeId << endl; + } else { + noOfTransportersCreated++; + } + case CONNECTION_TYPE_OSE:{ + OSE_TransporterConfiguration conf; + + const char * host1, * host2; + if(iter.get(CFG_OSE_HOSTNAME_1, &host1)) break; + if(iter.get(CFG_OSE_HOSTNAME_2, &host2)) break; + + if(iter.get(CFG_OSE_PRIO_A_SIZE, &conf.prioASignalSize)) break; + if(iter.get(CFG_OSE_PRIO_B_SIZE, &conf.prioBSignalSize)) break; + if(iter.get(CFG_OSE_RECEIVE_ARRAY_SIZE, &conf.receiveBufferSize)) break; + + conf.localNodeId = nodeId; + conf.remoteNodeId = remoteNodeId; + conf.localHostName = (nodeId == nodeId1 ? host1 : host2); + conf.remoteHostName = (nodeId == nodeId1 ? host2 : host1); + conf.byteOrder = 0; + conf.compression = 0; + conf.checksum = checksum; + conf.signalId = sendSignalId; + + if(!tr.createTransporter(&conf)){ + ndbout << "Failed to create OSE Transporter from: " + << nodeId << " to: " << remoteNodeId << endl; + } else { + noOfTransportersCreated++; + } + } + default: + ndbout << "Unknown transporter type from: " << nodeId << + " to: " << remoteNodeId << endl; + break; + } + } + } + + return noOfTransportersCreated; +} + diff --git a/ndb/src/common/mgmcommon/InitConfigFileParser.cpp b/ndb/src/common/mgmcommon/InitConfigFileParser.cpp index 62c4bd28857..d52bc54db52 100644 --- a/ndb/src/common/mgmcommon/InitConfigFileParser.cpp +++ b/ndb/src/common/mgmcommon/InitConfigFileParser.cpp @@ -22,7 +22,7 @@ #include <NdbOut.hpp> #include "ConfigInfo.hpp" -const int MAX_LINE_LENGTH = 120; // Max length of line of text in config file +const int MAX_LINE_LENGTH = 1024; // Max length of line of text in config file static void trim(char *); static void require(bool v) { if(!v) abort();} @@ -30,51 +30,66 @@ static void require(bool v) { if(!v) abort();} //**************************************************************************** // Ctor / Dtor //**************************************************************************** -InitConfigFileParser::InitConfigFileParser(const char* initialConfigFileName){ - - m_initConfigStream = fopen(initialConfigFileName, "r"); +InitConfigFileParser::InitConfigFileParser(){ m_info = new ConfigInfo(); - m_config = new Config(); - m_defaults = new Properties(); - m_defaults->setCaseInsensitiveNames(true); } InitConfigFileParser::~InitConfigFileParser() { - if (m_initConfigStream != NULL) fclose(m_initConfigStream); - delete m_info; - delete m_config; - delete m_defaults; } //**************************************************************************** // Read Config File //**************************************************************************** -bool InitConfigFileParser::readConfigFile() { +InitConfigFileParser::Context::Context(const ConfigInfo * info) + : m_configValues(1000, 20) { + + m_config = new Properties(); + m_defaults = new Properties(); +} + +InitConfigFileParser::Context::~Context(){ + if(m_config != 0) + delete m_config; + + if(m_defaults != 0) + delete m_defaults; +} + +Config * +InitConfigFileParser::parseConfig(const char * filename) { + FILE * file = fopen(filename, "r"); + if(file == 0){ + ndbout << "Error opening file: " << filename << endl; + return 0; + } + + Config * ret = parseConfig(file); + fclose(file); + return ret; +} + +Config * +InitConfigFileParser::parseConfig(FILE * file) { char line[MAX_LINE_LENGTH]; - Context ctx; + Context ctx(m_info); ctx.m_lineno = 0; ctx.m_currentSection = 0; - ctx.m_info = m_info; - ctx.m_config = m_config; - ctx.m_defaults = m_defaults; - /************* * Open file * *************/ - if (m_initConfigStream == NULL) { - ctx.reportError("Could not open file."); - return false; + if (file == NULL) { + return 0; } /*********************** * While lines to read * ***********************/ - while (fgets(line, MAX_LINE_LENGTH, m_initConfigStream)) { + while (fgets(line, MAX_LINE_LENGTH, file)) { ctx.m_lineno++; trim(line); @@ -94,7 +109,7 @@ bool InitConfigFileParser::readConfigFile() { free(section); ctx.reportError("Could not store previous default section " "of configuration file."); - return false; + return 0; } snprintf(ctx.fname, sizeof(ctx.fname), section); free(section); @@ -115,7 +130,7 @@ bool InitConfigFileParser::readConfigFile() { free(section); ctx.reportError("Could not store previous section " "of configuration file."); - return false; + return 0; } snprintf(ctx.fname, sizeof(ctx.fname), section); @@ -123,7 +138,7 @@ bool InitConfigFileParser::readConfigFile() { ctx.type = InitConfigFileParser::Section; ctx.m_sectionLineno = ctx.m_lineno; ctx.m_currentSection = new Properties(); - ctx.m_userDefaults = getSection(ctx.fname, m_defaults); + ctx.m_userDefaults = getSection(ctx.fname, ctx.m_defaults); ctx.m_currentInfo = m_info->getInfo(ctx.fname); ctx.m_systemDefaults = m_info->getDefaults(ctx.fname); continue; @@ -134,15 +149,44 @@ bool InitConfigFileParser::readConfigFile() { ****************************/ if (!parseNameValuePair(ctx, line)) { ctx.reportError("Could not parse name-value pair in config file."); - return false; + return 0; } } + if (ferror(file)){ + ctx.reportError("Failure in reading"); + return 0; + } + if(!storeSection(ctx)) { ctx.reportError("Could not store section of configuration file."); - return false; + return 0; } + for(size_t i = 0; ConfigInfo::m_ConfigRules[i].m_configRule != 0; i++){ + ctx.type = InitConfigFileParser::Undefined; + ctx.m_currentSection = 0; + ctx.m_userDefaults = 0; + ctx.m_currentInfo = 0; + ctx.m_systemDefaults = 0; + + Vector<ConfigInfo::ConfigRuleSection> tmp; + if(!(* ConfigInfo::m_ConfigRules[i].m_configRule)(tmp, ctx, + ConfigInfo::m_ConfigRules[i].m_ruleData)) + return 0; + + for(size_t j = 0; j<tmp.size(); j++){ + snprintf(ctx.fname, sizeof(ctx.fname), tmp[j].m_sectionType.c_str()); + ctx.type = InitConfigFileParser::Section; + ctx.m_currentSection = tmp[j].m_sectionData; + ctx.m_userDefaults = getSection(ctx.fname, ctx.m_defaults); + ctx.m_currentInfo = m_info->getInfo(ctx.fname); + ctx.m_systemDefaults = m_info->getDefaults(ctx.fname); + if(!storeSection(ctx)) + return 0; + } + } + Uint32 nConnections = 0; Uint32 nComputers = 0; Uint32 nNodes = 0; @@ -153,21 +197,20 @@ bool InitConfigFileParser::readConfigFile() { ctx.m_userProperties.get("NoOfNodes", &nNodes); ctx.m_userProperties.get("ExtNoOfConnections", &nExtConnections); ctx.m_userProperties.get("ExtSystem", &system); - m_config->put("NoOfConnections", nConnections); - m_config->put("NoOfComputers", nComputers); - m_config->put("NoOfNodes", nNodes); + ctx.m_config->put("NoOfConnections", nConnections); + ctx.m_config->put("NoOfComputers", nComputers); + ctx.m_config->put("NoOfNodes", nNodes); char tmpLine[MAX_LINE_LENGTH]; snprintf(tmpLine, MAX_LINE_LENGTH, "EXTERNAL SYSTEM_"); strncat(tmpLine, system, MAX_LINE_LENGTH); strncat(tmpLine, ":NoOfConnections", MAX_LINE_LENGTH); - m_config->put(tmpLine, nExtConnections); + ctx.m_config->put(tmpLine, nExtConnections); - if (ferror(m_initConfigStream)) { - ctx.reportError("Failure in reading"); - return false; - } - return true; + Config * ret = new Config(); + ret->m_configValues = (struct ndb_mgm_configuration*)ctx.m_configValues.getConfigValues(); + ret->m_oldConfig = ctx.m_config; ctx.m_config = 0; + return ret; } //**************************************************************************** @@ -216,7 +259,13 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) { ctx.reportWarning("[%s] %s not yet implemented", ctx.fname, fname); } if (status == ConfigInfo::DEPRICATED) { - ctx.reportWarning("[%s] %s is depricated", ctx.fname, fname); + const char * desc = m_info->getDescription(ctx.m_currentInfo, fname); + if(desc){ + ctx.reportWarning("[%s] %s is depricated, use %s instead", + ctx.fname, fname, desc); + } else { + ctx.reportWarning("[%s] %s is depricated", ctx.fname, fname); + } } // ****************************************** @@ -249,7 +298,7 @@ InitConfigFileParser::storeNameValuePair(Context& ctx, const char* fname, const char* value) { - const char * pname = m_info->getPName(ctx.m_currentInfo, fname); + const char * pname = fname; if (ctx.m_currentSection->contains(pname)) { ctx.reportError("[%s] Parameter %s specified twice", ctx.fname, fname); @@ -260,7 +309,8 @@ InitConfigFileParser::storeNameValuePair(Context& ctx, // Store name-value pair // *********************** - switch(m_info->getType(ctx.m_currentInfo, fname)){ + const ConfigInfo::Type type = m_info->getType(ctx.m_currentInfo, fname); + switch(type){ case ConfigInfo::BOOL: { bool value_bool; if (!convertStringToBool(value, value_bool)) { @@ -270,20 +320,25 @@ InitConfigFileParser::storeNameValuePair(Context& ctx, MGM_REQUIRE(ctx.m_currentSection->put(pname, value_bool)); break; } - case ConfigInfo::INT:{ - Uint32 value_int; - if (!convertStringToUint32(value, value_int)) { + case ConfigInfo::INT: + case ConfigInfo::INT64:{ + Uint64 value_int; + if (!convertStringToUint64(value, value_int)) { ctx.reportError("Illegal integer value for parameter %s", fname); return false; } if (!m_info->verify(ctx.m_currentInfo, fname, value_int)) { ctx.reportError("Illegal value %s for parameter %s.\n" - "Legal values are between %d and %d", value, fname, + "Legal values are between %Lu and %Lu", value, fname, m_info->getMin(ctx.m_currentInfo, fname), m_info->getMax(ctx.m_currentInfo, fname)); return false; } - MGM_REQUIRE(ctx.m_currentSection->put(pname, value_int)); + if(type == ConfigInfo::INT){ + MGM_REQUIRE(ctx.m_currentSection->put(pname, (Uint32)value_int)); + } else { + MGM_REQUIRE(ctx.m_currentSection->put64(pname, value_int)); + } break; } case ConfigInfo::STRING: @@ -313,8 +368,8 @@ bool InitConfigFileParser::isEmptyLine(const char* line) const { //**************************************************************************** // Convert String to Int //**************************************************************************** -bool InitConfigFileParser::convertStringToUint32(const char* s, - Uint32& val, +bool InitConfigFileParser::convertStringToUint64(const char* s, + Uint64& val, Uint32 log10base) { if (s == NULL) return false; @@ -323,7 +378,7 @@ bool InitConfigFileParser::convertStringToUint32(const char* s, errno = 0; char* p; - long v = strtol(s, &p, 10); + long long v = strtoll(s, &p, 10); if (errno != 0) return false; @@ -359,14 +414,16 @@ bool InitConfigFileParser::convertStringToBool(const char* s, bool& val) { if (!strcmp(s, "Y") || !strcmp(s, "y") || !strcmp(s, "Yes") || !strcmp(s, "YES") || !strcmp(s, "yes") || - !strcmp(s, "True") || !strcmp(s, "TRUE") || !strcmp(s, "true")) { + !strcmp(s, "True") || !strcmp(s, "TRUE") || !strcmp(s, "true") || + !strcmp(s, "1")) { val = true; return true; } if (!strcmp(s, "N") || !strcmp(s, "n") || !strcmp(s, "No") || !strcmp(s, "NO") || !strcmp(s, "no") || - !strcmp(s, "False") || !strcmp(s, "FALSE") || !strcmp(s, "false")) { + !strcmp(s, "False") || !strcmp(s, "FALSE") || !strcmp(s, "false") || + !strcmp(s, "0")) { val = false; return true; } @@ -375,21 +432,6 @@ bool InitConfigFileParser::convertStringToBool(const char* s, bool& val) { } //**************************************************************************** -// Get Config -//**************************************************************************** -const Config* InitConfigFileParser::getConfig() { - Uint32 nConnections = 0; - Uint32 nComputers = 0; - Uint32 nNodes = 0; - m_config->get("NoOfConnections", &nConnections); - m_config->get("NoOfComputers", &nComputers); - m_config->get("NoOfNodes", &nNodes); - - return m_config; -} - - -//**************************************************************************** // Parse Section Header //**************************************************************************** static void @@ -481,33 +523,30 @@ bool InitConfigFileParser::storeSection(Context& ctx){ if(ctx.m_currentSection == NULL) return true; - for(int i = strlen(ctx.fname) - 1; i>=0; i--){ ctx.fname[i] = toupper(ctx.fname[i]); } - snprintf(ctx.pname, sizeof(ctx.pname), ctx.fname); - char buf[255]; if(ctx.type == InitConfigFileParser::Section) snprintf(buf, sizeof(buf), "%s", ctx.fname); if(ctx.type == InitConfigFileParser::DefaultSection) snprintf(buf, sizeof(buf), "%s DEFAULT", ctx.fname); - snprintf(ctx.fname, sizeof(ctx.fname), buf); - for(int i = 0; i<m_info->m_NoOfRules; i++){ - const ConfigInfo::SectionRule & rule = m_info->m_SectionRules[i]; - if(strcmp(rule.m_section, ctx.fname) == 0) - if(!(* rule.m_sectionRule)(ctx, rule.m_ruleData)){ - return false; - } + if(ctx.type == InitConfigFileParser::Section){ + for(int i = 0; i<m_info->m_NoOfRules; i++){ + const ConfigInfo::SectionRule & rule = m_info->m_SectionRules[i]; + if(!strcmp(rule.m_section, "*") || !strcmp(rule.m_section, ctx.fname)) + if(!(* rule.m_sectionRule)(ctx, rule.m_ruleData)) + return false; + } } - + if(ctx.type == InitConfigFileParser::DefaultSection) - require(m_defaults->put(ctx.pname, ctx.m_currentSection)); + require(ctx.m_defaults->put(ctx.pname, ctx.m_currentSection)); if(ctx.type == InitConfigFileParser::Section) - require(m_config->put(ctx.pname, ctx.m_currentSection)); + require(ctx.m_config->put(ctx.pname, ctx.m_currentSection)); delete ctx.m_currentSection; ctx.m_currentSection = NULL; diff --git a/ndb/src/common/mgmcommon/InitConfigFileParser.hpp b/ndb/src/common/mgmcommon/InitConfigFileParser.hpp index f4f27abb055..6b7482c12ae 100644 --- a/ndb/src/common/mgmcommon/InitConfigFileParser.hpp +++ b/ndb/src/common/mgmcommon/InitConfigFileParser.hpp @@ -20,6 +20,7 @@ #include <ndb_global.h> #include <Properties.hpp> +#include <ConfigValues.hpp> class Config; class ConfigInfo; @@ -28,18 +29,40 @@ class ConfigInfo; * @class InitConfigFileParser * @brief Reads initial config file and returns Config object * - * This class contains one public method InitConfigFileParser::getConfig, + * This class contains one public method InitConfigFileParser::parseConfig, * which reads an initial configuration file and returns a Config * object if the config file has correct syntax and semantic. */ class InitConfigFileParser { public: + /** + * Constructor + */ + InitConfigFileParser(); + ~InitConfigFileParser(); + + /** + * Reads the initial configuration file, checks syntax and semantic + * and stores internally the values of all parameters. + * + * @returns Config or NULL on failure + * @note must be freed by caller + */ + Config * parseConfig(FILE * file); + Config * parseConfig(const char * filename); + + /** + * Parser context struct + */ enum ContextSectionType { Undefined, Section, DefaultSection }; /** * Context = Which section in init config file we are currently parsing */ struct Context { + Context(const ConfigInfo *); + ~Context(); + ContextSectionType type; ///< Section type (e.g. default section,section) char fname[256]; ///< Section name occuring in init config file char pname[256]; ///< Section name stored in properties object @@ -47,8 +70,8 @@ public: Uint32 m_sectionLineno; ///< Where did current section start const ConfigInfo * m_info; // The config info - const Properties * m_config; // The config object - const Properties * m_defaults; // The user defaults + Properties * m_config; // The config object + Properties * m_defaults; // The user defaults Properties * m_currentSection; // The current section I'm in const Properties * m_userDefaults; // The defaults of this section @@ -56,36 +79,13 @@ public: const Properties * m_currentInfo; // The "info" for this section Properties m_userProperties; // User properties (temporary values) + ConfigValuesFactory m_configValues; // public: void reportError(const char * msg, ...); void reportWarning(const char * msg, ...); }; - - /** - * Constructor - * @param initialConfigFileName: Name of the initial configuration file - */ - InitConfigFileParser(const char* initialConfigFileName); - ~InitConfigFileParser(); - - /** - * Reads the initial configuration file, checks syntax and semantic - * and stores internally the values of all parameters. - * - * @returns true if succeeded, o/w false (e.g. incorrect config file) - */ - bool readConfigFile(); - - /** - * Get config. Must execute InitConfigFileParser::readConfigFile first. - * - * @returns Config if succeeded, o/w NULL - */ - const Config* getConfig(); - - private: /** * Check if line only contains space/comments @@ -111,33 +111,16 @@ private: bool parseNameValuePair(Context&, const char* line); bool storeNameValuePair(Context&, const char* fname, const char* value); - bool convertStringToUint32(const char* s, Uint32& val, Uint32 log10base = 0); + bool convertStringToUint64(const char* s, Uint64& val, Uint32 log10base = 0); bool convertStringToBool(const char* s, bool& val); + bool storeSection(Context&); const Properties* getSection(const char * name, const Properties* src); - /*************************************************************************** - * VARIABLES - ***************************************************************************/ - FILE* m_initConfigStream; - /** * Information about parameters (min, max values etc) */ - const ConfigInfo* m_info; - - /** - * Configuration from initial configuration file - * (returned by InitConfigFileParser::readConfigFile) - */ - Config* m_config; - - /** - * Default values specified in default sections - */ - Properties* m_defaults; - - bool storeSection(Context&); + ConfigInfo* m_info; }; #endif // InitConfigFileParser_H diff --git a/ndb/src/common/mgmcommon/Makefile.am b/ndb/src/common/mgmcommon/Makefile.am new file mode 100644 index 00000000000..8a34fa16ed1 --- /dev/null +++ b/ndb/src/common/mgmcommon/Makefile.am @@ -0,0 +1,18 @@ +noinst_LTLIBRARIES = libmgmsrvcommon.la + +libmgmsrvcommon_la_SOURCES = \ + LocalConfig.cpp \ + Config.cpp \ + ConfigInfo.cpp \ + ConfigRetriever.cpp \ + InitConfigFileParser.cpp \ + IPCConfig.cpp NdbConfig.c + +INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi + +include $(top_srcdir)/ndb/config/common.mk.am +include $(top_srcdir)/ndb/config/type_ndbapi.mk.am +include $(top_srcdir)/ndb/config/type_mgmapiclient.mk.am + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/ndb/src/common/mgmcommon/Makefile b/ndb/src/common/mgmcommon/Makefile_old index 2db7be01d60..c7bfda7e3bf 100644 --- a/ndb/src/common/mgmcommon/Makefile +++ b/ndb/src/common/mgmcommon/Makefile_old @@ -5,6 +5,7 @@ TYPE := ndbapi mgmapiclient PIC_ARCHIVE := Y ARCHIVE_TARGET := mgmsrvcommon +# Removed temporary DIRS := printConfig SOURCES = \ @@ -17,6 +18,8 @@ SOURCES = \ SOURCES.c = NdbConfig.c +CFLAGS_IPCConfig.cpp := -I$(call fixpath,$(NDB_TOP)/src/mgmapi) + include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/common/mgmcommon/printConfig/Makefile b/ndb/src/common/mgmcommon/printConfig/Makefile index 9194316da87..77e8943e2c6 100644 --- a/ndb/src/common/mgmcommon/printConfig/Makefile +++ b/ndb/src/common/mgmcommon/printConfig/Makefile @@ -7,8 +7,10 @@ BIN_TARGET_ARCHIVES := general portlib CCFLAGS_LOC += -I.. -SOURCES := printConfig.cpp +SOURCES := printConfig.cpp ../ConfigRetriever.cpp -SOURCES.c := ../ConfigRetriever.c ../NdbConfig.c ../LocalConfig.c +SOURCES.c := ../NdbConfig.c ../LocalConfig.c + +CFLAGS_printConfig.cpp := -I$(call fixpath,$(NDB_TOP)/src/mgmapi) include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/common/mgmcommon/printConfig/printConfig.cpp b/ndb/src/common/mgmcommon/printConfig/printConfig.cpp index daa287cc44d..7cedbb451e2 100644 --- a/ndb/src/common/mgmcommon/printConfig/printConfig.cpp +++ b/ndb/src/common/mgmcommon/printConfig/printConfig.cpp @@ -18,6 +18,7 @@ #include <ndb_global.h> #include <NdbMain.h> +#include <mgmapi.h> #include <ConfigRetriever.hpp> #include <Properties.hpp> #include <NdbOut.hpp> @@ -50,9 +51,9 @@ NDB_COMMAND(printConfig, return 0; } - Properties * p = 0; ConfigRetriever c; - + struct ndb_mgm_configuration * p = 0; + if(strcmp("host", argv[1]) == 0){ int verId = 0; if(argc > 5) @@ -64,7 +65,6 @@ NDB_COMMAND(printConfig, p = c.getConfig(argv[2], atoi(argv[3]), - atoi(argv[4]), verId); } else if (strcmp("file", argv[1]) == 0){ int verId = 0; @@ -79,12 +79,11 @@ NDB_COMMAND(printConfig, } if(p != 0){ - p->print(stdout); + // + free(p); } else { ndbout << "Configuration not found: " << c.getErrorString() << endl; } - delete p; - return 0; } diff --git a/ndb/src/common/portlib/Makefile.am b/ndb/src/common/portlib/Makefile.am new file mode 100644 index 00000000000..e6ecb30fe04 --- /dev/null +++ b/ndb/src/common/portlib/Makefile.am @@ -0,0 +1,18 @@ +noinst_HEADERS = gcc.cpp + +noinst_LTLIBRARIES = libportlib.la + +libportlib_la_SOURCES = \ + NdbCondition.c NdbMutex.c NdbSleep.c NdbTick.c \ + NdbEnv.c NdbThread.c NdbHost.c NdbTCP.c \ + NdbDaemon.c NdbMem.c + +include $(top_srcdir)/ndb/config/common.mk.am +include $(top_srcdir)/ndb/config/type_util.mk.am + +EXTRA_PROGRAMS = memtest PortLibTest munmaptest + +PortLibTest_SOURCES = NdbPortLibTest.cpp +munmaptest_SOURCES = munmaptest.cpp + +# Don't update the files from bitkeeper diff --git a/ndb/src/common/portlib/Makefile b/ndb/src/common/portlib/Makefile_old index 48f4929a839..48f4929a839 100644 --- a/ndb/src/common/portlib/Makefile +++ b/ndb/src/common/portlib/Makefile_old diff --git a/ndb/src/common/portlib/unix/NdbCondition.c b/ndb/src/common/portlib/NdbCondition.c index 1d229bdcdef..1d229bdcdef 100644 --- a/ndb/src/common/portlib/unix/NdbCondition.c +++ b/ndb/src/common/portlib/NdbCondition.c diff --git a/ndb/src/common/portlib/unix/NdbDaemon.c b/ndb/src/common/portlib/NdbDaemon.c index 186331a4dab..d8d33595156 100644 --- a/ndb/src/common/portlib/unix/NdbDaemon.c +++ b/ndb/src/common/portlib/NdbDaemon.c @@ -18,9 +18,9 @@ #include "NdbDaemon.h" #define NdbDaemon_ErrorSize 500 -long NdbDaemon_DaemonPid; -int NdbDaemon_ErrorCode; -char NdbDaemon_ErrorText[NdbDaemon_ErrorSize]; +long NdbDaemon_DaemonPid = 0; +int NdbDaemon_ErrorCode = 0; +char NdbDaemon_ErrorText[NdbDaemon_ErrorSize] = ""; int NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags) diff --git a/ndb/src/common/portlib/unix/NdbEnv.c b/ndb/src/common/portlib/NdbEnv.c index d294e0b52ca..d294e0b52ca 100644 --- a/ndb/src/common/portlib/unix/NdbEnv.c +++ b/ndb/src/common/portlib/NdbEnv.c diff --git a/ndb/src/common/portlib/unix/NdbHost.c b/ndb/src/common/portlib/NdbHost.c index 4749bb39ea7..4749bb39ea7 100644 --- a/ndb/src/common/portlib/unix/NdbHost.c +++ b/ndb/src/common/portlib/NdbHost.c diff --git a/ndb/src/common/portlib/unix/NdbMem.c b/ndb/src/common/portlib/NdbMem.c index 0b06e5b23f1..0b06e5b23f1 100644 --- a/ndb/src/common/portlib/unix/NdbMem.c +++ b/ndb/src/common/portlib/NdbMem.c diff --git a/ndb/src/common/portlib/unix/NdbMutex.c b/ndb/src/common/portlib/NdbMutex.c index 50f314d2683..50f314d2683 100644 --- a/ndb/src/common/portlib/unix/NdbMutex.c +++ b/ndb/src/common/portlib/NdbMutex.c diff --git a/ndb/src/common/portlib/test/NdbPortLibTest.cpp b/ndb/src/common/portlib/NdbPortLibTest.cpp index 55b9ccec5f2..55b9ccec5f2 100644 --- a/ndb/src/common/portlib/test/NdbPortLibTest.cpp +++ b/ndb/src/common/portlib/NdbPortLibTest.cpp diff --git a/ndb/src/common/portlib/unix/NdbSleep.c b/ndb/src/common/portlib/NdbSleep.c index 8702a25d1b1..8702a25d1b1 100644 --- a/ndb/src/common/portlib/unix/NdbSleep.c +++ b/ndb/src/common/portlib/NdbSleep.c diff --git a/ndb/src/common/portlib/unix/NdbTCP.c b/ndb/src/common/portlib/NdbTCP.c index 287dc6c2ecd..287dc6c2ecd 100644 --- a/ndb/src/common/portlib/unix/NdbTCP.c +++ b/ndb/src/common/portlib/NdbTCP.c diff --git a/ndb/src/common/portlib/unix/NdbThread.c b/ndb/src/common/portlib/NdbThread.c index a5c42f79be8..8683a37edcb 100644 --- a/ndb/src/common/portlib/unix/NdbThread.c +++ b/ndb/src/common/portlib/NdbThread.c @@ -21,6 +21,7 @@ #define MAX_THREAD_NAME 16 +/*#define USE_PTHREAD_EXTRAS*/ struct NdbThread { @@ -52,14 +53,14 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func, pthread_attr_init(&thread_attr); pthread_attr_setstacksize(&thread_attr, thread_stack_size); -#if defined NDB_SOLARIS -#if !defined NDB_SOLARIS6 +#ifdef USE_PTHREAD_EXTRAS /* Guard stack overflow with a 2k databuffer */ pthread_attr_setguardsize(&thread_attr, 2048); #endif -#endif +#ifdef PTHREAD_CREATE_JOINABLE /* needed on SCO */ pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE); +#endif result = pthread_create(&tmpThread->thread, &thread_attr, p_thread_func, @@ -104,7 +105,7 @@ void NdbThread_Exit(int status) int NdbThread_SetConcurrencyLevel(int level) { -#ifndef NDB_SOLARIS6 +#ifdef USE_PTHREAD_EXTRAS return pthread_setconcurrency(level); #else return 0; diff --git a/ndb/src/common/portlib/unix/NdbTick.c b/ndb/src/common/portlib/NdbTick.c index d8f0b6ec27a..d8f0b6ec27a 100644 --- a/ndb/src/common/portlib/unix/NdbTick.c +++ b/ndb/src/common/portlib/NdbTick.c diff --git a/ndb/src/common/portlib/gcc.cpp b/ndb/src/common/portlib/gcc.cpp index 41b1373ee78..66aa4812dc6 100644 --- a/ndb/src/common/portlib/gcc.cpp +++ b/ndb/src/common/portlib/gcc.cpp @@ -2,6 +2,6 @@ /** * GCC linking problem... */ -#if ( __GNUC__ == 3 ) +#ifdef DEFINE_CXA_PURE_VIRTUAL extern "C" { int __cxa_pure_virtual() { return 0;} } #endif diff --git a/ndb/src/common/portlib/memtest/memtest.c b/ndb/src/common/portlib/memtest.c index 059a4ec025e..059a4ec025e 100644 --- a/ndb/src/common/portlib/memtest/memtest.c +++ b/ndb/src/common/portlib/memtest.c diff --git a/ndb/src/common/portlib/mmstest/mmslist.cpp b/ndb/src/common/portlib/mmslist.cpp index 05538785293..05538785293 100644 --- a/ndb/src/common/portlib/mmstest/mmslist.cpp +++ b/ndb/src/common/portlib/mmslist.cpp diff --git a/ndb/src/common/portlib/mmstest/mmstest.cpp b/ndb/src/common/portlib/mmstest.cpp index 9cc7d810985..9cc7d810985 100644 --- a/ndb/src/common/portlib/mmstest/mmstest.cpp +++ b/ndb/src/common/portlib/mmstest.cpp diff --git a/ndb/src/common/portlib/memtest/munmaptest/munmaptest.cpp b/ndb/src/common/portlib/munmaptest.cpp index b1d84131810..b1d84131810 100644 --- a/ndb/src/common/portlib/memtest/munmaptest/munmaptest.cpp +++ b/ndb/src/common/portlib/munmaptest.cpp diff --git a/ndb/src/common/portlib/memtest/Makefile b/ndb/src/common/portlib/old_dirs/memtest/Makefile index 716cdbdea82..716cdbdea82 100644 --- a/ndb/src/common/portlib/memtest/Makefile +++ b/ndb/src/common/portlib/old_dirs/memtest/Makefile diff --git a/ndb/src/common/portlib/memtest/munmaptest/Makefile b/ndb/src/common/portlib/old_dirs/memtest/munmaptest/Makefile index ea8c5238d1c..ea8c5238d1c 100644 --- a/ndb/src/common/portlib/memtest/munmaptest/Makefile +++ b/ndb/src/common/portlib/old_dirs/memtest/munmaptest/Makefile diff --git a/ndb/src/common/portlib/ose/Makefile b/ndb/src/common/portlib/old_dirs/ose/Makefile index 4ef93b7824a..4ef93b7824a 100644 --- a/ndb/src/common/portlib/ose/Makefile +++ b/ndb/src/common/portlib/old_dirs/ose/Makefile diff --git a/ndb/src/common/portlib/ose/NdbCondition.c b/ndb/src/common/portlib/old_dirs/ose/NdbCondition.c index 73a2dbc5d66..73a2dbc5d66 100644 --- a/ndb/src/common/portlib/ose/NdbCondition.c +++ b/ndb/src/common/portlib/old_dirs/ose/NdbCondition.c diff --git a/ndb/src/common/portlib/ose/NdbConditionOSE.h b/ndb/src/common/portlib/old_dirs/ose/NdbConditionOSE.h index bd0306261cc..bd0306261cc 100644 --- a/ndb/src/common/portlib/ose/NdbConditionOSE.h +++ b/ndb/src/common/portlib/old_dirs/ose/NdbConditionOSE.h diff --git a/ndb/src/common/portlib/ose/NdbEnv.c b/ndb/src/common/portlib/old_dirs/ose/NdbEnv.c index e2ac4d879d2..e2ac4d879d2 100644 --- a/ndb/src/common/portlib/ose/NdbEnv.c +++ b/ndb/src/common/portlib/old_dirs/ose/NdbEnv.c diff --git a/ndb/src/common/portlib/ose/NdbHost.c b/ndb/src/common/portlib/old_dirs/ose/NdbHost.c index f5e1e511c16..f5e1e511c16 100644 --- a/ndb/src/common/portlib/ose/NdbHost.c +++ b/ndb/src/common/portlib/old_dirs/ose/NdbHost.c diff --git a/ndb/src/common/portlib/ose/NdbMem.c b/ndb/src/common/portlib/old_dirs/ose/NdbMem.c index 0e38024bbb4..0e38024bbb4 100644 --- a/ndb/src/common/portlib/ose/NdbMem.c +++ b/ndb/src/common/portlib/old_dirs/ose/NdbMem.c diff --git a/ndb/src/common/portlib/ose/NdbMem_SoftOse.cpp b/ndb/src/common/portlib/old_dirs/ose/NdbMem_SoftOse.cpp index cad22c0474b..cad22c0474b 100644 --- a/ndb/src/common/portlib/ose/NdbMem_SoftOse.cpp +++ b/ndb/src/common/portlib/old_dirs/ose/NdbMem_SoftOse.cpp diff --git a/ndb/src/common/portlib/ose/NdbMutex.c b/ndb/src/common/portlib/old_dirs/ose/NdbMutex.c index 253c0e412ff..253c0e412ff 100644 --- a/ndb/src/common/portlib/ose/NdbMutex.c +++ b/ndb/src/common/portlib/old_dirs/ose/NdbMutex.c diff --git a/ndb/src/common/portlib/ose/NdbOut.cpp b/ndb/src/common/portlib/old_dirs/ose/NdbOut.cpp index eb81bc9d971..eb81bc9d971 100644 --- a/ndb/src/common/portlib/ose/NdbOut.cpp +++ b/ndb/src/common/portlib/old_dirs/ose/NdbOut.cpp diff --git a/ndb/src/common/portlib/ose/NdbSleep.c b/ndb/src/common/portlib/old_dirs/ose/NdbSleep.c index 70fd83117ef..70fd83117ef 100644 --- a/ndb/src/common/portlib/ose/NdbSleep.c +++ b/ndb/src/common/portlib/old_dirs/ose/NdbSleep.c diff --git a/ndb/src/common/portlib/ose/NdbTCP.c b/ndb/src/common/portlib/old_dirs/ose/NdbTCP.c index 9994697b3f8..9994697b3f8 100644 --- a/ndb/src/common/portlib/ose/NdbTCP.c +++ b/ndb/src/common/portlib/old_dirs/ose/NdbTCP.c diff --git a/ndb/src/common/portlib/ose/NdbThread.c b/ndb/src/common/portlib/old_dirs/ose/NdbThread.c index e46903a5cce..e46903a5cce 100644 --- a/ndb/src/common/portlib/ose/NdbThread.c +++ b/ndb/src/common/portlib/old_dirs/ose/NdbThread.c diff --git a/ndb/src/common/portlib/ose/NdbTick.c b/ndb/src/common/portlib/old_dirs/ose/NdbTick.c index c3deae2bec3..c3deae2bec3 100644 --- a/ndb/src/common/portlib/ose/NdbTick.c +++ b/ndb/src/common/portlib/old_dirs/ose/NdbTick.c diff --git a/ndb/src/common/portlib/test/Makefile b/ndb/src/common/portlib/old_dirs/test/Makefile index 4edc98ede75..4edc98ede75 100644 --- a/ndb/src/common/portlib/test/Makefile +++ b/ndb/src/common/portlib/old_dirs/test/Makefile diff --git a/ndb/src/common/portlib/unix/Makefile b/ndb/src/common/portlib/old_dirs/unix/Makefile_old index 452196d9f08..452196d9f08 100644 --- a/ndb/src/common/portlib/unix/Makefile +++ b/ndb/src/common/portlib/old_dirs/unix/Makefile_old diff --git a/ndb/src/common/portlib/win32/Makefile b/ndb/src/common/portlib/old_dirs/win32/Makefile index bb29ac5547e..bb29ac5547e 100644 --- a/ndb/src/common/portlib/win32/Makefile +++ b/ndb/src/common/portlib/old_dirs/win32/Makefile diff --git a/ndb/src/common/portlib/win32/NdbCondition.c b/ndb/src/common/portlib/old_dirs/win32/NdbCondition.c index 77869b673de..77869b673de 100644 --- a/ndb/src/common/portlib/win32/NdbCondition.c +++ b/ndb/src/common/portlib/old_dirs/win32/NdbCondition.c diff --git a/ndb/src/common/portlib/win32/NdbDaemon.c b/ndb/src/common/portlib/old_dirs/win32/NdbDaemon.c index 972fb1b88d8..972fb1b88d8 100644 --- a/ndb/src/common/portlib/win32/NdbDaemon.c +++ b/ndb/src/common/portlib/old_dirs/win32/NdbDaemon.c diff --git a/ndb/src/common/portlib/win32/NdbEnv.c b/ndb/src/common/portlib/old_dirs/win32/NdbEnv.c index 0df703a5e97..0df703a5e97 100644 --- a/ndb/src/common/portlib/win32/NdbEnv.c +++ b/ndb/src/common/portlib/old_dirs/win32/NdbEnv.c diff --git a/ndb/src/common/portlib/win32/NdbHost.c b/ndb/src/common/portlib/old_dirs/win32/NdbHost.c index f91dd1a531c..f91dd1a531c 100644 --- a/ndb/src/common/portlib/win32/NdbHost.c +++ b/ndb/src/common/portlib/old_dirs/win32/NdbHost.c diff --git a/ndb/src/common/portlib/win32/NdbMem.c b/ndb/src/common/portlib/old_dirs/win32/NdbMem.c index ab7123b0a29..ab7123b0a29 100644 --- a/ndb/src/common/portlib/win32/NdbMem.c +++ b/ndb/src/common/portlib/old_dirs/win32/NdbMem.c diff --git a/ndb/src/common/portlib/win32/NdbMutex.c b/ndb/src/common/portlib/old_dirs/win32/NdbMutex.c index e797024d5bb..e797024d5bb 100644 --- a/ndb/src/common/portlib/win32/NdbMutex.c +++ b/ndb/src/common/portlib/old_dirs/win32/NdbMutex.c diff --git a/ndb/src/common/portlib/win32/NdbSleep.c b/ndb/src/common/portlib/old_dirs/win32/NdbSleep.c index ac0f44dd07f..ac0f44dd07f 100644 --- a/ndb/src/common/portlib/win32/NdbSleep.c +++ b/ndb/src/common/portlib/old_dirs/win32/NdbSleep.c diff --git a/ndb/src/common/portlib/win32/NdbTCP.c b/ndb/src/common/portlib/old_dirs/win32/NdbTCP.c index 483a53bd606..483a53bd606 100644 --- a/ndb/src/common/portlib/win32/NdbTCP.c +++ b/ndb/src/common/portlib/old_dirs/win32/NdbTCP.c diff --git a/ndb/src/common/portlib/win32/NdbThread.c b/ndb/src/common/portlib/old_dirs/win32/NdbThread.c index 1f052f034e8..1f052f034e8 100644 --- a/ndb/src/common/portlib/win32/NdbThread.c +++ b/ndb/src/common/portlib/old_dirs/win32/NdbThread.c diff --git a/ndb/src/common/portlib/win32/NdbTick.c b/ndb/src/common/portlib/old_dirs/win32/NdbTick.c index e3a67d8437d..e3a67d8437d 100644 --- a/ndb/src/common/portlib/win32/NdbTick.c +++ b/ndb/src/common/portlib/old_dirs/win32/NdbTick.c diff --git a/ndb/src/common/transporter/Makefile.am b/ndb/src/common/transporter/Makefile.am new file mode 100644 index 00000000000..218b261606d --- /dev/null +++ b/ndb/src/common/transporter/Makefile.am @@ -0,0 +1,22 @@ + +noinst_LTLIBRARIES = libtransporter.la + +libtransporter_la_SOURCES = \ + Transporter.cpp \ + SendBuffer.cpp \ + TCP_Transporter.cpp \ + TransporterRegistry.cpp \ + Packer.cpp + +EXTRA_libtransporter_la_SOURCES = SHM_Transporter.cpp SHM_Transporter.unix.cpp SCI_Transporter.cpp + +libtransporter_la_LIBADD = @ndb_transporter_opt_objs@ +libtransporter_la_DEPENDENCIES = @ndb_transporter_opt_objs@ + +INCLUDES_LOC = -I$(top_srcdir)/ndb/include/kernel -I$(top_srcdir)/ndb/include/transporter + +include $(top_srcdir)/ndb/config/common.mk.am +include $(top_srcdir)/ndb/config/type_util.mk.am + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/ndb/src/common/transporter/Makefile b/ndb/src/common/transporter/Makefile_old index 372bf640566..372bf640566 100644 --- a/ndb/src/common/transporter/Makefile +++ b/ndb/src/common/transporter/Makefile_old diff --git a/ndb/src/common/transporter/Transporter.hpp b/ndb/src/common/transporter/Transporter.hpp index c562451a1b0..43b26d45899 100644 --- a/ndb/src/common/transporter/Transporter.hpp +++ b/ndb/src/common/transporter/Transporter.hpp @@ -17,6 +17,8 @@ #ifndef Transporter_H #define Transporter_H +#include <ndb_global.h> + #include <TransporterCallback.hpp> #include "TransporterDefinitions.hpp" #include "Packer.hpp" diff --git a/ndb/src/common/util/Base64.cpp b/ndb/src/common/util/Base64.cpp index 482d0b10ad2..f7a490d427d 100644 --- a/ndb/src/common/util/Base64.cpp +++ b/ndb/src/common/util/Base64.cpp @@ -22,89 +22,186 @@ static char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789+/"; int -base64_encode(UtilBuffer &src, BaseString &dst) { - char *s = (char *)src.get_data(); - int i = 0; +base64_encode(const UtilBuffer &src, BaseString &dst) { + const unsigned char *s = (const unsigned char *)src.get_data(); + size_t i = 0; + size_t len = 0; + size_t src_len = src.length(); + while(i < src_len) { + if(len == 76){ + len = 0; + dst.append('\n'); + } - while(i < src.length()) { - int c; + unsigned c; c = s[i++]; c <<= 8; - if(i < src.length()) + if(i < src_len) c += s[i]; c <<= 8; i++; - if(i < src.length()) + if(i < src_len) c += s[i]; i++; - + dst.append(base64_table[(c >> 18) & 0x3f]); dst.append(base64_table[(c >> 12) & 0x3f]); - if(i > (src.length() + 1)) + if(i > (src_len + 1)) dst.append('='); else dst.append(base64_table[(c >> 6) & 0x3f]); - if(i > src.length()) + if(i > src_len) dst.append('='); else dst.append(base64_table[(c >> 0) & 0x3f]); + + len += 4; } return 0; } -static inline int -pos(char c) { +static inline unsigned +pos(unsigned char c) { return strchr(base64_table, c) - base64_table; } int -base64_decode(BaseString &src, UtilBuffer &dst) { - size_t size; - size = (src.length() * 3) / 4; +base64_decode(const BaseString &src, UtilBuffer &dst) { + return base64_decode(src.c_str(), src.length(), dst); +} + +#define SKIP_SPACE(src, i, size){ \ + while(i < size && isspace(* src)){ \ + i++; \ + src++; \ + } \ + if(i == size){ \ + i = size + 1; \ + break; \ + } \ +} + +int +base64_decode(const char * src, size_t size, UtilBuffer &dst) { size_t i = 0; - const char *s = src.c_str(); - while(i < size) { - int c = 0; + while(i < size){ + unsigned c = 0; int mark = 0; - c += pos(*s++); + + SKIP_SPACE(src, i, size); + + c += pos(*src++); c <<= 6; i++; - c += pos(*s++); + SKIP_SPACE(src, i, size); + + c += pos(*src++); c <<= 6; i++; - if(*s != '=') - c += pos(*s++); + SKIP_SPACE(src, i, size); + + if(* src != '=') + c += pos(*src++); else { - size--; - mark++; + i = size; + mark = 2; + c <<= 6; + goto end; } c <<= 6; i++; - if(*s != '=') - c += pos(*s++); + SKIP_SPACE(src, i, size); + + if(*src != '=') + c += pos(*src++); else { - size--; - mark++; + i = size; + mark = 1; + goto end; } - /* c <<= 6; */ i++; + end: char b[3]; - - b[0] = (c >> 16) & 0xff; b[1] = (c >> 8) & 0xff; b[2] = (c >> 0) & 0xff; - + dst.append((void *)b, 3-mark); } + + if(i != size){ + abort(); + return -1; + } return 0; } + +#ifdef __TEST__B64 +/** + * USER_FLAGS="-D__TEST__B64" make Base64.o && g++ Base64.o BaseString.o + */ +inline +void +require(bool b){ + if(!b) + abort(); +} + +int +main(void){ + for(int i = 0; i < 500; i++){ + const size_t len = rand() % 10000 + 1; + UtilBuffer src; + for(size_t j = 0; j<len; j++){ + char c = rand(); + src.append(&c, 1); + } + require(src.length() == len); + + BaseString str; + require(base64_encode(src, str) == 0); + + if(str.length() == 3850){ + printf(">%s<\n", str.c_str()); + } + + UtilBuffer dst; + require(base64_decode(str, dst) == 0); + require(dst.length() == src.length()); + + const char * c_src = (char*)src.get_data(); + const char * c_dst = (char*)dst.get_data(); + if(memcmp(src.get_data(), dst.get_data(), src.length()) != 0){ + printf("-- src --\n"); + for(int i2 = 0; i2<len; i2++){ + unsigned char c = c_src[i2]; + printf("%.2x ", (unsigned)c); + if((i2 % 8) == 7) + printf("\n"); + } + printf("\n"); + + printf("-- dst --\n"); + for(int i2 = 0; i2<len; i2++){ + unsigned char c = c_dst[i2]; + printf("%.2x ", (unsigned)c); + if((i2 % 8) == 7) + printf("\n"); + } + printf("\n"); + abort(); + } + } + return 0; +} + +#endif diff --git a/ndb/src/common/util/ConfigValues.cpp b/ndb/src/common/util/ConfigValues.cpp new file mode 100644 index 00000000000..18ecf4bcdc4 --- /dev/null +++ b/ndb/src/common/util/ConfigValues.cpp @@ -0,0 +1,743 @@ +#include <ConfigValues.hpp> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include <new> +#include <NdbOut.hpp> +#include <NdbTCP.h> + +static Uint32 hash(Uint32 key, Uint32 size); +static Uint32 nextHash(Uint32 key, Uint32 size, Uint32 pos, Uint32 count); +static bool findKey(const Uint32 * vals, Uint32 sz, Uint32 key, Uint32 * pos); + +/** + * Key + * + * t = Type - 4 bits 0-15 + * s = Section - 14 bits 0-16383 + * k = Key value - 14 bits 0-16383 + * + * 1111111111222222222233 + * 01234567890123456789012345678901 + * kkkkkkkkkkkkkkssssssssssssssoooo + */ +#define KP_TYPE_MASK (15) +#define KP_TYPE_SHIFT (28) +#define KP_SECTION_MASK (0x3FFF) +#define KP_SECTION_SHIFT (14) +#define KP_KEYVAL_MASK (0x3FFF) +#define KP_KEYVAL_SHIFT (0) +#define KP_MASK (0x0FFFFFFF) + +static const Uint32 CFV_KEY_PARENT = (KP_KEYVAL_MASK - 1); +static const Uint32 CFV_KEY_FREE = ~0; + +static const char Magic[] = { 'N', 'D', 'B', 'C', 'O', 'N', 'F', 'V' }; + +//#define DEBUG_CV +#ifdef DEBUG_CV +#define DEBUG +#else +#define DEBUG if(0) +#endif + +inline +ConfigValues::ValueType +getTypeOf(Uint32 k) { + return (ConfigValues::ValueType)((k >> KP_TYPE_SHIFT) & KP_TYPE_MASK); +} + +ConfigValues::ConfigValues(Uint32 sz, Uint32 dsz){ + m_size = sz; + m_dataSize = dsz; + m_stringCount = 0; + m_int64Count = 0; + for(Uint32 i = 0; i<m_size; i++){ + m_values[i << 1] = CFV_KEY_FREE; + } +} + +ConfigValues::~ConfigValues(){ + for(Uint32 i = 0; i<m_stringCount; i++){ + free(getString(i)); + } +} + +bool +ConfigValues::ConstIterator::get(Uint32 key, Entry * result) const { + Uint32 pos; + if(!findKey(m_cfg.m_values, m_cfg.m_size, key | m_currentSection, &pos)){ + return false; + } + + result->m_key = key; + return m_cfg.getByPos(pos, result); +} + +bool +ConfigValues::getByPos(Uint32 pos, Entry * result) const { + assert(pos < (2 * m_size)); + Uint32 keypart = m_values[pos]; + Uint32 val = m_values[pos+1]; + + switch(::getTypeOf(keypart)){ + case IntType: + case SectionType: + result->m_int = val; + break; + case StringType: + result->m_string = getString(val); + break; + case Int64Type: + result->m_int64 = get64(val); + break; + case InvalidType: + default: + return false; + } + + result->m_type = ::getTypeOf(keypart); + + return true; +} + +Uint64 & +ConfigValues::get64(Uint32 index) const { + assert(index < m_int64Count); + Uint64 * ptr = (Uint64*)(&m_values[m_size << 1]); + return ptr[index]; +} + +char * & +ConfigValues::getString(Uint32 index) const { + assert(index < m_stringCount); + char ** ptr = (char**)(((char *)&(m_values[m_size << 1])) + m_dataSize); + return ptr[-index]; +} + +bool +ConfigValues::ConstIterator::openSection(Uint32 key, Uint32 no){ + Uint32 curr = m_currentSection; + + Entry tmp; + if(get(key, &tmp) && tmp.m_type == SectionType){ + m_currentSection = tmp.m_int; + if(get(no, &tmp) && tmp.m_type == IntType){ + m_currentSection = tmp.m_int; + /** + * Validate + */ + if(get(CFV_KEY_PARENT, &tmp)){ + return true; + } + } + } + + m_currentSection = curr; + return false; +} + +bool +ConfigValues::ConstIterator::closeSection() { + + Entry tmp; + if(get(CFV_KEY_PARENT, &tmp) && tmp.m_type == IntType){ + m_currentSection = tmp.m_int; + return true; + } + + return false; +} + +bool +ConfigValues::Iterator::set(Uint32 key, Uint32 value){ + Uint32 pos; + if(!findKey(m_cfg.m_values, m_cfg.m_size, key | m_currentSection, &pos)){ + return false; + } + + if(::getTypeOf(m_cfg.m_values[pos]) != IntType){ + return false; + } + + m_cfg.m_values[pos+1] = value; + return true; +} + +bool +ConfigValues::Iterator::set(Uint32 key, Uint64 value){ + Uint32 pos; + if(!findKey(m_cfg.m_values, m_cfg.m_size, key | m_currentSection, &pos)){ + return false; + } + + if(::getTypeOf(m_cfg.m_values[pos]) != Int64Type){ + return false; + } + + m_cfg.get64(m_cfg.m_values[pos+1]) = value; + return true; +} + +bool +ConfigValues::Iterator::set(Uint32 key, const char * value){ + Uint32 pos; + if(!findKey(m_cfg.m_values, m_cfg.m_size, key | m_currentSection, &pos)){ + return false; + } + + if(::getTypeOf(m_cfg.m_values[pos]) != StringType){ + return false; + } + + char * & str = m_cfg.getString(m_cfg.m_values[pos+1]); + free(str); + str = strdup(value ? value : ""); + return true; +} + +static +bool +findKey(const Uint32 * values, Uint32 sz, Uint32 key, Uint32 * _pos){ + Uint32 pos = hash(key, sz); + Uint32 count = 0; + while((values[pos] & KP_MASK) != key && count < sz){ + pos = nextHash(key, sz, pos, ++count); + } + + if((values[pos] & KP_MASK)== key){ + *_pos = pos; + return true; + } + return false; +} + +static +Uint32 +hash(Uint32 key, Uint32 size){ + Uint32 tmp = (key >> 16) ^ (key & 0xFFFF); + return (((tmp << 16) | tmp) % size) << 1; +} + +static +Uint32 +nextHash(Uint32 key, Uint32 size, Uint32 pos, Uint32 count){ + Uint32 p = (pos >> 1); + if((key % size) != 0) + p += key; + else + p += 1; + return (p % size) << 1; +} + +static +Uint32 +directory(Uint32 sz){ + const Uint32 _input = sz; + if((sz & 1) == 0) + sz ++; + + bool prime = false; + while(!prime){ + prime = true; + for(Uint32 n = 3; n*n <= sz; n += 2){ + if((sz % n) == 0){ + prime = false; + sz += 2; + break; + } + } + } + DEBUG printf("directory %d -> %d\n", _input, sz); + return sz; +} + +ConfigValuesFactory::ConfigValuesFactory(Uint32 keys, Uint32 data){ + m_sectionCounter = (1 << KP_SECTION_SHIFT); + m_freeKeys = directory(keys); + m_freeData = data; + m_currentSection = 0; + m_cfg = create(m_freeKeys, data); +} + +ConfigValuesFactory::ConfigValuesFactory(ConfigValues * cfg){ + m_cfg = cfg; + m_freeKeys = 0; + m_freeData = m_cfg->m_dataSize; + m_sectionCounter = (1 << KP_SECTION_SHIFT); + m_currentSection = 0; + const Uint32 sz = 2 * m_cfg->m_size; + for(Uint32 i = 0; i<sz; i += 2){ + const Uint32 key = m_cfg->m_values[i]; + if(key == CFV_KEY_FREE){ + m_freeKeys++; + } else { + switch(::getTypeOf(key)){ + case ConfigValues::IntType: + case ConfigValues::SectionType: + break; + case ConfigValues::Int64Type: + m_freeData -= sizeof(Uint64); + break; + case ConfigValues::StringType: + m_freeData -= sizeof(char *); + break; + case ConfigValues::InvalidType: + abort(); + } + Uint32 sec = key & (KP_SECTION_MASK << KP_SECTION_SHIFT); + m_sectionCounter = (sec > m_sectionCounter ? sec : m_sectionCounter); + } + } +} + +ConfigValues * +ConfigValuesFactory::create(Uint32 keys, Uint32 data){ + Uint32 sz = sizeof(ConfigValues); + sz += (2 * keys * sizeof(Uint32)); + sz += data; + + void * tmp = malloc(sz); + return new (tmp) ConfigValues(keys, data); +} + +void +ConfigValuesFactory::expand(Uint32 fk, Uint32 fs){ + if(m_freeKeys >= fk && m_freeData >= fs){ + return ; + } + + m_freeKeys = (m_freeKeys >= fk ? m_cfg->m_size : fk + m_cfg->m_size); + m_freeData = (m_freeData >= fs ? m_cfg->m_dataSize : fs + m_cfg->m_dataSize); + m_freeKeys = directory(m_freeKeys); + + ConfigValues * m_tmp = m_cfg; + m_cfg = create(m_freeKeys, m_freeData); + put(* m_tmp); + m_tmp->~ConfigValues(); + free(m_tmp); +} + +void +ConfigValuesFactory::shrink(){ + if(m_freeKeys == 0 && m_freeData == 0){ + return ; + } + + m_freeKeys = m_cfg->m_size - m_freeKeys; + m_freeData = m_cfg->m_dataSize - m_freeData; + m_freeKeys = directory(m_freeKeys); + + ConfigValues * m_tmp = m_cfg; + m_cfg = create(m_freeKeys, m_freeData); + put(* m_tmp); + m_tmp->~ConfigValues(); + free(m_tmp); +} + +bool +ConfigValuesFactory::openSection(Uint32 key, Uint32 no){ + ConfigValues::Entry tmp; + const Uint32 parent = m_currentSection; + + ConfigValues::ConstIterator iter(* m_cfg); + iter.m_currentSection = m_currentSection; + if(!iter.get(key, &tmp)){ + + tmp.m_key = key; + tmp.m_type = ConfigValues::SectionType; + tmp.m_int = m_sectionCounter; + m_sectionCounter += (1 << KP_SECTION_SHIFT); + + if(!put(tmp)){ + return false; + } + } + + if(tmp.m_type != ConfigValues::SectionType){ + return false; + } + + m_currentSection = tmp.m_int; + + tmp.m_key = no; + tmp.m_type = ConfigValues::IntType; + tmp.m_int = m_sectionCounter; + if(!put(tmp)){ + m_currentSection = parent; + return false; + } + m_sectionCounter += (1 << KP_SECTION_SHIFT); + + m_currentSection = tmp.m_int; + tmp.m_type = ConfigValues::IntType; + tmp.m_key = CFV_KEY_PARENT; + tmp.m_int = parent; + if(!put(tmp)){ + m_currentSection = parent; + return false; + } + + return true; +} + +bool +ConfigValuesFactory::closeSection(){ + ConfigValues::ConstIterator iter(* m_cfg); + iter.m_currentSection = m_currentSection; + const bool b = iter.closeSection(); + m_currentSection = iter.m_currentSection; + return b; +} + +bool +ConfigValuesFactory::put(const ConfigValues::Entry & entry){ + + if(m_freeKeys == 0 || + (entry.m_type == ConfigValues::StringType && m_freeData < sizeof(char *)) + || (entry.m_type == ConfigValues::Int64Type && m_freeData < 8 )){ + + DEBUG ndbout_c("m_freeKeys = %d, m_freeData = %d -> expand", + m_freeKeys, m_freeData); + + expand(31, 20); + } + + const Uint32 tmp = entry.m_key | m_currentSection; + const Uint32 sz = m_cfg->m_size; + Uint32 pos = hash(tmp, sz); + Uint32 count = 0; + Uint32 val = m_cfg->m_values[pos]; + + while((val & KP_MASK) != tmp && val != CFV_KEY_FREE && count < sz){ + pos = nextHash(tmp, sz, pos, ++count); + val = m_cfg->m_values[pos]; + } + + if((val & KP_MASK) == tmp){ + DEBUG ndbout_c("key %x already found at pos: %d", tmp, pos); + return false; + } + + if(count >= sz){ + pos = hash(tmp, sz); + count = 0; + Uint32 val = m_cfg->m_values[pos]; + + printf("key: %d, (key %% size): %d\n", entry.m_key, (entry.m_key % sz)); + printf("pos: %d", pos); + while((val & KP_MASK) != tmp && val != CFV_KEY_FREE && count < sz){ + pos = nextHash(tmp, sz, pos, ++count); + val = m_cfg->m_values[pos]; + printf(" %d", pos); + } + printf("\n"); + + abort(); + printf("Full\n"); + return false; + } + + assert(pos < (sz << 1)); + + Uint32 key = tmp; + key |= (entry.m_type << KP_TYPE_SHIFT); + m_cfg->m_values[pos] = key; + switch(entry.m_type){ + case ConfigValues::IntType: + case ConfigValues::SectionType: + m_cfg->m_values[pos+1] = entry.m_int; + m_freeKeys--; + DEBUG printf("Putting at: %d(%d) (loop = %d) key: %d value: %d\n", + pos, sz, count, + (key >> KP_KEYVAL_SHIFT) & KP_KEYVAL_MASK, + entry.m_int); + return true; + case ConfigValues::StringType:{ + Uint32 index = m_cfg->m_stringCount++; + m_cfg->m_values[pos+1] = index; + m_cfg->getString(index) = strdup(entry.m_string ? entry.m_string : ""); + m_freeKeys--; + m_freeData -= sizeof(char *); + DEBUG printf("Putting at: %d(%d) (loop = %d) key: %d value(%d): %s\n", + pos, sz, count, + (key >> KP_KEYVAL_SHIFT) & KP_KEYVAL_MASK, + index, + entry.m_string); + return true; + } + case ConfigValues::Int64Type:{ + Uint32 index = m_cfg->m_int64Count++; + m_cfg->m_values[pos+1] = index; + m_cfg->get64(index) = entry.m_int64; + m_freeKeys--; + m_freeData -= 8; + DEBUG printf("Putting at: %d(%d) (loop = %d) key: %d value64(%d): %lld\n", + pos, sz, count, + (key >> KP_KEYVAL_SHIFT) & KP_KEYVAL_MASK, + index, + entry.m_int64); + return true; + } + case ConfigValues::InvalidType: + default: + return false; + } + return false; +} + +void +ConfigValuesFactory::put(const ConfigValues & cfg){ + + Uint32 curr = m_currentSection; + m_currentSection = 0; + + ConfigValues::Entry tmp; + for(Uint32 i = 0; i < 2 * cfg.m_size; i += 2){ + if(cfg.m_values[i] != CFV_KEY_FREE){ + tmp.m_key = cfg.m_values[i]; + cfg.getByPos(i, &tmp); + put(tmp); + } + } + + m_currentSection = curr; +} + +ConfigValues * +ConfigValuesFactory::extractCurrentSection(const ConfigValues::ConstIterator & cfg){ + ConfigValuesFactory * fac = new ConfigValuesFactory(20, 20); + Uint32 curr = cfg.m_currentSection; + + ConfigValues::Entry tmp; + for(Uint32 i = 0; i < 2 * cfg.m_cfg.m_size; i += 2){ + Uint32 keypart = cfg.m_cfg.m_values[i]; + const Uint32 sec = keypart & (KP_SECTION_MASK << KP_SECTION_SHIFT); + const Uint32 key = keypart & KP_KEYVAL_MASK; + if(sec == curr && key != CFV_KEY_PARENT){ + tmp.m_key = cfg.m_cfg.m_values[i]; + cfg.m_cfg.getByPos(i, &tmp); + tmp.m_key = key; + fac->put(tmp); + } + } + + ConfigValues * ret = fac->m_cfg; + delete fac; + return ret; +} + +ConfigValues * +ConfigValuesFactory::getConfigValues(){ + ConfigValues * ret = m_cfg; + m_cfg = create(10, 10); + return ret; +} + +static int +mod4(unsigned int i){ + int res = i + (4 - (i % 4)); + return res; +} + +Uint32 +ConfigValues::getPackedSize() const { + + Uint32 size = 0; + for(Uint32 i = 0; i < 2 * m_size; i += 2){ + Uint32 key = m_values[i]; + if(key != CFV_KEY_FREE){ + switch(::getTypeOf(key)){ + case IntType: + case SectionType: + size += 8; + break; + case Int64Type: + size += 12; + break; + case StringType: + size += 8; // key + len + size += mod4(strlen(getString(m_values[i+1])) + 1); + break; + case InvalidType: + default: + abort(); + } + } + } + + return size + sizeof(Magic) + 4; // checksum also +} + +Uint32 +ConfigValues::pack(void * _dst, Uint32 _len) const { + + char * dst = (char*)_dst; + memcpy(dst, Magic, sizeof(Magic)); dst += sizeof(Magic); + + for(Uint32 i = 0; i < 2 * m_size; i += 2){ + Uint32 key = m_values[i]; + Uint32 val = m_values[i+1]; + if(key != CFV_KEY_FREE){ + switch(::getTypeOf(key)){ + case IntType: + case SectionType: + * (Uint32*)dst = htonl(key); dst += 4; + * (Uint32*)dst = htonl(val); dst += 4; + break; + case Int64Type:{ + Uint64 i64 = get64(val); + Uint32 hi = (i64 >> 32); + Uint32 lo = (i64 & 0xFFFFFFFF); + * (Uint32*)dst = htonl(key); dst += 4; + * (Uint32*)dst = htonl(hi); dst += 4; + * (Uint32*)dst = htonl(lo); dst += 4; + } + break; + case StringType:{ + const char * str = getString(val); + Uint32 len = strlen(str) + 1; + * (Uint32*)dst = htonl(key); dst += 4; + * (Uint32*)dst = htonl(len); dst += 4; + memcpy(dst, str, len); + memset(dst+len, 0, mod4(len) - len); + dst += mod4(len); + } + break; + case InvalidType: + default: + abort(); + } + } + } + + const Uint32 * sum = (Uint32*)_dst; + const Uint32 len = ((Uint32*)dst) - sum; + Uint32 chk = 0; + for(Uint32 i = 0; i<len; i++){ + chk ^= htonl(sum[i]); + } + + * (Uint32*)dst = htonl(chk); dst += 4; + return 4 * (len + 1); +} + +bool +ConfigValuesFactory::unpack(const void * _src, Uint32 len){ + + if(len < sizeof(Magic) + 4){ + DEBUG abort(); + return false; + } + + if(memcmp(_src, Magic, sizeof(Magic)) != 0){ + DEBUG abort(); + return false; + } + + const char * src = (const char *)_src; + + { + Uint32 len32 = (len >> 2); + const Uint32 * tmp = (const Uint32*)_src; + Uint32 chk = 0; + for(Uint32 i = 0; (i+1)<len32; i++){ + chk ^= ntohl(tmp[i]); + } + + if(chk != ntohl(tmp[len32-1])){ + DEBUG abort(); + return false; + } + } + + const char * end = src + len - 4; + src += sizeof(Magic); + + ConfigValues::Entry entry; + while(end - src > 4){ + Uint32 tmp = ntohl(* (const Uint32 *)src); src += 4; + entry.m_key = tmp & KP_MASK; + entry.m_type = ::getTypeOf(tmp); + switch(entry.m_type){ + case ConfigValues::IntType: + case ConfigValues::SectionType: + entry.m_int = ntohl(* (const Uint32 *)src); src += 4; + break; + case ConfigValues::Int64Type:{ + Uint64 hi = ntohl(* (const Uint32 *)src); src += 4; + Uint64 lo = ntohl(* (const Uint32 *)src); src += 4; + entry.m_int64 = (hi <<32) | lo; + } + break; + case ConfigValues::StringType:{ + Uint32 s_len = ntohl(* (const Uint32 *)src); src += 4; + size_t s_len2 = strlen((const char*)src); + if(s_len2 + 1 != s_len){ + DEBUG abort(); + return false; + } + + entry.m_string = (const char*)src; src+= mod4(s_len); + } + break; + case ConfigValues::InvalidType: + default: + DEBUG abort(); + return false; + } + if(!put(entry)){ + DEBUG abort(); + return false; + } + } + if(src != end){ + DEBUG abort(); + return false; + } + return true; +} + +#ifdef __TEST_CV_HASH_HPP + +int +main(void){ + srand(time(0)); + for(int t = 0; t<100; t++){ + const size_t len = directory(rand() % 1000); + + printf("size = %d\n", len); + unsigned * buf = new unsigned[len]; + for(size_t key = 0; key<len; key++){ + Uint32 p = hash(key, len); + for(size_t j = 0; j<len; j++){ + buf[j] = p; + p = nextHash(key, len, p, j+1); + } + + for(size_t j = 0; j<len; j++){ + Uint32 pos = buf[j]; + int unique = 0; + for(size_t k = j + 1; k<len; k++){ + if(pos == buf[k]){ + if(unique > 0) + printf("size=%d key=%d pos(%d)=%d buf[%d]=%d\n", len, key, j, pos, k, buf[k]); + unique ++; + } + } + if(unique > 1){ + printf("key = %d size = %d not uniqe!!\n", key, len); + for(size_t k = 0; k<len; k++){ + printf("%d ", buf[k]); + } + printf("\n"); + } + } + } + delete[] buf; + } + return 0; +} + +#endif diff --git a/ndb/src/common/util/Makefile.am b/ndb/src/common/util/Makefile.am new file mode 100644 index 00000000000..59d9775b8e3 --- /dev/null +++ b/ndb/src/common/util/Makefile.am @@ -0,0 +1,17 @@ + +noinst_LTLIBRARIES = libgeneral.la + +libgeneral_la_SOURCES = \ + File.cpp md5_hash.cpp Properties.cpp socket_io.cpp \ + SimpleProperties.cpp Parser.cpp InputStream.cpp SocketServer.cpp \ + OutputStream.cpp NdbOut.cpp BaseString.cpp Base64.cpp \ + NdbSqlUtil.cpp new.cpp \ + uucode.c random.c getarg.c version.c \ + strdup.c strlcat.c strlcpy.c \ + ConfigValues.cpp + +include $(top_srcdir)/ndb/config/common.mk.am +include $(top_srcdir)/ndb/config/type_util.mk.am + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/ndb/src/common/util/Makefile b/ndb/src/common/util/Makefile_old index e8ca2b87c20..65093396246 100644 --- a/ndb/src/common/util/Makefile +++ b/ndb/src/common/util/Makefile_old @@ -8,7 +8,7 @@ ARCHIVE_TARGET := general SOURCES = File.cpp md5_hash.cpp Properties.cpp socket_io.cpp \ SimpleProperties.cpp Parser.cpp InputStream.cpp SocketServer.cpp \ OutputStream.cpp NdbOut.cpp BaseString.cpp Base64.cpp \ - NdbSqlUtil.cpp new.cpp + NdbSqlUtil.cpp ConfigValues.cpp new.cpp SOURCES.c = uucode.c random.c getarg.c version.c @@ -20,7 +20,7 @@ ifeq ($(NDB_OS), OSE) endif SOURCES.c += strdup.c strlcat.c strlcpy.c -DIRS := testSimpleProperties +DIRS := testSimpleProperties testProperties testConfigValues include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index e91ade374cf..e34d6d18539 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -155,6 +155,14 @@ NdbSqlUtil::m_typeList[] = { { Type::Timespec, NULL // cmpTimespec + }, + { + Type::Blob, + NULL // cmpDatetime + }, + { + Type::Clob, + cmpClob } }; @@ -284,6 +292,18 @@ NdbSqlUtil::cmpTimespec(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 return cmp(Type::Timespec, p1, p2, full, size); } +int +NdbSqlUtil::cmpBlob(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + return cmp(Type::Blob, p1, p2, full, size); +} + +int +NdbSqlUtil::cmpClob(const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + return cmp(Type::Clob, p1, p2, full, size); +} + #ifdef NDB_SQL_UTIL_TEST #include <NdbTick.h> diff --git a/ndb/src/common/util/Properties.cpp b/ndb/src/common/util/Properties.cpp index 2ab008142ba..3e41056ac18 100644 --- a/ndb/src/common/util/Properties.cpp +++ b/ndb/src/common/util/Properties.cpp @@ -21,6 +21,12 @@ #include <NdbTCP.h> #include <NdbOut.hpp> +static +char * f_strdup(const char * s){ + if(!s) return 0; + return strdup(s); +} + /** * Note has to be a multiple of 4 bytes */ @@ -36,6 +42,7 @@ struct PropertyImpl{ ~PropertyImpl(); PropertyImpl(const char * name, Uint32 value); + PropertyImpl(const char * name, Uint64 value); PropertyImpl(const char * name, const char * value); PropertyImpl(const char * name, const Properties * value); @@ -167,6 +174,11 @@ Properties::put(const char * name, Uint32 value, bool replace){ return ::put(impl, name, value, replace); } +bool +Properties::put64(const char * name, Uint64 value, bool replace){ + return ::put(impl, name, value, replace); +} + bool Properties::put(const char * name, const char * value, bool replace){ return ::put(impl, name, value, replace); @@ -208,6 +220,40 @@ Properties::get(const char * name, Uint32 * value) const { setErrno(E_PROPERTIES_OK); return true; } + + if(nvp->valueType == PropertiesType_Uint64){ + Uint64 tmp = * (Uint64 *)nvp->value; + Uint64 max = 1; max <<= 32; + if(tmp < max){ + * value = (Uint32)tmp; + setErrno(E_PROPERTIES_OK); + return true; + } + } + setErrno(E_PROPERTIES_INVALID_TYPE); + return false; +} + +bool +Properties::get(const char * name, Uint64 * value) const { + PropertyImpl * nvp = impl->get(name); + if(nvp == 0){ + setErrno(E_PROPERTIES_NO_SUCH_ELEMENT); + return false; + } + + if(nvp->valueType == PropertiesType_Uint32){ + Uint32 tmp = * (Uint32 *)nvp->value; + * value = (Uint64)tmp; + setErrno(E_PROPERTIES_OK); + return true; + } + + if(nvp->valueType == PropertiesType_Uint64){ + * value = * (Uint64 *)nvp->value; + setErrno(E_PROPERTIES_OK); + return true; + } setErrno(E_PROPERTIES_INVALID_TYPE); return false; } @@ -263,7 +309,7 @@ Properties::getCopy(const char * name, char ** value) const { } if(nvp->valueType == PropertiesType_char){ - * value = strdup((const char *)nvp->value); + * value = f_strdup((const char *)nvp->value); setErrno(E_PROPERTIES_OK); return true; } @@ -313,6 +359,10 @@ Properties::print(FILE * out, const char * prefix) const{ fprintf(out, "%s%s = (Uint32) %d\n", buf, impl->content[i]->name, *(Uint32 *)impl->content[i]->value); break; + case PropertiesType_Uint64: + fprintf(out, "%s%s = (Uint64) %lld\n", buf, impl->content[i]->name, + *(Uint64 *)impl->content[i]->value); + break; case PropertiesType_char: fprintf(out, "%s%s = (char*) \"%s\"\n", buf, impl->content[i]->name, (char *)impl->content[i]->value); @@ -598,11 +648,18 @@ PropertiesImpl::getPackedSize(Uint32 pLen) const { sz += 4; // Name Len sz += 4; // Value Len sz += mod4(pLen + strlen(content[i]->name)); // Name - if(content[i]->valueType == PropertiesType_char){ + switch(content[i]->valueType){ + case PropertiesType_char: sz += mod4(strlen((char *)content[i]->value)); - } else if(content[i]->valueType == PropertiesType_Uint32){ + break; + case PropertiesType_Uint32: sz += mod4(4); - } else { + break; + case PropertiesType_Uint64: + sz += mod4(8); + break; + case PropertiesType_Properties: + default: assert(0); } } @@ -700,6 +757,9 @@ PropertiesImpl::pack(Uint32 *& buf, const char * prefix, Uint32 pLen) const { case PropertiesType_Uint32: valLenData = 4; break; + case PropertiesType_Uint64: + valLenData = 8; + break; case PropertiesType_char: valLenData = strlen((char *)content[i]->value); break; @@ -722,6 +782,14 @@ PropertiesImpl::pack(Uint32 *& buf, const char * prefix, Uint32 pLen) const { case PropertiesType_Uint32: * (Uint32 *)valBuf = htonl(* (Uint32 *)content[i]->value); break; + case PropertiesType_Uint64:{ + Uint64 val = * (Uint64 *)content[i]->value; + Uint32 hi = (val >> 32); + Uint32 lo = (val & 0xFFFFFFFF); + * (Uint32 *)valBuf = htonl(hi); + * (Uint32 *)(valBuf + 4) = htonl(lo); + } + break; case PropertiesType_char: memcpy(valBuf, content[i]->value, strlen((char*)content[i]->value)); break; @@ -788,6 +856,12 @@ PropertiesImpl::unpack(const Uint32 * buf, Uint32 &bufLen, Properties * top, case PropertiesType_Uint32: res3 = top->put(nameBuf, ntohl(* (Uint32 *)valBuf), true); break; + case PropertiesType_Uint64:{ + Uint64 hi = ntohl(* (Uint32 *)valBuf); + Uint64 lo = ntohl(* (Uint32 *)(valBuf + 4)); + res3 = top->put64(nameBuf, (hi << 32) + lo, true); + } + break; case PropertiesType_char: res3 = top->put(nameBuf, valBuf, true); break; @@ -808,6 +882,9 @@ PropertyImpl::~PropertyImpl(){ case PropertiesType_Uint32: delete (Uint32 *)value; break; + case PropertiesType_Uint64: + delete (Uint64 *)value; + break; case PropertiesType_char: free((char *)value); break; @@ -822,6 +899,8 @@ PropertyImpl::copyPropertyImpl(const PropertyImpl & org){ switch(org.valueType){ case PropertiesType_Uint32: return new PropertyImpl(org.name, * (Uint32 *)org.value); + case PropertiesType_Uint64: + return new PropertyImpl(org.name, * (Uint64 *)org.value); break; case PropertiesType_char: return new PropertyImpl(org.name, (char *)org.value); @@ -836,21 +915,28 @@ PropertyImpl::copyPropertyImpl(const PropertyImpl & org){ } PropertyImpl::PropertyImpl(const char * _name, Uint32 _value){ - this->name = strdup(_name); + this->name = f_strdup(_name); this->value = new Uint32; * ((Uint32 *)this->value) = _value; this->valueType = PropertiesType_Uint32; } +PropertyImpl::PropertyImpl(const char * _name, Uint64 _value){ + this->name = f_strdup(_name); + this->value = new Uint64; + * ((Uint64 *)this->value) = _value; + this->valueType = PropertiesType_Uint64; +} + PropertyImpl::PropertyImpl(const char * _name, const char * _value){ - this->name = strdup(_name); - this->value = strdup(_value); + this->name = f_strdup(_name); + this->value = f_strdup(_value); this->valueType = PropertiesType_char; } PropertyImpl::PropertyImpl(const char * _name, const Properties * _value){ - this->name = strdup(_name); + this->name = f_strdup(_name); this->value = new Properties(* _value); this->valueType = PropertiesType_Properties; } @@ -902,6 +988,16 @@ Properties::put(const char * name, Uint32 no, Uint32 val, bool replace){ return res; } +bool +Properties::put64(const char * name, Uint32 no, Uint64 val, bool replace){ + size_t tmp_len = strlen(name)+20; + char * tmp = (char*)malloc(tmp_len); + snprintf(tmp, tmp_len, "%s_%d", name, no); + bool res = put(tmp, val, replace); + free(tmp); + return res; +} + bool Properties::put(const char * name, Uint32 no, const char * val, bool replace){ @@ -957,6 +1053,16 @@ Properties::get(const char * name, Uint32 no, Uint32 * value) const{ return res; } +bool +Properties::get(const char * name, Uint32 no, Uint64 * value) const{ + size_t tmp_len = strlen(name)+20; + char * tmp = (char*)malloc(tmp_len); + snprintf(tmp, tmp_len, "%s_%d", name, no); + bool res = get(tmp, value); + free(tmp); + return res; +} + bool Properties::get(const char * name, Uint32 no, const char ** value) const { diff --git a/ndb/src/common/util/md5_hash.cpp b/ndb/src/common/util/md5_hash.cpp index 5e28edcf8fa..068843183ac 100644 --- a/ndb/src/common/util/md5_hash.cpp +++ b/ndb/src/common/util/md5_hash.cpp @@ -48,7 +48,7 @@ void byteReverse(unsigned char *buf, unsigned longs); */ void byteReverse(unsigned char *buf, unsigned longs) { - uint32 t; + Uint32 t; do { t = (Uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]); diff --git a/ndb/src/common/util/new.cpp b/ndb/src/common/util/new.cpp index 889e83edf6f..b61541b7474 100644 --- a/ndb/src/common/util/new.cpp +++ b/ndb/src/common/util/new.cpp @@ -5,6 +5,8 @@ extern "C" { void (* ndb_new_handler)() = 0; } +#ifdef USE_MYSYS_NEW + void *operator new (size_t sz) { void * p = malloc (sz ? sz : 1); @@ -36,3 +38,5 @@ void operator delete[] (void *ptr) throw () if (ptr) free(ptr); } + +#endif // USE_MYSYS_NEW diff --git a/ndb/src/common/util/socket_io.cpp b/ndb/src/common/util/socket_io.cpp index 8def7ebe91b..97bb4863a67 100644 --- a/ndb/src/common/util/socket_io.cpp +++ b/ndb/src/common/util/socket_io.cpp @@ -202,13 +202,13 @@ vprintln_socket(NDB_SOCKET_TYPE socket, int timeout_millis, size_t size = sizeof(buf); if (fmt != 0) { - size = vsnprintf(buf, sizeof(buf)-1, fmt, ap); + size = vsnprintf(buf, sizeof(buf), fmt, ap); /* Check if the output was truncated */ - if(size >= sizeof(buf)) { + if(size >= sizeof(buf)-1) { buf2 = (char *)malloc(size+2); if(buf2 == NULL) return -1; - vsnprintf(buf2, size, fmt, ap); + vsnprintf(buf2, size+1, fmt, ap); } else size = sizeof(buf); } else diff --git a/ndb/src/common/util/testConfigValues/Makefile b/ndb/src/common/util/testConfigValues/Makefile new file mode 100644 index 00000000000..5b7400f5ee3 --- /dev/null +++ b/ndb/src/common/util/testConfigValues/Makefile @@ -0,0 +1,12 @@ +include .defs.mk + +TYPE := util + +BIN_TARGET := testConfigValues +BIN_TARGET_ARCHIVES := portlib general + +SOURCES := testConfigValues.cpp + +CCFLAGS_LOC += -I$(call fixpath,$(NDB_TOP)/include/util) + +include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/common/util/testConfigValues/testConfigValues.cpp b/ndb/src/common/util/testConfigValues/testConfigValues.cpp new file mode 100644 index 00000000000..362deb1ddad --- /dev/null +++ b/ndb/src/common/util/testConfigValues/testConfigValues.cpp @@ -0,0 +1,122 @@ +#include <ConfigValues.hpp> +#include <NdbOut.hpp> +#include <stdlib.h> +#include <string.h> + +#define CF_NODES 1 +#define CF_LOG_PAGES 2 +#define CF_MEM_PAGES 3 +#define CF_START_TO 4 +#define CF_STOP_TO 5 + +void print(Uint32 i, ConfigValues::ConstIterator & cf){ + ndbout_c("---"); + for(Uint32 j = 2; j<=7; j++){ + switch(cf.getTypeOf(j)){ + case ConfigValues::IntType: + ndbout_c("Node %d : CFG(%d) : %d", + i, j, cf.get(j, 999)); + break; + case ConfigValues::Int64Type: + ndbout_c("Node %d : CFG(%d) : %lld (64)", + i, j, cf.get64(j, 999)); + break; + case ConfigValues::StringType: + ndbout_c("Node %d : CFG(%d) : %s", + i, j, cf.get(j, "<NOT FOUND>")); + break; + default: + ndbout_c("Node %d : CFG(%d) : TYPE: %d", + i, j, cf.getTypeOf(j)); + } + } +} + +void print(Uint32 i, ConfigValues & _cf){ + ConfigValues::ConstIterator cf(_cf); + print(i, cf); +} + +void +print(ConfigValues & _cf){ + ConfigValues::ConstIterator cf(_cf); + Uint32 i = 0; + while(cf.openSection(CF_NODES, i)){ + print(i, cf); + cf.closeSection(); + i++; + } +} + +inline +void +require(bool b){ + if(!b) + abort(); +} + +int +main(void){ + + { + ConfigValuesFactory cvf(10, 20); + cvf.openSection(1, 0); + cvf.put(2, 12); + cvf.put64(3, 13); + cvf.put(4, 14); + cvf.put64(5, 15); + cvf.put(6, "Keso"); + cvf.put(7, "Kent"); + cvf.closeSection(); + + cvf.openSection(1, 1); + cvf.put(2, 22); + cvf.put64(3, 23); + cvf.put(4, 24); + cvf.put64(5, 25); + cvf.put(6, "Kalle"); + cvf.put(7, "Anka"); + cvf.closeSection(); + + ndbout_c("-- print --"); + print(* cvf.m_cfg); + + cvf.shrink(); + ndbout_c("shrink\n-- print --"); + print(* cvf.m_cfg); + cvf.expand(10, 10); + ndbout_c("expand\n-- print --"); + print(* cvf.m_cfg); + + ndbout_c("packed size: %d", cvf.m_cfg->getPackedSize()); + + ConfigValues::ConstIterator iter(* cvf.m_cfg); + iter.openSection(CF_NODES, 0); + ConfigValues * cfg2 = ConfigValuesFactory::extractCurrentSection(iter); + print(99, * cfg2); + + cvf.shrink(); + ndbout_c("packed size: %d", cfg2->getPackedSize()); + + UtilBuffer buf; + Uint32 l1 = cvf.m_cfg->pack(buf); + Uint32 l2 = cvf.m_cfg->getPackedSize(); + require(l1 == l2); + + ConfigValuesFactory cvf2; + require(cvf2.unpack(buf)); + UtilBuffer buf2; + cvf2.shrink(); + Uint32 l3 = cvf2.m_cfg->pack(buf2); + require(l1 == l3); + + ndbout_c("unpack\n-- print --"); + print(* cvf2.m_cfg); + + cfg2->~ConfigValues();; + cvf.m_cfg->~ConfigValues(); + free(cfg2); + free(cvf.m_cfg); + } + return 0; +} diff --git a/ndb/src/common/util/testProperties/Makefile b/ndb/src/common/util/testProperties/Makefile index 00b4465b69d..343c07a49e7 100644 --- a/ndb/src/common/util/testProperties/Makefile +++ b/ndb/src/common/util/testProperties/Makefile @@ -1,12 +1,9 @@ include .defs.mk -TYPE := +TYPE := util BIN_TARGET := keso -BIN_TARGET_ARCHIVES := portlib general SOURCES := testProperties.cpp -CCFLAGS_LOC += -I$(call fixpath,$(NDB_TOP)/include/util) - include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/common/util/testProperties/testProperties.cpp b/ndb/src/common/util/testProperties/testProperties.cpp index 3aa2af92c5b..e445f7ca3e4 100644 --- a/ndb/src/common/util/testProperties/testProperties.cpp +++ b/ndb/src/common/util/testProperties/testProperties.cpp @@ -63,12 +63,6 @@ readFromFile(Properties & p, const char *fname, bool uu = true){ return res; } -Property defs[] = { - Property("Rolf", 123) - ,Property("Keso", "Kent") -}; - - void putALot(Properties & tmp){ int i = 123; tmp.put("LockPagesInMainMemory", i++); @@ -124,7 +118,6 @@ main(void){ p.put("Ank4", "anka"); putALot(p); - //p.put(defs, 2); Properties tmp; tmp.put("Type", "TCP"); tmp.put("OwnNodeId", 1); @@ -136,8 +129,8 @@ main(void){ tmp.put("Compression", (Uint32)false); tmp.put("Checksum", 1); - tmp.put("SendBufferSize", 2000); - tmp.put("MaxReceiveSize", 1000); + tmp.put64("SendBufferSize", 2000); + tmp.put64("MaxReceiveSize", 1000); tmp.put("PortNumber", 1233); putALot(tmp); |