~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/test/include/NdbRestarter.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
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.
 
6
 
 
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.
 
11
 
 
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 */
 
15
 
 
16
#ifndef NDBT_RESTARTER_HPP
 
17
#define NDBT_RESTARTER_HPP
 
18
 
 
19
#include <mgmapi.h>
 
20
#include <Vector.hpp>
 
21
#include <BaseString.hpp>
 
22
 
 
23
class NdbRestarter {
 
24
public:
 
25
  NdbRestarter(const char* _addr = 0);
 
26
  ~NdbRestarter();
 
27
 
 
28
  int getDbNodeId(int _i);
 
29
 
 
30
  enum RestartFlags {
 
31
    NRRF_INITIAL = 0x1,
 
32
    NRRF_NOSTART = 0x2,
 
33
    NRRF_ABORT   = 0x4
 
34
  };
 
35
 
 
36
  int restartOneDbNode(int _nodeId, 
 
37
                       bool initial = false, 
 
38
                       bool nostart = false, 
 
39
                       bool abort = false);
 
40
 
 
41
  int restartOneDbNode2(int _nodeId, Uint32 flags){
 
42
    return restartOneDbNode(_nodeId,
 
43
                            flags & NRRF_INITIAL,
 
44
                            flags & NRRF_NOSTART,
 
45
                            flags & NRRF_ABORT);
 
46
  }
 
47
 
 
48
  int restartAll(bool initial = false, 
 
49
                 bool nostart = false, 
 
50
                 bool abort = false);
 
51
  
 
52
  int restartAll2(Uint32 flags){
 
53
    return restartAll(flags & NRRF_INITIAL,
 
54
                      flags & NRRF_NOSTART,
 
55
                      flags & NRRF_ABORT);
 
56
  }
 
57
  
 
58
  int startAll();
 
59
  int startNodes(const int * _nodes, int _num_nodes);
 
60
  int waitClusterStarted(unsigned int _timeout = 120);
 
61
  int waitClusterSingleUser(unsigned int _timeout = 120);
 
62
  int waitClusterStartPhase(int _startphase, unsigned int _timeout = 120);
 
63
  int waitClusterNoStart(unsigned int _timeout = 120);  
 
64
  int waitNodesStarted(const int * _nodes, int _num_nodes,
 
65
                       unsigned int _timeout = 120);
 
66
  int waitNodesStartPhase(const int * _nodes, int _num_nodes, 
 
67
                          int _startphase, unsigned int _timeout = 120);
 
68
  int waitNodesNoStart(const int * _nodes, int _num_nodes,
 
69
                       unsigned int _timeout = 120); 
 
70
 
 
71
 
 
72
  int getNumDbNodes();
 
73
  int insertErrorInNode(int _nodeId, int error);
 
74
  int insertErrorInAllNodes(int error);
 
75
 
 
76
  int enterSingleUserMode(int _nodeId);
 
77
  int exitSingleUserMode();
 
78
 
 
79
  int dumpStateOneNode(int _nodeId, const int * _args, int _num_args);
 
80
  int dumpStateAllNodes(const int * _args, int _num_args);
 
81
 
 
82
  int getMasterNodeId();
 
83
  int getNextMasterNodeId(int nodeId);
 
84
  int getNodeGroup(int nodeId);
 
85
  int getRandomNodeSameNodeGroup(int nodeId, int randomNumber);
 
86
  int getRandomNodeOtherNodeGroup(int nodeId, int randomNumber);
 
87
  int getRandomNotMasterNodeId(int randomNumber);
 
88
  
 
89
  NdbMgmHandle handle;  
 
90
  
 
91
protected:
 
92
 
 
93
  int waitClusterState(ndb_mgm_node_status _status,
 
94
                       unsigned int _timeout,
 
95
                       int _startphase = -1);  
 
96
 
 
97
  int waitNodesState(const int * _nodes, int _num_nodes,
 
98
                     ndb_mgm_node_status _status,
 
99
                     unsigned int _timeout,
 
100
                     int _startphase = -1);
 
101
 
 
102
  bool isConnected();
 
103
  int connect();
 
104
  void disconnect();
 
105
  int getStatus();
 
106
 
 
107
  Vector<ndb_mgm_node_state> mgmNodes;
 
108
  Vector<ndb_mgm_node_state> apiNodes;
 
109
  
 
110
  bool connected;
 
111
  BaseString addr;
 
112
  ndb_mgm_configuration * m_config;
 
113
protected:
 
114
  ndb_mgm_configuration * getConfig();
 
115
 
 
116
public:  
 
117
  Vector<ndb_mgm_node_state> ndbNodes;
 
118
};
 
119
 
 
120
#endif