1 /*
2    Copyright (c) 2003, 2021, Oracle and/or its affiliates.
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 #ifndef ClusterConfiguration_H
26 #define ClusterConfiguration_H
27 
28 #include <kernel_types.h>
29 #include <ndb_limits.h>
30 #include <Properties.hpp>
31 #include <ErrorReporter.hpp>
32 #include <signaldata/CmvmiCfgConf.hpp>
33 #include <signaldata/SetLogLevelOrd.hpp>
34 #include <NodeInfo.hpp>
35 
36 #define JAM_FILE_ID 284
37 
38 
39 // MaxNumber of sizealteration records in each block
40 // MaxNumber of blocks with sizealteration, (size of array)
41 #define MAX_SIZEALT_RECORD 16
42 #define MAX_SIZEALT_BLOCKS 8
43 
44 enum NdbBlockName { ACC = 0, DICT, DIH, LQH, TC, TUP, TUX, NDB_SIZEALT_OFF };
45 //  NDB_SIZEALT_OFF is used for block without sizealteration
46 //  IMPORTANT to assign NDB_SIZEALT_OFF as largest value
47 
48 struct VarSize {
49   int   nrr;
50   bool   valid;
51 };
52 
53 struct SizeAlt {
54   unsigned int   noOfTables;
55   unsigned int   noOfIndexes;
56   unsigned int   noOfReplicas;
57   unsigned int   noOfNDBNodes;
58   unsigned int   noOfAPINodes;
59   unsigned int   noOfMGMNodes;
60   unsigned int   noOfNodes;
61   unsigned int   noOfDiskLessNodes;
62   unsigned int   noOfAttributes;
63   unsigned int   noOfOperations;
64   unsigned int   noOfTransactions;
65   unsigned int   noOfIndexPages;
66   unsigned int   noOfDataPages;
67   unsigned int   noOfDiskBufferPages;
68   unsigned int   noOfFreeClusters;
69   unsigned int   noOfDiskClusters;
70   unsigned int   noOfScanRecords;
71   bool       exist;
72   VarSize    varSize[MAX_SIZEALT_BLOCKS][MAX_SIZEALT_RECORD];
73   unsigned short blockNo[MAX_SIZEALT_BLOCKS];
74   LogLevel logLevel;
75 };
76 
77 
78 class ClusterConfiguration
79 {
80 public:
81 
82   struct NodeData {
NodeDataClusterConfiguration::NodeData83     NodeData() {
84       nodeId = MAX_NODES+1;
85       nodeType = NodeInfo::INVALID;
86       arbitRank = ~0;
87     }
88     NodeId nodeId;
89     NodeInfo::NodeType nodeType;
90     unsigned arbitRank;
91   };
92 
93   struct ClusterData
94   {
95     SizeAlt  SizeAltData;
96     NodeData nodeData[MAX_NODES];
97     Uint32   ispValues[5][CmvmiCfgConf::NO_OF_WORDS];
98   };
99 
100   ClusterConfiguration();
101   ~ClusterConfiguration();
102   const ClusterData& clusterData() const;
103 
104   void init(const Properties & p, const Properties & db);
105 protected:
106 
107 private:
108 
109   ClusterData the_clusterData;
110 
111   void calcSizeAlteration();
112 
113 };
114 
115 
116 #undef JAM_FILE_ID
117 
118 #endif // ClusterConfiguration_H
119 
120