clusterconfiguration.cpp
来自「MySQL数据库开发源码 值得一看哦」· C++ 代码 · 共 485 行 · 第 1/2 页
CPP
485 行
/* 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 "ClusterConfiguration.hpp"#include <ErrorHandlingMacros.hpp>#include <pc.hpp>#include <BlockNumbers.h>#include <signaldata/AccSizeAltReq.hpp>#include <signaldata/DictSizeAltReq.hpp>#include <signaldata/DihSizeAltReq.hpp>#include <signaldata/LqhSizeAltReq.hpp>#include <signaldata/TcSizeAltReq.hpp>#include <signaldata/TupSizeAltReq.hpp>#include <signaldata/TuxSizeAltReq.hpp>ClusterConfiguration::ClusterConfiguration(){ for (unsigned i= 0; i< MAX_SIZEALT_BLOCKS; i++) // initialize for (unsigned j= 0; j< MAX_SIZEALT_RECORD; j++) { the_clusterData.SizeAltData.varSize[i][j].valid = false; the_clusterData.SizeAltData.varSize[i][j].nrr = 0; } for (unsigned i1 = 0; i1< 5; i1++) // initialize for (unsigned j1= 0; j1< CmvmiCfgConf::NO_OF_WORDS; j1++) the_clusterData.ispValues[i1][j1] = 0; the_clusterData.SizeAltData.noOfNodes = 0; the_clusterData.SizeAltData.noOfNDBNodes = 0; the_clusterData.SizeAltData.noOfAPINodes = 0; the_clusterData.SizeAltData.noOfMGMNodes = 0;}ClusterConfiguration::~ClusterConfiguration(){}voidsetValue(VarSize* dst, const int index, UintR variableValue){ assert(dst != NULL); assert(index >= 0 && index < MAX_SIZEALT_RECORD); dst[index].nrr = variableValue; dst[index].valid = true;}voidClusterConfiguration::calcSizeAlteration(){ SizeAlt *size = &the_clusterData.SizeAltData; size->noOfTables++; // Remove impact of system table size->noOfTables += size->noOfIndexes; // Indexes are tables too size->noOfAttributes += 2; // ---"---- size->noOfTables *= 2; // Remove impact of Dict need 2 ids for each table Uint32 noOfDBNodes = size->noOfNDBNodes; if (noOfDBNodes > 15) { noOfDBNodes = 15; }//if Uint32 noOfLocalScanRecords = (noOfDBNodes * size->noOfScanRecords) + 1; Uint32 noOfTCScanRecords = size->noOfScanRecords; { /** * Acc Size Alt values */ size->blockNo[ACC] = DBACC; VarSize * const acc = &(size->varSize[ACC][0]); // Can keep 65536 pages (= 0.5 GByte) setValue(acc, AccSizeAltReq::IND_DIR_RANGE, 4 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas); setValue(acc, AccSizeAltReq::IND_DIR_ARRAY, (size->noOfIndexPages >> 8) + 4 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas); setValue(acc, AccSizeAltReq::IND_FRAGMENT, 2 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas); /*-----------------------------------------------------------------------*/ // The extra operation records added are used by the scan and node // recovery process. // Node recovery process will have its operations dedicated to ensure // that they never have a problem with allocation of the operation record. // The remainder are allowed for use by the scan processes. /*-----------------------------------------------------------------------*/ setValue(acc, AccSizeAltReq::IND_OP_RECS, size->noOfReplicas*((16 * size->noOfOperations) / 10 + 50) + (noOfLocalScanRecords * MAX_PARALLEL_SCANS_PER_FRAG) + NODE_RECOVERY_SCAN_OP_RECORDS); setValue(acc, AccSizeAltReq::IND_OVERFLOW_RECS, size->noOfIndexPages + 2 * NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas); setValue(acc, AccSizeAltReq::IND_PAGE8, size->noOfIndexPages + 32); setValue(acc, AccSizeAltReq::IND_ROOT_FRAG, NO_OF_FRAG_PER_NODE * size->noOfTables* size->noOfReplicas); setValue(acc, AccSizeAltReq::IND_TABLE, size->noOfTables); setValue(acc, AccSizeAltReq::IND_SCAN, noOfLocalScanRecords); } { /** * Dict Size Alt values */ size->blockNo[DICT] = DBDICT; VarSize * const dict = &(size->varSize[DICT][0]); setValue(dict, DictSizeAltReq::IND_ATTRIBUTE, size->noOfAttributes); setValue(dict, DictSizeAltReq::IND_CONNECT, size->noOfOperations + 32); setValue(dict, DictSizeAltReq::IND_FRAG_CONNECT, NO_OF_FRAG_PER_NODE * size->noOfNDBNodes * size->noOfReplicas); setValue(dict, DictSizeAltReq::IND_TABLE, size->noOfTables); setValue(dict, DictSizeAltReq::IND_TC_CONNECT, 2* size->noOfOperations); } { /** * Dih Size Alt values */ size->blockNo[DIH] = DBDIH; VarSize * const dih = &(size->varSize[DIH][0]); setValue(dih, DihSizeAltReq::IND_API_CONNECT, 2 * size->noOfTransactions); setValue(dih, DihSizeAltReq::IND_CONNECT, size->noOfOperations + 46); setValue(dih, DihSizeAltReq::IND_FRAG_CONNECT, NO_OF_FRAG_PER_NODE * size->noOfTables * size->noOfNDBNodes); int temp; temp = size->noOfReplicas - 2; if (temp < 0) temp = 1; else temp++; setValue(dih, DihSizeAltReq::IND_MORE_NODES, temp * NO_OF_FRAG_PER_NODE * size->noOfTables * size->noOfNDBNodes); setValue(dih, DihSizeAltReq::IND_REPLICAS, NO_OF_FRAG_PER_NODE * size->noOfTables * size->noOfNDBNodes * size->noOfReplicas); setValue(dih, DihSizeAltReq::IND_TABLE, size->noOfTables); } { /** * Lqh Size Alt values */ size->blockNo[LQH] = DBLQH; VarSize * const lqh = &(size->varSize[LQH][0]); setValue(lqh, LqhSizeAltReq::IND_FRAG, NO_OF_FRAG_PER_NODE * size->noOfTables * size->noOfReplicas); setValue(lqh, LqhSizeAltReq::IND_CONNECT, size->noOfReplicas*((11 * size->noOfOperations) / 10 + 50)); setValue(lqh, LqhSizeAltReq::IND_TABLE, size->noOfTables); setValue(lqh, LqhSizeAltReq::IND_TC_CONNECT, size->noOfReplicas*((16 * size->noOfOperations) / 10 + 50)); setValue(lqh, LqhSizeAltReq::IND_REPLICAS, size->noOfReplicas); setValue(lqh, LqhSizeAltReq::IND_LOG_FILES, (4 * the_clusterData.ispValues[1][4])); setValue(lqh, LqhSizeAltReq::IND_SCAN, noOfLocalScanRecords); } { /** * Tc Size Alt values */ size->blockNo[TC] = DBTC; VarSize * const tc = &(size->varSize[TC][0]); setValue(tc, TcSizeAltReq::IND_API_CONNECT, 3 * size->noOfTransactions); setValue(tc, TcSizeAltReq::IND_TC_CONNECT, size->noOfOperations + 16 + size->noOfTransactions); setValue(tc, TcSizeAltReq::IND_TABLE, size->noOfTables); setValue(tc, TcSizeAltReq::IND_LOCAL_SCAN, noOfLocalScanRecords); setValue(tc, TcSizeAltReq::IND_TC_SCAN, noOfTCScanRecords); } { /** * Tup Size Alt values
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?