MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NdbRestarts.hpp
1 /*
2  Copyright (c) 2003, 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 #ifndef NDBT_RESTARTS_HPP
19 #define NDBT_RESTARTS_HPP
20 
21 #include <NdbRestarter.hpp>
22 #include <NdbTick.h>
23 #include <random.h>
24 
42 class NDBT_Context;
43 
44 class NdbRestarts {
45 public:
46  NdbRestarts(const char* _addr = 0):
47  m_restarter(_addr)
48  {
49  myRandom48Init((long)NdbTick_CurrentMillisecond());
50  }
51 
52  enum NdbRestartType{
53  NODE_RESTART,
54  MULTIPLE_NODE_RESTART,
55  SYSTEM_RESTART
56  };
57 
58  struct NdbRestart {
59  typedef int (restartFunc)(NDBT_Context*, NdbRestarter&, const NdbRestart*);
60 
61  NdbRestart(const char* _name,
62  NdbRestartType _type,
63  restartFunc* _func,
64  int _requiredNodes,
65  int _arg1 = -1);
66 
67  const char * m_name;
68  NdbRestartType m_type;
69  restartFunc* m_restartFunc;
70  int m_numRequiredNodes;
71  int m_arg1;
72 
73  };
74 
75  int getNumRestarts();
76 
77  int executeRestart(NDBT_Context*, int _num, unsigned int _to = 120);
78  int executeRestart(NDBT_Context*, const char* _name, unsigned int _to = 120);
79 
80  void listRestarts();
81  void listRestarts(NdbRestartType _type);
82 private:
83  int executeRestart(NDBT_Context*, const NdbRestart*, unsigned int _timeout);
84 
85  struct NdbErrorInsert {
86  NdbErrorInsert(const char* _name,
87  int _errorNo);
88 
89  const char * m_name;
90  int m_errorNo;
91 
92  public:
93  const char* getName();
94  };
95 
96  int getNumErrorInserts();
97  const NdbErrorInsert* getError(int _num);
98  const NdbErrorInsert* getRandomError();
99 
100  static const NdbErrorInsert m_errors[];
101  static const int m_NoOfErrors;
102 
103  const NdbRestart* getRestart(int _num);
104  const NdbRestart* getRestart(const char* _name);
105 
106  static const NdbRestart m_restarts[];
107  static const int m_NoOfRestarts;
108 
109  NdbRestarter m_restarter;
110 };
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 #endif