1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/* 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; version 2 of the License.
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 */
#ifndef NDBT_RESTARTS_HPP
#define NDBT_RESTARTS_HPP
#include <NdbRestarter.hpp>
#include <NdbTick.h>
#include <random.h>
/**
* This class is used to test Ndb's ability to handle
* node- and system-restarts.
* For example:
* Node restart: Restart one node in the cluster.
* System restart: Restart all nodes in the cluster.
* Node crash: Crash one node in the middle of execution and bring it up again.
* Multiple node crash: Crash multiple nodes with a few seconds or milliseconds delay between.
* Initial node restart: Restart one node in the cluster without a filesystem on disk.
*
* Each restart type is represented by a NdbRestart class and a collection of these are stored
* in the NdbRestarts class.
*
* This class may be used from other programs to execute a particular restart.
*
*/
class NdbRestarts {
public:
NdbRestarts(const char* _addr = 0):
m_restarter(_addr)
{
myRandom48Init(NdbTick_CurrentMillisecond());
}
enum NdbRestartType{
NODE_RESTART,
MULTIPLE_NODE_RESTART,
SYSTEM_RESTART
};
struct NdbRestart {
typedef int (restartFunc)(NdbRestarter&, const NdbRestart*);
NdbRestart(const char* _name,
NdbRestartType _type,
restartFunc* _func,
int _requiredNodes,
int _arg1 = -1);
const char * m_name;
NdbRestartType m_type;
restartFunc* m_restartFunc;
int m_numRequiredNodes;
int m_arg1;
};
int getNumRestarts();
int executeRestart(int _num, unsigned int _timeout = 120);
int executeRestart(const char* _name, unsigned int _timeout = 120);
void listRestarts();
void listRestarts(NdbRestartType _type);
private:
int executeRestart(const NdbRestart*, unsigned int _timeout);
struct NdbErrorInsert {
NdbErrorInsert(const char* _name,
int _errorNo);
const char * m_name;
int m_errorNo;
public:
const char* getName();
};
int getNumErrorInserts();
const NdbErrorInsert* getError(int _num);
const NdbErrorInsert* getRandomError();
static const NdbErrorInsert m_errors[];
static const int m_NoOfErrors;
const NdbRestart* getRestart(int _num);
const NdbRestart* getRestart(const char* _name);
static const NdbRestart m_restarts[];
static const int m_NoOfRestarts;
NdbRestarter m_restarter;
};
#endif
|