|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.derbyTesting.system.oe.load.SimpleInsert
org.apache.derbyTesting.system.oe.load.ThreadInsert
public class ThreadInsert
Multi-threaded version of SimpleInsert.
A number of threads execute the INSERT statements
(each with their own connection).
All the rows for a given warehouse are executed by
one thread. The threads each get a warehouse to
complete and then insert all the rows. Then they
loop back to get the next warehouse. Warehouses
are assigned to threads in a first come first served
fashion. The main thread also inserts the ITEM table.
By default the number of threads is the number
of cpus on the machine, unless the scale to be loaded
is larger than the number of threads. Then the number
of threads will be equal to the scale. If the scale
is one or the number of threads is one then the
load is just like SimpleInsert.
The number of threads can be set but if it
it larger than the scale then the number of threads
will be equal to the scale.
It is assumed that foreign key constraints are
created after the load.
| Field Summary | |
|---|---|
private javax.sql.DataSource |
ds
|
private java.sql.SQLException |
loadExceptions
|
private ThreadInsert |
master
The main ThreadInsert, created by the main thread and holds the valid nextWarehouse. |
private short |
nextWarehouse
Next warehouse that needs to be populated. |
private int |
threadCount
|
| Fields inherited from class org.apache.derbyTesting.system.oe.load.SimpleInsert |
|---|
conn, random, scale, seed |
| Fields inherited from interface org.apache.derbyTesting.system.oe.client.Load |
|---|
CUSTOMER_COUNT_W, DISTRICT_COUNT_W, HISTORY_COUNT_W, ITEM_COUNT, NEWORDERS_BREAKPOINT, NEWORDERS_COUNT_W, ORDERLINE_COUNT_WV, ORDERS_COUNT_W, STOCK_COUNT_W |
| Constructor Summary | |
|---|---|
|
ThreadInsert(javax.sql.DataSource ds)
Create a ThreadInsert loader. |
private |
ThreadInsert(ThreadInsert master)
|
| Method Summary | |
|---|---|
(package private) void |
addException(java.sql.SQLException sqle)
Save all the exceptions seen during load. |
(package private) short |
getNextWarehouse()
Get the next warehouse to populate. |
void |
populateAllTables()
Populate the database. |
void |
run()
Run the load for a thread. |
void |
setThreadCount(int threadCount)
Set the thread count. |
void |
setupLoad(java.sql.Connection conn,
short scale)
Initialize the load by calling the super-class's method and default the number of threads to the smaller of the number of cpus and the scale. |
private void |
threadPopulate()
Populate the database using multiple threads. |
| Methods inherited from class org.apache.derbyTesting.system.oe.load.SimpleInsert |
|---|
customerTable, districtTable, itemTable, orderTable, populateForOneWarehouse, setRandomGenerator, setSeed, setupConnection, stockTable, warehouseTable |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final ThreadInsert master
private java.sql.SQLException loadExceptions
private int threadCount
private javax.sql.DataSource ds
private short nextWarehouse
| Constructor Detail |
|---|
public ThreadInsert(javax.sql.DataSource ds)
ds - getConnection() will be used to create connections
for the spaened threads.private ThreadInsert(ThreadInsert master)
| Method Detail |
|---|
public void setupLoad(java.sql.Connection conn,
short scale)
throws java.sql.SQLException
setupLoad in interface LoadsetupLoad in class SimpleInsertconn - -
database connectionscale - -
scale of the database. The WAREHOUSE table is used as the base
unit of scaling.
java.sql.SQLExceptionpublic void setThreadCount(int threadCount)
setThreadCount in interface LoadsetThreadCount in class SimpleInsertthreadCount - Number of threads to use if loading supports
multiple threading.
public void populateAllTables()
throws java.lang.Exception
populateAllTables in interface LoadpopulateAllTables in class SimpleInsertjava.sql.SQLException
java.lang.Exception
private void threadPopulate()
throws java.sql.SQLException,
java.lang.InterruptedException
java.sql.SQLException
java.lang.InterruptedExceptionshort getNextWarehouse()
void addException(java.sql.SQLException sqle)
public void run()
run in interface java.lang.Runnable
|
Built on Sat 2009-11-28 18:44:18-0800, from revision 885187 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||