MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NdbinfoTables.cpp
1 /*
2  Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
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 as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "Ndbinfo.hpp"
19 
20 
21 #define DECLARE_NDBINFO_TABLE(var, num) \
22 static const struct { \
23  Ndbinfo::Table::Members m; \
24  Ndbinfo::Column col[num]; \
25 } ndbinfo_##var
26 
27 
28 DECLARE_NDBINFO_TABLE(TABLES,3) =
29 { { "tables", 3, 0, "metadata for tables available through ndbinfo" },
30  {
31  {"table_id", Ndbinfo::Number, ""},
32 
33  {"table_name",Ndbinfo::String, ""},
34  {"comment", Ndbinfo::String, ""}
35  }
36 };
37 
38 DECLARE_NDBINFO_TABLE(COLUMNS,5) =
39 { { "columns", 5, 0, "metadata for columns available through ndbinfo " },
40  {
41  {"table_id", Ndbinfo::Number, ""},
42  {"column_id", Ndbinfo::Number, ""},
43 
44  {"column_name", Ndbinfo::String, ""},
45  {"column_type", Ndbinfo::Number, ""},
46  {"comment", Ndbinfo::String, ""}
47  }
48 };
49 
50 DECLARE_NDBINFO_TABLE(TEST,5) =
51 { { "test", 5, 0, "for testing" },
52  {
53  {"node_id", Ndbinfo::Number, ""},
54  {"block_number", Ndbinfo::Number, ""},
55  {"block_instance", Ndbinfo::Number, ""},
56 
57  {"counter", Ndbinfo::Number, ""},
58  {"counter2", Ndbinfo::Number64, ""}
59  }
60 };
61 
62 DECLARE_NDBINFO_TABLE(POOLS,12) =
63 { { "pools", 12, 0, "pool usage" },
64  {
65  {"node_id", Ndbinfo::Number, ""},
66  {"block_number", Ndbinfo::Number, ""},
67  {"block_instance", Ndbinfo::Number, ""},
68  {"pool_name", Ndbinfo::String, ""},
69 
70  {"used", Ndbinfo::Number64, "currently in use"},
71  {"total", Ndbinfo::Number64, "total allocated"},
72  {"high", Ndbinfo::Number64, "in use high water mark"},
73  {"entry_size", Ndbinfo::Number64, "size in bytes of each object"},
74  {"config_param1", Ndbinfo::Number, "config param 1 affecting pool"},
75  {"config_param2", Ndbinfo::Number, "config param 2 affecting pool"},
76  {"config_param3", Ndbinfo::Number, "config param 3 affecting pool"},
77  {"config_param4", Ndbinfo::Number, "config param 4 affecting pool"}
78  }
79 };
80 
81 DECLARE_NDBINFO_TABLE(TRANSPORTERS, 3) =
82 { { "transporters", 3, 0, "transporter status" },
83  {
84  {"node_id", Ndbinfo::Number, ""},
85  {"remote_node_id", Ndbinfo::Number, ""},
86 
87  {"connection_status", Ndbinfo::Number, ""}
88  }
89 };
90 
91 DECLARE_NDBINFO_TABLE(LOGSPACES, 7) =
92 { { "logspaces", 7, 0, "logspace usage" },
93  {
94  {"node_id", Ndbinfo::Number, ""},
95  {"log_type", Ndbinfo::Number, "0 = REDO, 1 = DD-UNDO"},
96  {"log_id", Ndbinfo::Number, ""},
97  {"log_part", Ndbinfo::Number, ""},
98 
99  {"total", Ndbinfo::Number64, "total allocated"},
100  {"used", Ndbinfo::Number64, "currently in use"},
101  {"high", Ndbinfo::Number64, "in use high water mark"}
102  }
103 };
104 
105 DECLARE_NDBINFO_TABLE(LOGBUFFERS, 7) =
106 { { "logbuffers", 7, 0, "logbuffer usage" },
107  {
108  {"node_id", Ndbinfo::Number, ""},
109  {"log_type", Ndbinfo::Number, "0 = REDO, 1 = DD-UNDO"},
110  {"log_id", Ndbinfo::Number, ""},
111  {"log_part", Ndbinfo::Number, ""},
112 
113  {"total", Ndbinfo::Number64, "total allocated"},
114  {"used", Ndbinfo::Number64, "currently in use"},
115  {"high", Ndbinfo::Number64, "in use high water mark"}
116  }
117 };
118 
119 DECLARE_NDBINFO_TABLE(RESOURCES,6) =
120 { { "resources", 6, 0, "resources usage (a.k.a superpool)" },
121  {
122  {"node_id", Ndbinfo::Number, ""},
123  {"resource_id", Ndbinfo::Number, ""},
124 
125  {"reserved", Ndbinfo::Number, "reserved for this resource"},
126  {"used", Ndbinfo::Number, "currently in use"},
127  {"max", Ndbinfo::Number, "max available"},
128  {"high", Ndbinfo::Number, "in use high water mark"}
129  }
130 };
131 
132 DECLARE_NDBINFO_TABLE(COUNTERS,5) =
133 { { "counters", 5, 0, "monotonic counters" },
134  {
135  {"node_id", Ndbinfo::Number, ""},
136  {"block_number", Ndbinfo::Number, ""},
137  {"block_instance", Ndbinfo::Number, ""},
138  {"counter_id", Ndbinfo::Number, ""},
139 
140  {"val", Ndbinfo::Number64, "monotonically increasing since process start"}
141  }
142 };
143 
144 DECLARE_NDBINFO_TABLE(NODES,5) =
145 { { "nodes", 5, 0, "node status" },
146  {
147  {"node_id", Ndbinfo::Number, ""},
148 
149  {"uptime", Ndbinfo::Number64, "time in seconds that node has been running"},
150  {"status", Ndbinfo::Number, "starting/started/stopped etc."},
151  {"start_phase", Ndbinfo::Number, "start phase if node is starting"},
152  {"config_generation", Ndbinfo::Number, "configuration generation number"}
153  }
154 };
155 
156 DECLARE_NDBINFO_TABLE(DISKPAGEBUFFER, 9) =
157 { { "diskpagebuffer", 9, 0, "disk page buffer info" },
158  {
159  {"node_id", Ndbinfo::Number, ""},
160  {"block_instance", Ndbinfo::Number, ""},
161 
162  {"pages_written", Ndbinfo::Number64, "Pages written to disk"},
163  {"pages_written_lcp", Ndbinfo::Number64, "Pages written by local checkpoint"},
164  {"pages_read", Ndbinfo::Number64, "Pages read from disk"},
165  {"log_waits", Ndbinfo::Number64, "Page writes waiting for log to be written to disk"},
166  {"page_requests_direct_return", Ndbinfo::Number64, "Page in buffer and no requests waiting for it"},
167  {"page_requests_wait_queue", Ndbinfo::Number64, "Page in buffer, but some requests are already waiting for it"},
168  {"page_requests_wait_io", Ndbinfo::Number64, "Page not in buffer, waiting to be read from disk"},
169  }
170 };
171 
172 #define DBINFOTBL(x) { Ndbinfo::x##_TABLEID, (Ndbinfo::Table*)&ndbinfo_##x }
173 
174 static
175 struct ndbinfo_table_list_entry {
176  Ndbinfo::TableId id;
178 } ndbinfo_tables[] = {
179  // NOTE! the tables must be added to the list in the same order
180  // as they are in "enum TableId"
181  DBINFOTBL(TABLES),
182  DBINFOTBL(COLUMNS),
183  DBINFOTBL(TEST),
184  DBINFOTBL(POOLS),
185  DBINFOTBL(TRANSPORTERS),
186  DBINFOTBL(LOGSPACES),
187  DBINFOTBL(LOGBUFFERS),
188  DBINFOTBL(RESOURCES),
189  DBINFOTBL(COUNTERS),
190  DBINFOTBL(NODES),
191  DBINFOTBL(DISKPAGEBUFFER)
192 };
193 
194 static int no_ndbinfo_tables =
195  sizeof(ndbinfo_tables) / sizeof(ndbinfo_tables[0]);
196 
197 
198 int Ndbinfo::getNumTables(){
199  return no_ndbinfo_tables;
200 }
201 
202 const Ndbinfo::Table& Ndbinfo::getTable(int i)
203 {
204  assert(i >= 0 && i < no_ndbinfo_tables);
205  ndbinfo_table_list_entry& entry = ndbinfo_tables[i];
206  assert(entry.id == i);
207  return *entry.table;
208 }
209 
210 const Ndbinfo::Table& Ndbinfo::getTable(Uint32 i)
211 {
212  return getTable((int)i);
213 }