MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SignalSender.hpp
1 /*
2  Copyright (c) 2005, 2011, 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 SIGNAL_SENDER_HPP
19 #define SIGNAL_SENDER_HPP
20 
21 #include <ndb_global.h>
22 #include "TransporterFacade.hpp"
23 #include "trp_client.hpp"
24 #include "NdbApiSignal.hpp"
25 #include <Vector.hpp>
26 
27 #include <signaldata/TestOrd.hpp>
28 #include <signaldata/TamperOrd.hpp>
29 #include <signaldata/StartOrd.hpp>
30 #include <signaldata/ApiVersion.hpp>
31 #include <signaldata/ResumeReq.hpp>
32 #include <signaldata/SetLogLevelOrd.hpp>
33 #include <signaldata/EventSubscribeReq.hpp>
34 #include <signaldata/EventReport.hpp>
35 #include <signaldata/DumpStateOrd.hpp>
36 #include <signaldata/BackupSignalData.hpp>
37 #include <signaldata/AllocNodeId.hpp>
38 
39 struct SimpleSignal {
40 public:
41  SimpleSignal(bool dealloc = false);
42  SimpleSignal(const SimpleSignal& src);
43  ~SimpleSignal();
44 
45  void set(class SignalSender&,
46  Uint8 trace, Uint16 recBlock, Uint16 gsn, Uint32 len);
47 
48  NdbApiSignal header;
49  LinearSectionPtr ptr[3];
50 
51  int readSignalNumber() const { return header.readSignalNumber(); };
52  Uint32 *getDataPtrSend() { return header.getDataPtrSend(); }
53  const Uint32 *getDataPtr() const { return header.getDataPtr(); }
54  Uint32 getLength() const { return header.getLength(); }
55 
59  bool isFragmented() const { return header.isFragmented(); }
60  bool isFirstFragment() const { return header.isFirstFragment(); }
61  bool isLastFragment() const { return header.isLastFragment(); };
62  Uint32 getFragmentId() const { return header.getFragmentId(); };
63 
64  void print(FILE * out = stdout) const;
65  SimpleSignal& operator=(const SimpleSignal&);
66 private:
67  bool deallocSections;
68 };
69 
70 class SignalSender : public trp_client {
71 public:
72  SignalSender(TransporterFacade *facade, int blockNo = -1);
74  virtual ~SignalSender();
75 
76  int lock();
77  int unlock();
78 
79  Uint32 getOwnRef() const;
80 
81  NodeId find_confirmed_node(const NodeBitmask& mask);
82  NodeId find_connected_node(const NodeBitmask& mask);
83  NodeId find_alive_node(const NodeBitmask& mask);
84 
85  SendStatus sendSignal(Uint16 nodeId, const SimpleSignal *);
86  SendStatus sendSignal(Uint16 nodeId, SimpleSignal& sig,
87  Uint16 recBlock, Uint16 gsn, Uint32 len);
88  int sendFragmentedSignal(Uint16 nodeId, SimpleSignal& sig,
89  Uint16 recBlock, Uint16 gsn, Uint32 len);
90  NodeBitmask broadcastSignal(NodeBitmask mask, SimpleSignal& sig,
91  Uint16 recBlock, Uint16 gsn, Uint32 len);
92 
93  SimpleSignal * waitFor(Uint32 timeOutMillis = 0);
94 
95  Uint32 get_an_alive_node() const { return theFacade->get_an_alive_node(); }
96  Uint32 getAliveNode() const { return get_an_alive_node(); }
97  bool get_node_alive(Uint32 n) const { return getNodeInfo(n).m_alive; }
98 
99 private:
100  int m_blockNo;
101  TransporterFacade * theFacade;
102 
103 public:
107  virtual void trp_deliver_signal(const NdbApiSignal* signal,
108  const struct LinearSectionPtr ptr[3]);
109 
110  Vector<SimpleSignal *> m_jobBuffer;
111  Vector<SimpleSignal *> m_usedBuffer;
112 
113  template<class T>
114  SimpleSignal * waitFor(Uint32 timeOutMillis, T & t);
115 
116  template<class T>
117  NodeId find_node(const NodeBitmask& mask, T & t);
118 };
119 
120 #endif