MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NdbWaiter.hpp
1 /*
2  Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef NDB_WAITER_HPP
19 #define NDB_WAITER_HPP
20 
21 #include <ndb_global.h>
22 #include <NdbTick.h>
23 #include <NdbOut.hpp>
24 
25 enum WaitSignalType {
26  NO_WAIT = 0,
27  WAIT_NODE_FAILURE = 1, // Node failure during wait
28  WST_WAIT_TIMEOUT = 2, // Timeout during wait
29 
30  WAIT_TC_SEIZE = 3,
31  WAIT_TC_RELEASE = 4,
32  WAIT_NDB_TAMPER = 5,
33  WAIT_SCAN = 6,
34 
35  WAIT_TRANS = 7,
36 
37  // DICT stuff
38  WAIT_GET_TAB_INFO_REQ = 11,
39  WAIT_CREATE_TAB_REQ = 12,
40  WAIT_DROP_TAB_REQ = 13,
41  WAIT_ALTER_TAB_REQ = 14,
42  WAIT_CREATE_INDX_REQ = 15,
43  WAIT_DROP_INDX_REQ = 16,
44  WAIT_LIST_TABLES_CONF = 17,
45  WAIT_SCHEMA_TRANS = 18
46 };
47 
48 class NdbWaiter {
49 public:
50  NdbWaiter(class trp_client*);
51  ~NdbWaiter();
52 
53  void signal(Uint32 state);
54  void nodeFail(Uint32 node);
55 
56  void clear_wait_state() { m_state = NO_WAIT; }
57  Uint32 get_wait_state() { return m_state; }
58  void set_wait_state(Uint32 s) { m_state = s;}
59 
60  void set_state(Uint32 state) { m_state= state; }
61  void set_node(Uint32 node) { m_node= node; }
62  Uint32 get_state() { return m_state; }
63 private:
64 
65  Uint32 m_node;
66  Uint32 m_state;
67  class trp_client* m_clnt;
68 };
69 
70 
71 #include "trp_client.hpp"
72 
73 inline
74 void
75 NdbWaiter::nodeFail(Uint32 aNodeId)
76 {
77  if (m_state != NO_WAIT && m_node == aNodeId)
78  {
79  m_state = WAIT_NODE_FAILURE;
80  m_clnt->wakeup();
81  }
82 }
83 
84 inline
85 void
86 NdbWaiter::signal(Uint32 state)
87 {
88  m_state = state;
89  m_clnt->wakeup();
90 }
91 
92 #endif