18 #ifndef NdbEventOperationImpl_H
19 #define NdbEventOperationImpl_H
21 #include <NdbEventOperation.hpp>
22 #include <signaldata/SumaImpl.hpp>
23 #include <transporter/TransporterDefinitions.hpp>
24 #include <NdbRecAttr.hpp>
25 #include <AttributeHeader.hpp>
26 #include <UtilBuffer.hpp>
28 #define NDB_EVENT_OP_MAGIC_NUMBER 0xA9F301B4
31 #define DBUG_ENTER_EVENT(A) DBUG_ENTER(A)
32 #define DBUG_RETURN_EVENT(A) DBUG_RETURN(A)
33 #define DBUG_VOID_RETURN_EVENT DBUG_VOID_RETURN
34 #define DBUG_PRINT_EVENT(A,B) DBUG_PRINT(A,B)
35 #define DBUG_DUMP_EVENT(A,B,C) DBUG_DUMP(A,B,C)
37 #define DBUG_ENTER_EVENT(A)
38 #define DBUG_RETURN_EVENT(A) return(A)
39 #define DBUG_VOID_RETURN_EVENT return
40 #define DBUG_PRINT_EVENT(A,B)
41 #define DBUG_DUMP_EVENT(A,B,C)
44 #undef NDB_EVENT_VERIFY_SIZE
47 #define NDB_EVENT_VERIFY_SIZE
86 void get_full_size(Uint32 & full_count, Uint32 & full_sz)
const {
90 add_part_size(full_count, full_sz);
92 void add_part_size(Uint32 & full_count, Uint32 & full_sz)
const;
102 void remove_first(Uint32 & full_count, Uint32 & full_sz);
104 void append_used_data(
EventBufData *data, Uint32 full_count, Uint32 full_sz);
157 Uint32 m_gci_op_count;
166 Uint32 m_gci_op_count;
167 Gci_ops *m_gci_ops_list_tail;
171 Uint32 m_gci_op_alloc;
172 Uint32 m_is_not_multi_list;
174 Gci_ops *first_gci_ops();
175 Gci_ops *delete_next_gci_ops();
177 void add_gci_op(Gci_op g);
185 EventBufData_list::EventBufData_list()
186 : m_head(0), m_tail(0),
190 m_gci_ops_list_tail(0),
193 DBUG_ENTER_EVENT(
"EventBufData_list::EventBufData_list");
194 DBUG_PRINT_EVENT(
"info", (
"this: %p",
this));
195 DBUG_VOID_RETURN_EVENT;
199 EventBufData_list::~EventBufData_list()
201 DBUG_ENTER_EVENT(
"EventBufData_list::~EventBufData_list");
202 DBUG_PRINT_EVENT(
"info", (
"this: %p m_is_not_multi_list: %u",
203 this, m_is_not_multi_list));
204 if (m_is_not_multi_list)
206 DBUG_PRINT_EVENT(
"info", (
"delete m_gci_op_list: %p", m_gci_op_list));
207 delete [] m_gci_op_list;
211 Gci_ops *op = first_gci_ops();
213 op = delete_next_gci_ops();
215 DBUG_VOID_RETURN_EVENT;
219 int EventBufData_list::is_empty()
225 void EventBufData_list::remove_first(Uint32 & full_count, Uint32 & full_sz)
227 m_head->get_full_size(full_count, full_sz);
229 assert(m_count >= full_count);
230 assert(m_sz >= full_sz);
232 m_count -= full_count;
234 m_head = m_head->m_next;
240 void EventBufData_list::append_used_data(
EventBufData *data, Uint32 full_count, Uint32 full_sz)
244 m_tail->m_next = data;
249 assert(m_count == 0);
256 m_count += full_count;
261 void EventBufData_list::append_used_data(
EventBufData *data)
263 Uint32 full_count, full_sz;
264 data->get_full_size(full_count, full_sz);
265 append_used_data(data, full_count, full_sz);
271 Gci_op g = { data->m_event_op,
272 1 << SubTableData::getOperation(data->sdata->requestInfo) };
275 append_used_data(data);
279 EventBufData_list::first_gci_ops()
281 assert(!m_is_not_multi_list);
282 return m_gci_ops_list;
286 EventBufData_list::delete_next_gci_ops()
288 assert(!m_is_not_multi_list);
289 Gci_ops *first = m_gci_ops_list;
290 m_gci_ops_list = first->m_next;
291 if (first->m_gci_op_list)
293 DBUG_PRINT_EVENT(
"info", (
"this: %p delete m_gci_op_list: %p",
294 this, first->m_gci_op_list));
295 delete [] first->m_gci_op_list;
298 if (m_gci_ops_list == 0)
299 m_gci_ops_list_tail = 0;
300 return m_gci_ops_list;
320 enum { GCI_EVENT_HASH_SIZE = 101 };
325 void EventBufData_hash::append(Pos& hpos,
EventBufData* data)
327 data->m_next_hash = m_hash[hpos.index];
328 m_hash[hpos.index] = data;
336 GC_INCONSISTENT = 0x2
342 Uint16 m_gcp_complete_rep_count;
357 const char* eventName);
368 int execute_nolock();
370 NdbRecAttr *getValue(
const char *colName,
char *aValue,
int n);
372 NdbBlob *getBlobHandle(
const char *colName,
int n);
374 Uint32 get_blob_part_no(
bool hasDist);
376 Uint32 part, Uint32 count, Uint16* lenLoc);
378 bool tableNameChanged()
const;
379 bool tableFrmChanged()
const;
380 bool tableFragmentationChanged()
const;
381 bool tableRangeListChanged()
const;
383 Uint32 getAnyValue()
const;
384 Uint64 getLatestGCI();
385 Uint64 getTransId()
const;
395 Uint32 m_magic_number;
397 const NdbError & getNdbError()
const;
466 Uint32 m_change_mask;
469 Uint32 m_data_done_count;
477 void receive_data(
NdbRecAttr *r,
const Uint32 *data, Uint32 sz);
485 Uint32 m_total_buckets;
486 Uint16 m_min_gci_index;
487 Uint16 m_max_gci_index;
490 STATIC_CONST( ACTIVE_GCI_DIRECTORY_SIZE = 4 );
491 STATIC_CONST( ACTIVE_GCI_MASK = ACTIVE_GCI_DIRECTORY_SIZE - 1 );
500 void add_drop_lock() { NdbMutex_Lock(m_add_drop_mutex); }
501 void add_drop_unlock() { NdbMutex_Unlock(m_add_drop_mutex); }
502 void lock() { NdbMutex_Lock(m_mutex); }
503 void unlock() { NdbMutex_Unlock(m_mutex); }
507 void init_gci_containers();
514 int complete_cluster_failure= 0);
515 void complete_outof_order_gcis();
517 void report_node_failure_completed(Uint32 node_id);
520 Uint64 getLatestGCI();
521 Uint32 getEventId(
int bufferId);
523 int pollEvents(
int aMillisecondNumber, Uint64 *latestGCI= 0);
524 int flushIncompleteEvents(Uint64 gci);
526 bool isConsistent(Uint64& gci);
527 bool isConsistentGCI(Uint64 gci);
530 Uint32* event_types);
531 void deleteUsedEventOperations(Uint64 last_consumed_gci);
542 int copy_data(
const SubTableData *
const sdata, Uint32 len,
546 int merge_data(
const SubTableData *
const sdata, Uint32 len,
562 static NdbMutex *p_add_drop_mutex;
565 const char *m_latest_command;
573 Uint64 m_latest_complete_GCI;
574 Uint64 m_highest_sub_gcp_complete_GCI;
576 Uint64 m_latest_poll_GCI;
587 Uint32 m_free_data_count;
589 Uint32 m_free_data_sz;
595 unsigned m_total_alloc;
598 unsigned m_free_thresh, m_min_free_thresh, m_max_free_thresh;
599 unsigned m_gci_slip_thresh;
604 static void verify_size(
const EventBufData* data, Uint32 count, Uint32 sz);
614 int expand(
unsigned sz);
617 struct EventBufData_chunk
635 Uint32 m_active_op_count;
636 NdbMutex *m_add_drop_mutex;
639 Uint32 pos = (Uint32)(gci & ACTIVE_GCI_MASK);
641 if(likely(gci == bucket->m_gci))
644 return find_bucket_chained(gci);
648 void verify_known_gci(
bool allowempty);
652 bool find_max_known_gci(Uint64 * res)
const;
653 void resize_known_gci();
660 void set_total_buckets(Uint32);
671 NdbEventOperationImpl::receive_data(
NdbRecAttr *r,
675 r->receive_data(data,sz);
679 assert((r->attrSize() * r->arraySize() + 3) >> 2 == sz);
681 memcpy(r->
aRef(), data, 4 * sz);