1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
/* Copyright (c) 2003-2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifndef TRIX_H
#define TRIX_H
#include <SimulatedBlock.hpp>
#include <trigger_definitions.h>
#include <DataBuffer.hpp>
#include <SimpleProperties.hpp>
#include <signaldata/DictTabInfo.hpp>
#include <signaldata/CreateTrig.hpp>
#include <signaldata/BuildIndx.hpp>
// Error codes
#define INTERNAL_ERROR_ILLEGAL_CALL 4344
#define INTERNAL_ERROR_TRIX_BUSY 4345
/**
* TRIX - This block manages triggers and index (in coop with DICT)
*/
class Trix : public SimulatedBlock
{
public:
Trix(Block_context&);
virtual ~Trix();
public:
// Subscription data, when communicating with SUMA
enum RequestType {
TABLE_REORG = 0,
INDEX_BUILD = 1
};
typedef DataBuffer<11> AttrOrderBuffer;
private:
// Private attributes
BLOCK_DEFINES(Trix);
// Declared but not defined
//DBtrix(const Trix &obj);
//void operator = (const Trix &);
// Block state
enum BlockState {
NOT_STARTED,
STARTED,
NODE_FAILURE,
IDLE,
BUSY
};
BlockState c_blockState;
// Node data needed when communicating with remote TRIX:es
struct NodeRecord {
bool alive;
BlockReference trixRef;
union {
Uint32 nextPool;
Uint32 nextList;
};
Uint32 prevList;
};
typedef Ptr<NodeRecord> NodeRecPtr;
/**
* The pool of node records
*/
ArrayPool<NodeRecord> c_theNodeRecPool;
/**
* The list of other NDB nodes
*/
DLList<NodeRecord> c_theNodes;
Uint32 c_masterNodeId;
BlockReference c_masterTrixRef;
Uint16 c_noNodesFailed;
Uint16 c_noActiveNodes;
AttrOrderBuffer::DataBufferPool c_theAttrOrderBufferPool;
struct SubscriptionRecord {
SubscriptionRecord(AttrOrderBuffer::DataBufferPool & aop):
attributeOrder(aop)
{}
RequestType requestType;
BlockReference userReference; // For user
Uint32 connectionPtr; // For user
Uint32 subscriptionId; // For Suma
Uint32 subscriptionKey; // For Suma
Uint32 prepareId; // For DbUtil
Uint32 indexType;
Uint32 sourceTableId;
Uint32 targetTableId;
AttrOrderBuffer attributeOrder;
Uint32 noOfIndexColumns;
Uint32 noOfKeyColumns;
Uint32 parallelism;
BuildIndxRef::ErrorCode errorCode;
bool subscriptionCreated;
bool pendingSubSyncContinueConf;
Uint32 expectedConf; // Count in n UTIL_EXECUTE_CONF + 1 SUB_SYNC_CONF
union {
Uint32 nextPool;
Uint32 nextList;
};
Uint32 prevList;
};
typedef Ptr<SubscriptionRecord> SubscriptionRecPtr;
/**
* The pool of node records
*/
ArrayPool<SubscriptionRecord> c_theSubscriptionRecPool;
/**
* The list of other subscriptions
*/
DLList<SubscriptionRecord> c_theSubscriptions;
// System start
void execREAD_CONFIG_REQ(Signal* signal);
void execSTTOR(Signal* signal);
void execNDB_STTOR(Signal* signal);
// Node management
void execREAD_NODESCONF(Signal* signal);
void execREAD_NODESREF(Signal* signal);
void execNODE_FAILREP(Signal* signal);
void execINCL_NODEREQ(Signal* signal);
// Debugging
void execDUMP_STATE_ORD(Signal* signal);
// Build index
void execBUILDINDXREQ(Signal* signal);
void execBUILDINDXCONF(Signal* signal);
void execBUILDINDXREF(Signal* signal);
void execUTIL_PREPARE_CONF(Signal* signal);
void execUTIL_PREPARE_REF(Signal* signal);
void execUTIL_EXECUTE_CONF(Signal* signal);
void execUTIL_EXECUTE_REF(Signal* signal);
void execUTIL_RELEASE_CONF(Signal* signal);
void execUTIL_RELEASE_REF(Signal* signal);
// Suma signals
void execSUB_CREATE_CONF(Signal* signal);
void execSUB_CREATE_REF(Signal* signal);
void execSUB_REMOVE_CONF(Signal* signal);
void execSUB_REMOVE_REF(Signal* signal);
void execSUB_SYNC_CONF(Signal* signal);
void execSUB_SYNC_REF(Signal* signal);
void execSUB_SYNC_CONTINUE_REQ(Signal* signal);
void execSUB_TABLE_DATA(Signal* signal);
// Utility functions
void setupSubscription(Signal* signal, SubscriptionRecPtr subRecPtr);
void startTableScan(Signal* signal, SubscriptionRecPtr subRecPtr);
void prepareInsertTransactions(Signal* signal, SubscriptionRecPtr subRecPtr);
void executeInsertTransaction(Signal* signal, SubscriptionRecPtr subRecPtr,
SegmentedSectionPtr headerPtr,
SegmentedSectionPtr dataPtr);
void buildComplete(Signal* signal, SubscriptionRecPtr subRecPtr);
void buildFailed(Signal* signal,
SubscriptionRecPtr subRecPtr,
BuildIndxRef::ErrorCode);
void checkParallelism(Signal* signal, SubscriptionRecord* subRec);
};
#endif
|