MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HugoAsynchTransactions.hpp
1 /*
2  Copyright (C) 2003, 2005, 2006 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 #ifndef HUGO_ASYNCH_TRANSACTIONS_HPP
20 #define HUGO_ASYNCH_TRANSACTIONS_HPP
21 
22 
23 #include <NDBT.hpp>
24 #include <HugoCalculator.hpp>
25 #include <HugoTransactions.hpp>
26 
28 public:
31  int loadTableAsynch(Ndb*,
32  int records = 0,
33  int batch = 1,
34  int trans = 1,
35  int operations = 1);
36  int pkReadRecordsAsynch(Ndb*,
37  int records = 0,
38  int batch= 1,
39  int trans = 1,
40  int operations = 1);
41  int pkUpdateRecordsAsynch(Ndb*,
42  int records = 0,
43  int batch= 1,
44  int trans = 1,
45  int operations = 1);
46  int pkDelRecordsAsynch(Ndb*,
47  int records = 0,
48  int batch = 1,
49  int trans = 1,
50  int operations = 1);
51 
52 private:
53  enum NDB_OPERATION {NO_INSERT, NO_UPDATE, NO_READ, NO_DELETE};
54 
55  long transactionsCompleted;
56 
57  struct TransactionInfo
58  {
60  NdbConnection* transaction;
61  int startRecordId;
62  int numRecords;
63  int resultRowStartIndex;
64  int retries;
65  NDB_OPERATION opType;
66  };
67 
68  TransactionInfo* transInfo;
69  Ndb* theNdb;
70 
71  /* Work description */
72  int totalLoops;
73  int recordsPerLoop;
74  int maxOpsPerTrans;
75  NDB_OPERATION operationType;
76  ExecType execType;
77 
78  /* Progress description */
79  int nextUnProcessedRecord;
80  int loopNum;
81  int totalCompletedRecords;
82  int maxUsedRetries;
83  bool finished;
84  int testResult;
85 
86  void allocTransactions(int trans, int maxOpsPerTrans);
87  void deallocTransactions();
88 
89  int getNextWorkTask(int* startRecordId, int* numRecords);
90 
91  int defineUpdateOpsForTask(TransactionInfo* tInfo);
92  int defineTransactionForTask(TransactionInfo* tInfo, ExecType taskExecType);
93 
94  int beginNewTask(TransactionInfo* tInfo);
95  static void callbackFunc(int result, NdbConnection* trans, void* anObject);
96  void callback(int result, NdbConnection* trans, TransactionInfo* tInfo);
97 
98  int executeAsynchOperation(Ndb*,
99  int records,
100  int batch,
101  int trans,
102  int operations,
103  NDB_OPERATION theOperation,
104  ExecType theType = Commit);
105 };
106 
107 
108 
109 #endif
110