1 /* Copyright (c) 2003-2007 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
29 Bank(Ndb_cluster_connection
&, bool init
= true, const char *dbase
="BANK");
31 void setSkipCreate(bool skip
) { m_skip_create
= skip
; }
32 int createAndLoadBank(bool overWrite
, bool disk
= false, int num_accounts
=10);
35 int performTransactions(int maxSleepBetweenTrans
= 20, int yield
=0);
36 int performMakeGLs(int yield
=0);
37 int performValidateAllGLs();
38 int performSumAccounts(int maxSleepBetweenSums
= 2000, int yield
=0);
39 int performIncreaseTime(int maxSleepBetweenDays
= 30, int yield
=0);
44 enum TransactionTypes
{
49 static const int NOT_ENOUGH_FUNDS
= 1000;
50 static const int VERIFICATION_FAILED
= 1001;
52 int performTransaction();
53 int performTransaction(int fromAccountId
,
56 int performTransactionImpl1(int fromAccountId
,
60 int performValidateGLs(Uint64 age
= 20);
61 int performValidateGL(Uint64 GLTime
);
62 int performValidatePurged();
64 int performMakeGL(int time
);
65 int performMakeGLForAccountType(NdbConnection
* pTrans
,
67 Uint32 accountTypeId
);
68 int sumTransactionsForGL(const Uint64 time
,
69 const Uint32 accountType
,
71 Uint32
& withdrawalCount
,
72 Uint32
& withdrawalSum
,
75 Uint32
& transactionsCount
,
76 NdbConnection
* pTrans
);
77 int getBalanceForAccountType(const Uint32 accountType
,
79 int getBalanceForGL(const Uint64 glTime
,
80 const Uint32 accountType
,
83 int checkNoTransactionsOlderThan(const Uint32 accountType
,
85 int getOldestPurgedGL(const Uint32 accountType
,
87 int getOldestNotPurgedGL(Uint64
&oldest
,
88 Uint32
&accountTypeId
,
90 int findLastGL(Uint64
&lastTime
);
91 int purgeOldGLTransactions(Uint64 currTime
, Uint32 age
);
93 int purgeTransactions(const Uint64 glTime
,
94 const Uint32 accountTypeId
);
95 int findTransactionsToPurge(const Uint64 glTime
,
96 const Uint32 accountType
,
97 NdbConnection
* pTrans
);
100 int getSumAccounts(Uint32
&sumAccounts
,
101 Uint32
&numAccounts
);
102 int getNumAccounts();
103 int getNumAccountTypes();
108 LastTransactionId
= 0,
113 int readSystemValue(SystemValueId sysValId
, Uint64
& value
);
114 int increaseSystemValue(SystemValueId sysValId
, Uint64
&value
);
115 int increaseSystemValue2(SystemValueId sysValId
, Uint64
&value
);
116 int writeSystemValue(SystemValueId sysValId
, Uint64 value
);
117 int getNextTransactionId(Uint64
&value
);
118 int incCurrTime(Uint64
&value
);
119 int getCurrTime(Uint64
&time
);
121 int prepareReadSystemValueOp(NdbConnection
*, SystemValueId sysValId
, Uint64
&time
);
122 int prepareGetCurrTimeOp(NdbConnection
*, Uint64
&time
);
124 int createTables(bool disk
);
125 int createTable(const char* tabName
, bool disk
);
128 int dropTable(const char* tabName
);
131 int clearTable(const char* tabName
);
134 int loadAccountType();
135 int loadAccount (int numAccounts
);
136 int loadSystemValues();