1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
#include <ndb_global.h>
20
#include <OutputStream.hpp>
25
#include <NdbRestarter.hpp>
28
int main(int argc, const char** argv){
31
const char* _hostName = NULL;
37
struct getargs args[] = {
38
{ "initial", 'i', arg_flag, &_initial, "Do initial restart"},
39
{ "wait", '\0', arg_negative_flag, &_wait, "Wait until restarted(default=true)"},
40
{ "usage", '?', arg_flag, &_help, "Print help", "" }
43
int num_args = sizeof(args) / sizeof(args[0]);
47
"This program will connect to the mgmsrv of a NDB cluster\n"\
48
" and restart the cluster. \n";
50
if(getarg(args, num_args, argc, argv, &optind) || _help) {
51
arg_printusage(args, num_args, argv[0], desc);
52
return NDBT_ProgramExit(NDBT_WRONGARGS);
54
_hostName = argv[optind];
56
NdbRestarter restarter(_hostName);
57
setOutputLevel(1); // Show only g_err
60
ndbout << "Restarting cluster with initial restart" << endl;
61
if (restarter.restartAll(true, false, false) != 0)
64
ndbout << "Restarting cluster " << endl;
65
if (restarter.restartAll() != 0)
68
if (result == NDBT_FAILED){
69
g_err << "Failed to restart cluster" << endl;
70
return NDBT_ProgramExit(NDBT_FAILED);
74
ndbout << "Waiting for cluster to start" << endl;
75
if ( restarter.waitClusterStarted(120) != 0){
76
ndbout << "Failed waiting for restart of cluster" << endl;
80
ndbout << "Cluster restarted" << endl;
82
return NDBT_ProgramExit(result);