📄 configinfo.cpp
字号:
/* Copyright (C) 2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include <ndb_global.h>#include <ndb_opt_defaults.h>#include <NdbTCP.h>#include "ConfigInfo.hpp"#include <mgmapi_config_parameters.h>#include <ndb_limits.h>#include "InitConfigFileParser.hpp"#include <m_string.h>extern my_bool opt_ndb_shm;extern my_bool opt_core;#define MAX_LINE_LENGTH 255#define KEY_INTERNAL 0#define MAX_INT_RNIL 0xfffffeff#define _STR_VALUE(x) #x#define STR_VALUE(x) _STR_VALUE(x)/**************************************************************************** * Section names ****************************************************************************/#define DB_TOKEN_PRINT "ndbd(DB)"#define MGM_TOKEN_PRINT "ndb_mgmd(MGM)"#define API_TOKEN_PRINT "mysqld(API)"#define DB_TOKEN "DB"#define MGM_TOKEN "MGM"#define API_TOKEN "API"const ConfigInfo::AliasPairConfigInfo::m_sectionNameAliases[]={ {API_TOKEN, "MYSQLD"}, {DB_TOKEN, "NDBD"}, {MGM_TOKEN, "NDB_MGMD"}, {0, 0}};const char* ConfigInfo::m_sectionNames[]={ "SYSTEM", "COMPUTER", DB_TOKEN, MGM_TOKEN, API_TOKEN, "TCP", "SCI", "SHM", "OSE"};const int ConfigInfo::m_noOfSectionNames = sizeof(m_sectionNames)/sizeof(char*);/**************************************************************************** * Section Rules declarations ****************************************************************************/static bool transformComputer(InitConfigFileParser::Context & ctx, const char *);static bool transformSystem(InitConfigFileParser::Context & ctx, const char *);static bool transformNode(InitConfigFileParser::Context & ctx, const char *);static bool checkConnectionSupport(InitConfigFileParser::Context & ctx, const char *);static bool transformConnection(InitConfigFileParser::Context & ctx, const char *);static bool applyDefaultValues(InitConfigFileParser::Context & ctx, const char *);static bool checkMandatory(InitConfigFileParser::Context & ctx, const char *);static bool fixPortNumber(InitConfigFileParser::Context & ctx, const char *);static bool fixShmKey(InitConfigFileParser::Context & ctx, const char *);static bool checkDbConstraints(InitConfigFileParser::Context & ctx, const char *);static bool checkConnectionConstraints(InitConfigFileParser::Context &, const char *);static bool checkTCPConstraints(InitConfigFileParser::Context &, const char *);static bool fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data);static bool fixHostname(InitConfigFileParser::Context & ctx, const char * data);static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data);static bool fixDepricated(InitConfigFileParser::Context & ctx, const char *);static bool saveInConfigValues(InitConfigFileParser::Context & ctx, const char *);static bool fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data);static bool fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data);static bool fixShmUniqueId(InitConfigFileParser::Context & ctx, const char * data);static bool checkLocalhostHostnameMix(InitConfigFileParser::Context & ctx, const char * data);const ConfigInfo::SectionRule ConfigInfo::m_SectionRules[] = { { "SYSTEM", transformSystem, 0 }, { "COMPUTER", transformComputer, 0 }, { DB_TOKEN, transformNode, 0 }, { API_TOKEN, transformNode, 0 }, { MGM_TOKEN, transformNode, 0 }, { MGM_TOKEN, fixShmUniqueId, 0 }, { "TCP", checkConnectionSupport, 0 }, { "SHM", checkConnectionSupport, 0 }, { "SCI", checkConnectionSupport, 0 }, { "OSE", checkConnectionSupport, 0 }, { "TCP", transformConnection, 0 }, { "SHM", transformConnection, 0 }, { "SCI", transformConnection, 0 }, { "OSE", transformConnection, 0 }, { DB_TOKEN, fixNodeHostname, 0 }, { API_TOKEN, fixNodeHostname, 0 }, { MGM_TOKEN, fixNodeHostname, 0 }, { "TCP", fixNodeId, "NodeId1" }, { "TCP", fixNodeId, "NodeId2" }, { "SHM", fixNodeId, "NodeId1" }, { "SHM", fixNodeId, "NodeId2" }, { "SCI", fixNodeId, "NodeId1" }, { "SCI", fixNodeId, "NodeId2" }, { "OSE", fixNodeId, "NodeId1" }, { "OSE", fixNodeId, "NodeId2" }, { "TCP", fixHostname, "HostName1" }, { "TCP", fixHostname, "HostName2" }, { "SHM", fixHostname, "HostName1" }, { "SHM", fixHostname, "HostName2" }, { "SCI", fixHostname, "HostName1" }, { "SCI", fixHostname, "HostName2" }, { "SHM", fixHostname, "HostName1" }, { "SHM", fixHostname, "HostName2" }, { "OSE", fixHostname, "HostName1" }, { "OSE", fixHostname, "HostName2" }, { "TCP", fixPortNumber, 0 }, // has to come after fixHostName { "SHM", fixPortNumber, 0 }, // has to come after fixHostName { "SCI", fixPortNumber, 0 }, // has to come after fixHostName { "*", applyDefaultValues, "user" }, { "*", fixDepricated, 0 }, { "*", applyDefaultValues, "system" }, { "SHM", fixShmKey, 0 }, // has to come after apply default values { DB_TOKEN, checkLocalhostHostnameMix, 0 }, { API_TOKEN, checkLocalhostHostnameMix, 0 }, { MGM_TOKEN, checkLocalhostHostnameMix, 0 }, { DB_TOKEN, fixFileSystemPath, 0 }, { DB_TOKEN, fixBackupDataDir, 0 }, { DB_TOKEN, checkDbConstraints, 0 }, { "TCP", checkConnectionConstraints, 0 }, { "SHM", checkConnectionConstraints, 0 }, { "SCI", checkConnectionConstraints, 0 }, { "OSE", checkConnectionConstraints, 0 }, { "TCP", checkTCPConstraints, "HostName1" }, { "TCP", checkTCPConstraints, "HostName2" }, { "SCI", checkTCPConstraints, "HostName1" }, { "SCI", checkTCPConstraints, "HostName2" }, { "SHM", checkTCPConstraints, "HostName1" }, { "SHM", checkTCPConstraints, "HostName2" }, { "*", checkMandatory, 0 }, { DB_TOKEN, saveInConfigValues, 0 }, { API_TOKEN, saveInConfigValues, 0 }, { MGM_TOKEN, saveInConfigValues, 0 }, { "TCP", saveInConfigValues, 0 }, { "SHM", saveInConfigValues, 0 }, { "SCI", saveInConfigValues, 0 }, { "OSE", saveInConfigValues, 0 }};const int ConfigInfo::m_NoOfRules = sizeof(m_SectionRules)/sizeof(SectionRule);/**************************************************************************** * Config Rules declarations ****************************************************************************/static bool sanity_checks(Vector<ConfigInfo::ConfigRuleSection>§ions, struct InitConfigFileParser::Context &ctx, const char * rule_data);static bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>§ions, struct InitConfigFileParser::Context &ctx, const char * rule_data);static bool set_connection_priorities(Vector<ConfigInfo::ConfigRuleSection>§ions, struct InitConfigFileParser::Context &ctx, const char * rule_data);static bool check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>§ions, struct InitConfigFileParser::Context &ctx, const char * rule_data);const ConfigInfo::ConfigRule ConfigInfo::m_ConfigRules[] = { { sanity_checks, 0 }, { add_node_connections, 0 }, { set_connection_priorities, 0 }, { check_node_vs_replicas, 0 }, { 0, 0 }}; struct DepricationTransform { const char * m_section; const char * m_oldName; const char * m_newName; double m_add; double m_mul;};staticconst DepricationTransform f_deprication[] = { { DB_TOKEN, "Discless", "Diskless", 0, 1 }, { DB_TOKEN, "Id", "NodeId", 0, 1 }, { API_TOKEN, "Id", "NodeId", 0, 1 }, { MGM_TOKEN, "Id", "NodeId", 0, 1 }, { 0, 0, 0, 0, 0}};/** * The default constructors create objects with suitable values for the * configuration parameters. * * Some are however given the value MANDATORY which means that the value * must be specified in the configuration file. * * Min and max values are also given for some parameters. * - Attr1: Name in file (initial config file) * - Attr2: Name in prop (properties object) * - Attr3: Name of Section (in init config file) * - Attr4: Updateable * - Attr5: Type of parameter (INT or BOOL) * - Attr6: Default Value (number only) * - Attr7: Min value * - Attr8: Max value * * Parameter constraints are coded in file Config.cpp. * * ******************************************************************* * Parameters used under development should be marked "NOTIMPLEMENTED" * ******************************************************************* */const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { /**************************************************************************** * COMPUTER ***************************************************************************/ { KEY_INTERNAL, "COMPUTER", "COMPUTER", "Computer section", ConfigInfo::CI_INTERNAL, false, ConfigInfo::CI_SECTION, 0, 0, 0 }, { KEY_INTERNAL, "Id", "COMPUTER", "Name of computer", ConfigInfo::CI_USED, false, ConfigInfo::CI_STRING, MANDATORY, 0, 0 }, { KEY_INTERNAL, "HostName", "COMPUTER", "Hostname of computer (e.g. mysql.com)", ConfigInfo::CI_USED, false, ConfigInfo::CI_STRING, MANDATORY, 0, 0 }, { KEY_INTERNAL, "ByteOrder", "COMPUTER", 0, ConfigInfo::CI_DEPRICATED, false, ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, /**************************************************************************** * SYSTEM ***************************************************************************/ { CFG_SECTION_SYSTEM, "SYSTEM", "SYSTEM", "System section", ConfigInfo::CI_USED, false, ConfigInfo::CI_SECTION, (const char *)CFG_SECTION_SYSTEM, 0, 0 }, { CFG_SYS_NAME, "Name", "SYSTEM", "Name of system (NDB Cluster)", ConfigInfo::CI_USED, false, ConfigInfo::CI_STRING, MANDATORY, 0, 0 }, { CFG_SYS_PRIMARY_MGM_NODE, "PrimaryMGMNode", "SYSTEM", "Node id of Primary "MGM_TOKEN_PRINT" node", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, "0", "0", STR_VALUE(MAX_INT_RNIL) }, { CFG_SYS_CONFIG_GENERATION, "ConfigGenerationNumber", "SYSTEM", "Configuration generation number", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, "0", "0", STR_VALUE(MAX_INT_RNIL) }, /*************************************************************************** * DB ***************************************************************************/ { CFG_SECTION_NODE, DB_TOKEN, DB_TOKEN, "Node section", ConfigInfo::CI_USED, false, ConfigInfo::CI_SECTION, (const char *)NODE_TYPE_DB, 0, 0 }, { CFG_NODE_HOST, "HostName", DB_TOKEN, "Name of computer for this node", ConfigInfo::CI_INTERNAL, false, ConfigInfo::CI_STRING, "localhost", 0, 0 }, { CFG_NODE_SYSTEM, "System", DB_TOKEN, "Name of system for this node", ConfigInfo::CI_INTERNAL, false, ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, { KEY_INTERNAL, "Id", DB_TOKEN, "", ConfigInfo::CI_DEPRICATED, false, ConfigInfo::CI_INT, MANDATORY, "1", STR_VALUE(MAX_NODES) }, { CFG_NODE_ID, "NodeId", DB_TOKEN, "Number identifying the database node ("DB_TOKEN_PRINT")", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, MANDATORY, "1", STR_VALUE(MAX_NODES) }, { KEY_INTERNAL, "ServerPort", DB_TOKEN, "Port used to setup transporter", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, UNDEFINED, "1", STR_VALUE(MAX_INT_RNIL) }, { CFG_DB_NO_REPLICAS, "NoOfReplicas", DB_TOKEN, "Number of copies of all data in the database (1-4)", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, MANDATORY, "1", "4" }, { CFG_DB_NO_ATTRIBUTES, "MaxNoOfAttributes", DB_TOKEN, "Total number of attributes stored in database. I.e. sum over all tables", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, "1000", "32", STR_VALUE(MAX_INT_RNIL) }, { CFG_DB_NO_TABLES, "MaxNoOfTables", DB_TOKEN, "Total number of tables stored in the database", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, "128", "8", STR_VALUE(MAX_INT_RNIL) }, { CFG_DB_NO_ORDERED_INDEXES, "MaxNoOfOrderedIndexes", DB_TOKEN, "Total number of ordered indexes that can be defined in the system", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, "128", "0", STR_VALUE(MAX_INT_RNIL) }, { CFG_DB_NO_UNIQUE_HASH_INDEXES, "MaxNoOfUniqueHashIndexes", DB_TOKEN, "Total number of unique hash indexes that can be defined in the system", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, "64", "0", STR_VALUE(MAX_INT_RNIL) }, { CFG_DB_NO_INDEXES, "MaxNoOfIndexes", DB_TOKEN, "Total number of indexes that can be defined in the system", ConfigInfo::CI_DEPRICATED, false, ConfigInfo::CI_INT, "128", "0", STR_VALUE(MAX_INT_RNIL) }, { CFG_DB_NO_INDEX_OPS, "MaxNoOfConcurrentIndexOperations", DB_TOKEN, "Total number of index operations that can execute simultaneously on one "DB_TOKEN_PRINT" node", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, "8K", "0", STR_VALUE(MAX_INT_RNIL) }, { CFG_DB_NO_TRIGGERS, "MaxNoOfTriggers", DB_TOKEN, "Total number of triggers that can be defined in the system", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, "768", "0", STR_VALUE(MAX_INT_RNIL) }, { CFG_DB_NO_TRIGGER_OPS, "MaxNoOfFiredTriggers", DB_TOKEN, "Total number of triggers that can fire simultaneously in one "DB_TOKEN_PRINT" node", ConfigInfo::CI_USED, false, ConfigInfo::CI_INT, "4000", "0", STR_VALUE(MAX_INT_RNIL) }, { KEY_INTERNAL, "ExecuteOnComputer", DB_TOKEN, "String referencing an earlier defined COMPUTER", ConfigInfo::CI_USED, false, ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, { CFG_DB_NO_SAVE_MSGS, "MaxNoOfSavedMessages", DB_TOKEN, "Max number of error messages in error log and max number of trace files", ConfigInfo::CI_USED, true, ConfigInfo::CI_INT, "25", "0", STR_VALUE(MAX_INT_RNIL) }, { CFG_DB_MEMLOCK, "LockPagesInMainMemory", DB_TOKEN, "If set to yes, then NDB Cluster data will not be swapped out to disk", ConfigInfo::CI_USED, true, ConfigInfo::CI_BOOL,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -