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, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 #ifndef NDB_WAITER_HPP
26 #define NDB_WAITER_HPP
27 
28 #include <ndb_global.h>
29 #include <NdbTick.h>
30 #include <NdbOut.hpp>
31 
32 enum WaitSignalType {
33   NO_WAIT           = 0,
34   WAIT_NODE_FAILURE = 1,  // Node failure during wait
35   WST_WAIT_TIMEOUT  = 2,  // Timeout during wait
36 
37   WAIT_TC_SEIZE     = 3,
38   WAIT_TC_RELEASE   = 4,
39   WAIT_NDB_TAMPER   = 5,
40   WAIT_SCAN         = 6,
41 
42   WAIT_TRANS        = 7,
43 
44   // DICT stuff
45   WAIT_GET_TAB_INFO_REQ = 11,
46   WAIT_CREATE_TAB_REQ = 12,
47   WAIT_DROP_TAB_REQ = 13,
48   WAIT_ALTER_TAB_REQ = 14,
49   WAIT_CREATE_INDX_REQ = 15,
50   WAIT_DROP_INDX_REQ = 16,
51   WAIT_LIST_TABLES_CONF = 17,
52   WAIT_SCHEMA_TRANS = 18
53 };
54 
55 class NdbWaiter {
56 public:
57   NdbWaiter(class trp_client*);
58   ~NdbWaiter();
59 
60   void signal(Uint32 state);
61   void nodeFail(Uint32 node);
62 
clear_wait_state()63   void clear_wait_state() { m_state = NO_WAIT; }
get_wait_state()64   Uint32 get_wait_state() { return m_state; }
set_wait_state(Uint32 s)65   void set_wait_state(Uint32 s) { m_state = s;}
66 
set_state(Uint32 state)67   void set_state(Uint32 state) { m_state= state; }
set_node(Uint32 node)68   void set_node(Uint32 node) { m_node= node; }
get_state()69   Uint32 get_state() { return m_state; }
70 private:
71 
72   Uint32 m_node;
73   Uint32 m_state;
74   class trp_client* m_clnt;
75 };
76 
77 
78 #include "trp_client.hpp"
79 
80 inline
81 void
nodeFail(Uint32 aNodeId)82 NdbWaiter::nodeFail(Uint32 aNodeId)
83 {
84   if (m_state != NO_WAIT && m_node == aNodeId)
85   {
86     m_state = WAIT_NODE_FAILURE;
87     m_clnt->wakeup();
88   }
89 }
90 
91 inline
92 void
signal(Uint32 state)93 NdbWaiter::signal(Uint32 state)
94 {
95   m_state = state;
96   m_clnt->wakeup();
97 }
98 
99 #endif
100