MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SignalLoggerManager.hpp
1 /*
2  Copyright (C) 2003-2008 MySQL AB, 2008 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 //****************************************************************************
20 //
21 // .NAME
22 // SignalLoggerManager - Handle signal loggers
23 //
24 //****************************************************************************
25 #ifndef SignalLoggerManager_H
26 #define SignalLoggerManager_H
27 
28 
29 #include <kernel_types.h>
30 #include <BlockNumbers.h>
31 #include <TransporterDefinitions.hpp>
32 #include <RefConvert.hpp>
33 
35 {
36 public:
38  virtual ~SignalLoggerManager();
39 
44  FILE * setOutputStream(FILE * output);
45 
49  FILE * getOutputStream() const;
50 
51  void flushSignalLog();
52 
57  void executeDirect(const SignalHeader&,
58  Uint8 prio, const Uint32 * theData, Uint32 node);
59 
63  void executeSignal(const SignalHeader& sh, Uint8 prio,
64  const Uint32 * theData, Uint32 node) {
65  executeSignal(sh, prio, theData, node, (LinearSectionPtr*)0, 0);
66  }
67 
68  void executeSignal(const SignalHeader&, Uint8 prio,
69  const Uint32 * theData, Uint32 node,
70  const SegmentedSectionPtr ptr[3], Uint32 secs);
71 
72  void executeSignal(const SignalHeader&, Uint8 prio,
73  const Uint32 * theData, Uint32 node,
74  const LinearSectionPtr ptr[3], Uint32 secs);
75 
79  void sendSignal(const SignalHeader& sh, Uint8 prio,
80  const Uint32 * theData, Uint32 node) {
81  sendSignal(sh, prio, theData, node, (LinearSectionPtr*)0, 0);
82  }
83 
84  void sendSignal(const SignalHeader&, Uint8 prio,
85  const Uint32 * theData, Uint32 node,
86  const SegmentedSectionPtr ptr[3], Uint32 secs);
87 
88  void sendSignal(const SignalHeader&, Uint8 prio,
89  const Uint32 * theData, Uint32 node,
90  const LinearSectionPtr ptr[3], Uint32 secs);
91 
92  void sendSignal(const SignalHeader&, Uint8 prio,
93  const Uint32 * theData, Uint32 node,
94  const GenericSectionPtr ptr[3], Uint32 secs);
95 
99  void sendSignalWithDelay(Uint32 delayInMilliSeconds,
100  const SignalHeader& sh,
101  Uint8 prio, const Uint32 * data, Uint32 node){
102  sendSignalWithDelay(delayInMilliSeconds, sh, prio, data, node,
103  (SegmentedSectionPtr*)0, 0);
104  }
105 
106  void sendSignalWithDelay(Uint32 delayInMilliSeconds,
107  const SignalHeader&,
108  Uint8 prio, const Uint32 * data, Uint32 node,
109  const SegmentedSectionPtr ptr[3], Uint32 secs);
110 
114  void log(BlockNumber bno, const char * msg, ...)
115  ATTRIBUTE_FORMAT(printf, 3, 4);
116 
120  enum LogMode {
121  LogOff = 0,
122  LogIn = 1,
123  LogOut = 2,
124  LogInOut = 3
125  };
126 
130  int log(LogMode logMode, const char * params);
131  int logOn(bool allBlocks, BlockNumber bno, LogMode logMode);
132  int logOff(bool allBlocks, BlockNumber bno, LogMode logMode);
133  int logToggle(bool allBlocks, BlockNumber bno, LogMode logMode);
134 
135  void setTrace(unsigned long trace);
136  unsigned long getTrace() const;
137 
138  void setOwnNodeId(int nodeId);
139  void setLogDistributed(bool val);
140 
144  static void printSignalHeader(FILE * output,
145  const SignalHeader & sh,
146  Uint8 prio,
147  Uint32 node,
148  bool printReceiversSignalId);
149 
153  static void printSignalData(FILE * out,
154  const SignalHeader & sh, const Uint32 *);
155 
159  static void printLinearSection(FILE * output,
160  const SignalHeader & sh,
161  const LinearSectionPtr ptr[3],
162  unsigned i);
163 
167  static void printSegmentedSection(FILE * output,
168  const SignalHeader & sh,
169  const SegmentedSectionPtr ptr[3],
170  unsigned i);
171 
175  static void printGenericSection(FILE * output,
176  const SignalHeader & sh,
177  const GenericSectionPtr ptr[3],
178  unsigned i);
179 
184  static void printDataWord(FILE * output, Uint32 & pos, const Uint32 data);
185 
186 private:
187  bool m_logDistributed;
188  Uint32 m_ownNodeId;
189 
190  FILE * outputStream;
191  int log(int cmd, BlockNumber bno, LogMode logMode);
192 
193  Uint32 traceId;
194  Uint8 logModes[NO_OF_BLOCKS];
195 
196  NdbMutex* m_mutex;
197 
198 public:
199  void lock() { if (m_mutex != 0) NdbMutex_Lock(m_mutex); }
200  void unlock() { if (m_mutex != 0) NdbMutex_Unlock(m_mutex); }
201 
202  inline bool
203  logMatch(BlockNumber bno, LogMode mask)
204  {
205  // extract main block number
206  bno = blockToMain(bno);
207  // avoid addressing outside logModes
208  return
209  bno < MIN_BLOCK_NO || bno > MAX_BLOCK_NO ||
210  (logModes[bno-MIN_BLOCK_NO] & mask);
211  }
212 };
213 
214 #endif // SignalLoggerManager_H
215