23 #include <OutputStream.hpp>
28 #include <NdbRestarts.hpp>
31 int main(
int argc,
const char** argv){
34 const char* _restartName = NULL;
45 {
"seconds",
's', arg_integer, &_wait,
46 "Seconds to wait between each restart(0=random)",
"secs" },
47 {
"max seconds",
'm', arg_integer, &_maxwait,
48 "Max seconds to wait between each restart. Default is 120 seconds",
"msecs" },
49 {
"loops",
'l', arg_integer, &_loops,
"Number of loops(0=forever)",
"loops"},
50 {
"timeout",
't', arg_integer, &_timeout,
"Timeout waiting for nodes to start",
"seconds"},
51 {
"random",
'r', arg_flag, &_random,
"Select restart case randomly",
53 {
"all",
'a', arg_flag, &_all,
"Run all restarts",
55 {
"list-restarts",
'\0', arg_flag, &_list,
"List available restarts",
""},
56 {
"usage",
'?', arg_flag, &_help,
"Print help",
"" }
59 int num_args =
sizeof(args) /
sizeof(args[0]);
63 "This program will perform node restart, \n"\
64 "multiple node restart or system-restart.\n"\
65 "Use --list-restarts to see whats available\n";
67 if(getarg(args, num_args, argc, argv, &optind) || _help) {
68 arg_printusage(args, num_args, argv[0], desc);
69 return NDBT_ProgramExit(NDBT_WRONGARGS);
74 restarts.listRestarts();
75 return NDBT_ProgramExit(NDBT_OK);
78 if ((argv[optind] == NULL) && (_random == 0)){
79 arg_printusage(args, num_args, argv[0], desc);
80 return NDBT_ProgramExit(NDBT_WRONGARGS);
82 _restartName = argv[optind];
88 while (_loops == 0 || l < _loops){
93 _loops = restarts.getNumRestarts();
94 res = restarts.executeRestart(l, _timeout);
96 int num = rand() % restarts.getNumRestarts();
97 res = restarts.executeRestart(num, _timeout);
99 res = restarts.executeRestart(_restartName, _timeout);
108 seconds = (rand() % _maxwait) + 1;
110 g_info <<
"Waiting for " << seconds <<
"(" << _maxwait
111 <<
") secs " << endl;
112 NdbSleep_SecSleep(seconds);
117 return NDBT_ProgramExit(res);