MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ndbfs.hpp
1 /*
2  Copyright (c) 2003, 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 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 SIMBLOCKASYNCFILESYSTEM_H
19 #define SIMBLOCKASYNCFILESYSTEM_H
20 
21 #include <pc.hpp>
22 #include <SimulatedBlock.hpp>
23 #include "Pool.hpp"
24 #include "AsyncFile.hpp"
25 #include "OpenFiles.hpp"
26 #include <signaldata/FsOpenReq.hpp>
27 
28 class AsyncIoThread;
29 
30 // Because one NDB Signal request can result in multiple requests to
31 // AsyncFile one class must be made responsible to keep track
32 // of all out standing request and when all are finished the result
33 // must be reported to the sending block.
34 
35 class Ndbfs : public SimulatedBlock
36 {
37  friend class AsyncIoThread;
38 public:
40  virtual ~Ndbfs();
41  virtual const char* get_filename(Uint32 fd) const;
42 
43 protected:
44  BLOCK_DEFINES(Ndbfs);
45 
46  // The signal processing functions
47  void execREAD_CONFIG_REQ(Signal* signal);
48  void execDUMP_STATE_ORD(Signal* signal);
49  void execFSOPENREQ(Signal* signal);
50  void execFSCLOSEREQ(Signal* signal);
51  void execFSWRITEREQ(Signal* signal);
52  void execFSREADREQ(Signal* signal);
53  void execFSSYNCREQ(Signal* signal);
54  void execFSAPPENDREQ(Signal* signal);
55  void execFSREMOVEREQ(Signal* signal);
56  void execSTTOR(Signal* signal);
57  void execCONTINUEB(Signal* signal);
58  void execALLOC_MEM_REQ(Signal* signal);
59  void execSEND_PACKED(Signal*);
60  void execBUILD_INDX_IMPL_REQ(Signal* signal);
61  void execFSSUSPENDORD(Signal*);
62 
63  Uint16 newId();
64 
65 private:
66  int forward(AsyncFile *file, Request* Request);
67  void report(Request* request, Signal* signal);
68 protected:
69  bool scanIPC(Signal* signal);
70  bool scanningInProgress;
71 
72 private:
73  // Declared but not defined
74  Ndbfs(Ndbfs & );
75  void operator = (Ndbfs &);
76 
77  // Used for uniqe number generation
78  Uint16 theLastId;
79 
80  // Communication from/to files
81  MemoryChannel<Request> theFromThreads;
82  MemoryChannel<Request> theToBoundThreads;
83  MemoryChannel<Request> theToUnboundThreads;
84 
85  Pool<Request>* theRequestPool;
86 
87  AsyncIoThread* createIoThread(bool bound);
88  AsyncFile* createAsyncFile();
89  AsyncFile* getIdleFile(bool bound);
90  void pushIdleFile(AsyncFile*);
91 
92  Vector<AsyncIoThread*> theThreads;// List of all created threads
93  Vector<AsyncFile*> theFiles; // List all created AsyncFiles
94  Vector<AsyncFile*> theIdleFiles; // List of idle AsyncFiles
95  OpenFiles theOpenFiles; // List of open AsyncFiles
96 
97  BaseString m_base_path[FsOpenReq::BP_MAX];
98 
99  // Statistics variables
100  Uint32 m_maxOpenedFiles;
101 
102  // Limit for max number of AsyncFiles created
103  Uint32 m_maxFiles;
104 
105  void readWriteRequest( int action, Signal * signal );
106 
107  static Uint32 translateErrno(int aErrno);
108 
109  Uint32 m_bound_threads_cnt;
110  Uint32 m_unbounds_threads_cnt;
111  Uint32 m_active_bound_threads_cnt;
112  void cnt_active_bound(int val);
113 public:
114  const BaseString& get_base_path(Uint32 no) const;
115 };
116 
117 class VoidFs : public Ndbfs
118 {
119 public:
121  virtual ~VoidFs();
122 
123 protected:
124  BLOCK_DEFINES(VoidFs);
125 
126  // The signal processing functions
127  void execREAD_CONFIG_REQ(Signal* signal);
128  void execDUMP_STATE_ORD(Signal* signal);
129  void execFSOPENREQ(Signal* signal);
130  void execFSCLOSEREQ(Signal* signal);
131  void execFSWRITEREQ(Signal* signal);
132  void execFSREADREQ(Signal* signal);
133  void execFSSYNCREQ(Signal* signal);
134  void execFSAPPENDREQ(Signal* signal);
135  void execFSREMOVEREQ(Signal* signal);
136  void execSTTOR(Signal* signal);
137  void execALLOC_MEM_REQ(Signal*);
138  void execSEND_PACKED(Signal*);
139  void execFSSUSPENDORD(Signal*);
140 
141 private:
142  // Declared but not defined
143  VoidFs(VoidFs & );
144  void operator = (VoidFs &);
145 
146  // Used for uniqe number generation
147  Uint32 c_maxFileNo;
148 };
149 
150 #endif
151 
152