1 /*
2    Copyright (c) 2003, 2018, 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 Cmvmi_H_
26 #define Cmvmi_H_
27 
28 #include <SimulatedBlock.hpp>
29 #include <LogLevel.hpp>
30 
31 #include <IntrusiveList.hpp>
32 
33 #define JAM_FILE_ID 379
34 
35 
36 /**
37  * Cmvmi class
38  */
39 class Cmvmi : public SimulatedBlock {
40 public:
41   Cmvmi(Block_context&);
42   virtual ~Cmvmi();
43 
44 private:
45   BLOCK_DEFINES(Cmvmi);
46 
47   // The signal processing functions
48   void execNDB_TAMPER(Signal* signal);
49   void execSET_LOGLEVELORD(Signal* signal);
50   void execEVENT_REP(Signal* signal);
51   void execREAD_CONFIG_REQ(Signal* signal);
52   void execSTTOR(Signal* signal);
53   void execSIZEALT_ACK(Signal* signal);
54   void execTEST_ORD(Signal* signal);
55 
56   void execSTOP_ORD(Signal* signal);
57   void execSTART_ORD(Signal* signal);
58   void execTAMPER_ORD(Signal* signal);
59 
60   void execDUMP_STATE_ORD(Signal* signal);
61   void execTC_COMMIT_ACK(Signal* signal);
62 
63   void execEVENT_SUBSCRIBE_REQ(Signal *);
64   void execCANCEL_SUBSCRIPTION_REQ(Signal *);
65 
66   void execTESTSIG(Signal* signal);
67   void execNODE_START_REP(Signal* signal);
68 
69   void execCONTINUEB(Signal* signal);
70 
71   void execDBINFO_SCANREQ(Signal *signal);
72 
73   void execALLOC_MEM_REF(Signal*);
74   void execALLOC_MEM_CONF(Signal*);
75 
76   void execGET_CONFIG_REQ(Signal*);
77 
78 #ifdef ERROR_INSERT
79   Uint32 g_remaining_responses;
80   /* Testing */
81   void execFSOPENCONF(Signal*);
82   void execFSCLOSECONF(Signal*);
83 #endif
84 
85   char theErrorMessage[256];
86   void sendSTTORRY(Signal* signal);
87 
88   LogLevel clogLevel;
89   NdbNodeBitmask c_dbNodes;
90 
91   /**
92    * This struct defines the data needed for a EVENT_REP subscriber
93    */
94   struct EventRepSubscriber {
95     /**
96      * What log level is the subscriber using
97      */
98     LogLevel       logLevel;
99 
100     /**
101      * What block reference does he use
102      *   (Where should the EVENT_REP's be forwarded)
103      */
104     BlockReference blockRef;
105 
106     /**
107      * Next ptr (used in pool/list)
108      */
109     union { Uint32 nextPool; Uint32 nextList; };
110     Uint32 prevList;
111   };
112   typedef Ptr<EventRepSubscriber> SubscriberPtr;
113   typedef ArrayPool<EventRepSubscriber> EventRepSubscriber_pool;
114   typedef DLList<EventRepSubscriber_pool> EventRepSubscriber_list;
115   /**
116    * Pool of EventRepSubscriber record
117    */
118   EventRepSubscriber_pool subscriberPool;
119 
120   /**
121    * List of current subscribers
122    */
123   EventRepSubscriber_list subscribers;
124 
125 private:
126   // Declared but not defined
127   Cmvmi(const Cmvmi &obj);
128   void operator = (const Cmvmi &);
129 
130   void startFragmentedSend(Signal* signal, Uint32 variant, Uint32 numSigs, NodeReceiverGroup rg);
131   void testNodeFailureCleanupCallback(Signal* signal, Uint32 variant, Uint32 elementsCleaned);
132   void testFragmentedCleanup(Signal* signal, SectionHandle* handle, Uint32 testType, Uint32 variant);
133   void sendFragmentedComplete(Signal* signal, Uint32 data, Uint32 returnCode);
134 
135   Uint32 c_memusage_report_frequency;
136   void reportDMUsage(Signal* signal, int incDec,
137                      BlockReference ref = CMVMI_REF);
138   void reportIMUsage(Signal* signal, int incDec,
139                      BlockReference ref = CMVMI_REF);
140 
141   NDB_TICKS m_start_time;
142 
143   struct SyncRecord
144   {
145     Uint32 m_senderRef;
146     Uint32 m_senderData;
147     Uint32 m_prio;
148     Uint32 m_cnt;
149     Uint32 m_error;
150     Uint32 nextPool;
151   };
152   typedef ArrayPool<SyncRecord> SyncRecord_pool;
153 
154   SyncRecord_pool c_syncReqPool;
155 
156   void execSYNC_REQ(Signal*);
157   void execSYNC_REF(Signal*);
158   void execSYNC_CONF(Signal*);
159   void sendSYNC_REP(Signal * signal, Ptr<SyncRecord> ptr);
160 
161   void init_global_page_pool();
162 };
163 
164 
165 #undef JAM_FILE_ID
166 
167 #endif
168