1 /*
2    Copyright (c) 2011, 2019, 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 TRPMAN_H
26 #define TRPMAN_H
27 
28 #include <pc.hpp>
29 #include <SimulatedBlock.hpp>
30 #include <LocalProxy.hpp>
31 #include <signaldata/EnableCom.hpp>
32 #include <signaldata/CloseComReqConf.hpp>
33 #include <signaldata/SyncThreadViaReqConf.hpp>
34 #include <ndb_limits.h>
35 
36 #define JAM_FILE_ID 334
37 
38 
39 class Trpman : public SimulatedBlock
40 {
41 public:
42   Trpman(Block_context& ctx, Uint32 instanceNumber = 0);
43   BLOCK_DEFINES(Trpman);
44 
45   void execCLOSE_COMREQ(Signal *signal);
46   void execCLOSE_COMCONF(Signal * signal);
47   void execOPEN_COMORD(Signal *signal);
48   void execENABLE_COMREQ(Signal *signal);
49   void execDISCONNECT_REP(Signal *signal);
50   void execCONNECT_REP(Signal *signal);
51   void execROUTE_ORD(Signal* signal);
52   void execACTIVATE_TRP_REQ(Signal*);
53 
54   void sendSYNC_THREAD_VIA_CONF(Signal*, Uint32, Uint32);
55   void execSYNC_THREAD_VIA_REQ(Signal*);
56 
57   void execDBINFO_SCANREQ(Signal*);
58 
59   void execNDB_TAMPER(Signal*);
60   void execDUMP_STATE_ORD(Signal*);
61 protected:
62   bool getParam(const char* name, Uint32* count) override;
63 private:
64   bool handles_this_node(Uint32 nodeId, bool all = false);
65   void close_com_failed_node(Signal*, Uint32);
66   void enable_com_node(Signal*, Uint32);
67 };
68 
69 class TrpmanProxy : public LocalProxy
70 {
71 public:
72   TrpmanProxy(Block_context& ctx);
73   virtual ~TrpmanProxy();
74   BLOCK_DEFINES(TrpmanProxy);
75 
76   // GSN_OPEN_COMORD
77   void execOPEN_COMORD(Signal *signal);
78 
79   // GSN_CLOSE_COMREQ
80   struct Ss_CLOSE_COMREQ : SsParallel {
81     CloseComReqConf m_req;
Ss_CLOSE_COMREQTrpmanProxy::Ss_CLOSE_COMREQ82     Ss_CLOSE_COMREQ() {
83       m_sendREQ = (SsFUNCREQ)&TrpmanProxy::sendCLOSE_COMREQ;
84       m_sendCONF = (SsFUNCREP)&TrpmanProxy::sendCLOSE_COMCONF;
85     }
86     enum { poolSize = MAX_NODES };
poolTrpmanProxy::Ss_CLOSE_COMREQ87     static SsPool<Ss_CLOSE_COMREQ>& pool(LocalProxy* proxy) {
88       return ((TrpmanProxy*)proxy)->c_ss_CLOSE_COMREQ;
89     }
90   };
91   SsPool<Ss_CLOSE_COMREQ> c_ss_CLOSE_COMREQ;
92   void execCLOSE_COMREQ(Signal *signal);
93   void sendCLOSE_COMREQ(Signal*, Uint32 ssId, SectionHandle*);
94   void execCLOSE_COMCONF(Signal *signal);
95   void sendCLOSE_COMCONF(Signal*, Uint32 ssId);
96 
97   // GSN_ENABLE_COMREQ
98   struct Ss_ENABLE_COMREQ : SsParallel {
99     EnableComReq m_req;
Ss_ENABLE_COMREQTrpmanProxy::Ss_ENABLE_COMREQ100     Ss_ENABLE_COMREQ() {
101       m_sendREQ = (SsFUNCREQ)&TrpmanProxy::sendENABLE_COMREQ;
102       m_sendCONF = (SsFUNCREP)&TrpmanProxy::sendENABLE_COMCONF;
103     }
104     enum { poolSize = MAX_NODES };
poolTrpmanProxy::Ss_ENABLE_COMREQ105     static SsPool<Ss_ENABLE_COMREQ>& pool(LocalProxy* proxy) {
106       return ((TrpmanProxy*)proxy)->c_ss_ENABLE_COMREQ;
107     }
108   };
109   SsPool<Ss_ENABLE_COMREQ> c_ss_ENABLE_COMREQ;
110   void execENABLE_COMREQ(Signal *signal);
111   void sendENABLE_COMREQ(Signal*, Uint32 ssId, SectionHandle*);
112   void execENABLE_COMCONF(Signal *signal);
113   void sendENABLE_COMCONF(Signal*, Uint32 ssId);
114 
115   // GSN_SYNC_THREAD_VIA
116   struct Ss_SYNC_THREAD_VIA : SsParallel {
117     SyncThreadViaReqConf m_req;
Ss_SYNC_THREAD_VIATrpmanProxy::Ss_SYNC_THREAD_VIA118     Ss_SYNC_THREAD_VIA() {
119       m_sendREQ = (SsFUNCREQ)&TrpmanProxy::sendSYNC_THREAD_VIA_REQ;
120       m_sendCONF = (SsFUNCREP)&TrpmanProxy::sendSYNC_THREAD_VIA_CONF;
121     }
122     enum { poolSize = MAX_DATA_NODE_ID }; // Qmgr::MAX_DATA_NODE_FAILURES
poolTrpmanProxy::Ss_SYNC_THREAD_VIA123     static SsPool<Ss_SYNC_THREAD_VIA>& pool(LocalProxy* proxy) {
124       return ((TrpmanProxy*)proxy)->c_ss_SYNC_THREAD_VIA;
125     }
126   };
127   SsPool<Ss_SYNC_THREAD_VIA> c_ss_SYNC_THREAD_VIA;
128   void execSYNC_THREAD_VIA_REQ(Signal*);
129   void sendSYNC_THREAD_VIA_REQ(Signal*, Uint32, SectionHandle*);
130   void execSYNC_THREAD_VIA_CONF(Signal*);
131   void sendSYNC_THREAD_VIA_CONF(Signal*, Uint32);
132 
133   void execROUTE_ORD(Signal* signal);
134   void execNDB_TAMPER(Signal*);
135   void execDUMP_STATE_ORD(Signal*);
136   void execACTIVATE_TRP_REQ(Signal*);
137 protected:
138   virtual SimulatedBlock* newWorker(Uint32 instanceNo);
139 };
140 
141 
142 #undef JAM_FILE_ID
143 
144 #endif
145