23 #include <OutputStream.hpp>
28 #include <NdbRestarter.hpp>
29 #include <NdbRestarts.hpp>
32 int main(
int argc,
const char** argv){
35 const char* _hostName = NULL;
39 int _error_insert = 0;
46 {
"seconds",
's', arg_integer, &_wait,
47 "Seconds to wait between each restart(0=random)",
"secs" },
48 {
"max seconds",
'm', arg_integer, &_maxwait,
49 "Max seconds to wait between each restart. Default is 120 seconds",
51 {
"loops",
'l', arg_integer, &_loops,
52 "Number of loops(0=forever)",
"loops"},
53 {
"initial",
'i', arg_flag, &_initial,
"Initial node restart"},
54 {
"error-insert",
'e', arg_flag, &_error_insert,
"Use error insert"},
55 {
"master",
'm', arg_flag, &_master,
56 "Restart the master"},
57 {
"multiple",
'x', arg_flag, &_multiple,
58 "Multiple random node restarts. OBS! Even and odd node Ids must be separated into each node group"},
59 {
"usage",
'?', arg_flag, &_help,
"Print help",
"" }
62 int num_args =
sizeof(args) /
sizeof(args[0]);
66 "This program will connect to the mgmsrv of a NDB cluster.\n"\
67 "It will then wait for all nodes to be started, then restart node(s)\n"\
68 "and wait for all to restart inbetween. It will do this \n"\
69 "loop number of times\n";
71 if(getarg(args, num_args, argc, argv, &optind) || _help) {
72 arg_printusage(args, num_args, argv[0], desc);
73 return NDBT_ProgramExit(NDBT_WRONGARGS);
75 _hostName = argv[optind];
81 const char* restartName =
"";
84 restartName =
"TwoMasterNodeFailure";
88 restartName =
"FiftyPercentFail";
92 restartName =
"RestartMasterNodeError";
95 restartName =
"RestartRandomNodeError";
97 restartName =
"RestartRandomNodeInitial";
99 restartName =
"RestartRandomNode";
102 ndbout <<
"Performing " << restartName << endl;
104 int result = NDBT_OK;
106 while (_loops == 0 || l<_loops){
108 g_info <<
"Waiting for cluster to start" << endl;
109 while (restarter.waitClusterStarted(1) != 0){
116 seconds = (rand() % _maxwait) + 1;
118 g_info <<
"Waiting for " << seconds <<
"(" << _maxwait
119 <<
") secs " << endl;
120 NdbSleep_SecSleep(seconds);
122 g_info << l <<
": Restarting node(s) " << endl;
124 if (restarts.executeRestart(restartName) != 0){
125 result = NDBT_FAILED;
131 return NDBT_ProgramExit(NDBT_OK);