MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NodeInfo.hpp
1 /*
2  Copyright (C) 2003-2007 MySQL AB, 2008 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef NODE_INFO_HPP
20 #define NODE_INFO_HPP
21 
22 #include <NdbOut.hpp>
23 #include <mgmapi_config_parameters.h>
24 #include <ndb_version.h>
25 
26 class NodeInfo {
27 public:
28  NodeInfo();
29 
33  enum NodeType {
34  DB = NODE_TYPE_DB,
35  API = NODE_TYPE_API,
36  MGM = NODE_TYPE_MGM,
37  INVALID = 255
38  };
39  NodeType getType() const;
40 
41  Uint32 m_version;
42  Uint32 m_mysql_version;
43  Uint32 m_lqh_workers;
44  Uint32 m_type;
45  Uint32 m_connectCount;
46  bool m_connected;
47  Uint32 m_heartbeat_cnt;
48 
49  friend NdbOut & operator<<(NdbOut&, const NodeInfo&);
50 };
51 
52 
53 inline
54 NodeInfo::NodeInfo(){
55  m_version = 0;
56  m_mysql_version = 0;
57  m_lqh_workers = 0;
58  m_type = INVALID;
59  m_connectCount = 0;
60  m_heartbeat_cnt= 0;
61 }
62 
63 inline
65 NodeInfo::getType() const {
66  return (NodeType)m_type;
67 }
68 
69 
70 class NdbVersion {
71  Uint32 m_ver;
72 public:
73  NdbVersion(Uint32 ver) : m_ver(ver) {};
74 
75  friend NdbOut& operator<<(NdbOut&, const NdbVersion&);
76 };
77 
78 
79 inline
80 NdbOut&
81 operator<<(NdbOut& ndbout, const NdbVersion& ver){
82  ndbout.print("%d.%d.%d",
83  ndbGetMajor(ver.m_ver),
84  ndbGetMinor(ver.m_ver),
85  ndbGetBuild(ver.m_ver));
86  return ndbout;
87 }
88 
89 
90 inline
91 NdbOut &
92 operator<<(NdbOut& ndbout, const NodeInfo & info){
93  ndbout << "[NodeInfo: ";
94  switch(info.m_type){
95  case NodeInfo::DB:
96  ndbout << "DB";
97  break;
98  case NodeInfo::API:
99  ndbout << "API";
100  break;
101  case NodeInfo::MGM:
102  ndbout << "MGM";
103  break;
104  case NodeInfo::INVALID:
105  ndbout << "INVALID";
106  break;
107  default:
108  ndbout << "<Unknown: " << info.m_type << ">";
109  break;
110  }
111 
112  ndbout << " ndb version: " << NdbVersion(info.m_version)
113  << " mysql version: " << NdbVersion(info.m_mysql_version)
114  << " connect count: " << info.m_connectCount
115  << "]";
116  return ndbout;
117 }
118 
120 {
121  STATIC_CONST( DataLength = 6 );
122  struct
123  {
124  Uint32 m_min_version;
125  Uint32 m_max_version;
126  } m_type [3]; // Indexed as NodeInfo::Type
127 };
128 
129 #endif