|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.derbyTesting.perf.clients.BankTransactionClient
public class BankTransactionClient
This class implements a client thread which performs bank transactions. The transactions are intended to perform the same operations as the transactions specified by the TPC-B benchmark.
| Field Summary | |
|---|---|
private int |
accountsPerBranch
The number of accounts per branch. |
private int |
branches
The number of branches in the database. |
private java.sql.Connection |
conn
The connection on which the operations are performed. |
private java.util.Random |
random
Random number generator. |
private java.sql.PreparedStatement |
retrieveAccountBalance
Statement that retrieves the current account balance. |
private int |
tellersPerBranch
The number of tellers per branch. |
private java.sql.PreparedStatement |
updateAccount
Statement that updates the balance of the account. |
private java.sql.PreparedStatement |
updateBranch
Statement that updated the balance of the branch. |
private java.sql.PreparedStatement |
updateHistory
Statement that updated the history table. |
private java.sql.PreparedStatement |
updateTeller
Statement that updates the balance of the teller. |
| Constructor Summary | |
|---|---|
BankTransactionClient(int scale)
Create a client that works on a database with the default number of tellers and accounts per branch. |
|
BankTransactionClient(int branches,
int tellersPerBranch,
int accountsPerBranch)
Create a client that works on a database with the given number of branches, tellers and accounts. |
|
| Method Summary | |
|---|---|
void |
doWork()
Perform a single transaction with a profile like the one specified in Clause 1.2 of the TPC-B specification. |
private int |
fetchAccountId(int branchId)
Generate a random account id based on the specified branch. |
private int |
fetchBranchId(int tellerId)
Find the branch the specified teller belongs to. |
private int |
fetchDelta()
Generate a random delta value between -99999 and +99999, both inclusive (TPC-B specification, Clause 5.3.6). |
private int |
fetchTellerId()
Generate a random teller id. |
void |
init(java.sql.Connection c)
Initialize the connection and the statements used by the test. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final java.util.Random random
private final int branches
private final int tellersPerBranch
private final int accountsPerBranch
private java.sql.Connection conn
private java.sql.PreparedStatement updateAccount
private java.sql.PreparedStatement updateHistory
private java.sql.PreparedStatement updateTeller
private java.sql.PreparedStatement updateBranch
private java.sql.PreparedStatement retrieveAccountBalance
| Constructor Detail |
|---|
public BankTransactionClient(int branches,
int tellersPerBranch,
int accountsPerBranch)
branches - the number of branches in the databasetellersPerBranch - the number of tellers per branchaccountsPerBranch - the number of accounts per branchpublic BankTransactionClient(int scale)
scale - the scale factor for the database (equal to the number of
branches)BankAccountFiller.BankAccountFiller(int)| Method Detail |
|---|
public void init(java.sql.Connection c)
throws java.sql.SQLException
init in interface Clientc - a connection which can be used by this client
java.sql.SQLException - if a database error occurs
public void doWork()
throws java.sql.SQLException
doWork in interface Clientjava.sql.SQLException - if a database error occursprivate int fetchTellerId()
private int fetchBranchId(int tellerId)
tellerId - the id of the teller
private int fetchAccountId(int branchId)
branchId - the id of the selected branch
private int fetchDelta()
|
Built on Thu 2009-11-26 18:42:53-0800, from revision 884739 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||