mariadb/ndb/test/ndbapi/bank/Bank.hpp
unknown d31dd70b5a ndb - Update test programs to use new Ndb constructor
ndb/test/include/NDBT_Test.hpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/bank/Bank.cpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/bank/Bank.hpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/bank/bankCreator.cpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/bank/bankMakeGL.cpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/bank/bankSumAccounts.cpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/bank/bankTimer.cpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/bank/bankTransactionMaker.cpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/bank/bankValidateAllGLs.cpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/bank/testBank.cpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/create_all_tabs.cpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/create_tab.cpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/drop_all_tabs.cpp:
  Update to use new Ndb constructor
ndb/test/ndbapi/flexBench.cpp:
  Update to use new Ndb constructor
ndb/test/src/NDBT_Test.cpp:
  Update to use new Ndb constructor
ndb/test/tools/copy_tab.cpp:
  Update to use new Ndb constructor
ndb/test/tools/create_index.cpp:
  Update to use new Ndb constructor
ndb/test/tools/hugoFill.cpp:
  Update to use new Ndb constructor
ndb/test/tools/hugoLoad.cpp:
  Update to use new Ndb constructor
ndb/test/tools/hugoLockRecords.cpp:
  Update to use new Ndb constructor
ndb/test/tools/hugoPkDelete.cpp:
  Update to use new Ndb constructor
ndb/test/tools/hugoPkRead.cpp:
  Update to use new Ndb constructor
ndb/test/tools/hugoPkReadRecord.cpp:
  Update to use new Ndb constructor
ndb/test/tools/hugoPkUpdate.cpp:
  Update to use new Ndb constructor
ndb/test/tools/hugoScanRead.cpp:
  Update to use new Ndb constructor
ndb/test/tools/hugoScanUpdate.cpp:
  Update to use new Ndb constructor
ndb/test/tools/verify_index.cpp:
  Update to use new Ndb constructor
2004-12-29 16:01:43 +01:00

145 lines
4 KiB
C++

/* Copyright (C) 2003 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; either version 2 of the License, or
(at your option) any later version.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef BANK_HPP
#define BANK_HPP
#include <NdbOut.hpp>
#include <NdbApi.hpp>
#include <NDBT.hpp>
#include <NdbTick.h>
#include <random.h>
class Bank {
public:
Bank(Ndb_cluster_connection&);
int createAndLoadBank(bool overWrite, int num_accounts=10);
int dropBank();
int performTransactions(int maxSleepBetweenTrans = 20, int yield=0);
int performMakeGLs(int yield=0);
int performValidateAllGLs();
int performSumAccounts(int maxSleepBetweenSums = 2000, int yield=0);
int performIncreaseTime(int maxSleepBetweenDays = 30, int yield=0);
private:
int init();
enum TransactionTypes{
WithDrawal = 2000,
Deposit = 3000
};
static const int NOT_ENOUGH_FUNDS = 1000;
static const int VERIFICATION_FAILED = 1001;
int performTransaction();
int performTransaction(int fromAccountId,
int toAccountId,
int amount );
int performTransactionImpl1(int fromAccountId,
int toAccountId,
int amount );
int performValidateGLs(Uint64 age = 20);
int performValidateGL(Uint64 GLTime);
int performValidatePurged();
int performMakeGL(int time);
int performMakeGLForAccountType(NdbConnection* pTrans,
Uint64 time,
Uint32 accountTypeId);
int sumTransactionsForGL(const Uint64 time,
const Uint32 accountType,
Uint32& balance,
Uint32& withdrawalCount,
Uint32& withdrawalSum,
Uint32& depositSum,
Uint32& depositCount,
Uint32& transactionsCount,
NdbConnection* pTrans);
int getBalanceForAccountType(const Uint32 accountType,
Uint32& balance);
int getBalanceForGL(const Uint64 glTime,
const Uint32 accountType,
Uint32 &balance);
int checkNoTransactionsOlderThan(const Uint32 accountType,
const Uint64 oldest);
int getOldestPurgedGL(const Uint32 accountType,
Uint64 &oldest);
int getOldestNotPurgedGL(Uint64 &oldest,
Uint32 &accountTypeId,
bool &found);
int findLastGL(Uint64 &lastTime);
int purgeOldGLTransactions(Uint64 currTime, Uint32 age);
int purgeTransactions(const Uint64 glTime,
const Uint32 accountTypeId);
int findTransactionsToPurge(const Uint64 glTime,
const Uint32 accountType,
NdbConnection* pTrans);
int getSumAccounts(Uint32 &sumAccounts,
Uint32 &numAccounts);
int getNumAccounts();
int getNumAccountTypes();
int getMaxAmount();
enum SystemValueId {
LastTransactionId = 0,
CurrentTime = 1
};
int readSystemValue(SystemValueId sysValId, Uint64 & value);
int increaseSystemValue(SystemValueId sysValId, Uint64 &value);
int increaseSystemValue2(SystemValueId sysValId, Uint64 &value);
int writeSystemValue(SystemValueId sysValId, Uint64 value);
int getNextTransactionId(Uint64 &value);
int incCurrTime(Uint64 &value);
int getCurrTime(Uint64 &time);
int prepareReadSystemValueOp(NdbConnection*, SystemValueId sysValId, Uint64 &time);
int prepareGetCurrTimeOp(NdbConnection*, Uint64 &time);
int createTables();
int createTable(const char* tabName);
int dropTables();
int dropTable(const char* tabName);
int clearTables();
int clearTable(const char* tabName);
int loadGl();
int loadAccountType();
int loadAccount (int numAccounts);
int loadSystemValues();
private:
Ndb m_ndb;
int m_maxAccount;
bool m_initialized;
};
#endif