db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r575382 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe: client/Submitter.java direct/Standard.java schema/altindex.sql
Date Thu, 13 Sep 2007 17:50:55 GMT
Author: djd
Date: Thu Sep 13 10:50:54 2007
New Revision: 575382

URL: http://svn.apache.org/viewvc?rev=575382&view=rev
Log:
Add some utility methods for the oe system test framework and implement the submitter logic
for the new order transaction

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/schema/altindex.sql
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Submitter.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/direct/Standard.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Submitter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Submitter.java?rev=575382&r1=575381&r2=575382&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Submitter.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Submitter.java
Thu Sep 13 10:50:54 2007
@@ -112,7 +112,7 @@
      * Generate a new random number generator
      * that follows the rules according to 2.1.6.1
      * @param conn
-     * @return random number generator
+     * @return
      * @throws SQLException
      */
     public static OERandom getRuntimeRandom(Connection conn)
@@ -141,10 +141,111 @@
         
         return rand;
     }
-
+    
+    /**
+     * Return a Submitter than only executes stock level transactions.
+     */
+    public static Submitter stockLevelOnly(Display display,
+    		Operations ops, OERandom rand,
+            short maxW)
+    {
+    	return new Submitter(display, ops, rand, maxW)
+		{
+			protected int mixType(final int chooseType)
+			{
+				return Submitter.STOCK_LEVEL;
+			}
+		};  	
+    }
+    /**
+     * Return a Submitter than only executes order
+     * status by identifier transactions.
+     */
+    public static Submitter orderStatusByIdOnly(Display display,
+    		Operations ops, OERandom rand,
+            short maxW)
+    {
+    	return new Submitter(display, ops, rand, maxW)
+		{
+			protected int mixType(final int chooseType)
+			{
+				return Submitter.ORDER_STATUS_BY_ID;
+			}
+		};  	
+    }
+    /**
+     * Return a Submitter than only executes order
+     * status by name transactions.
+     */
+    public static Submitter orderStatusByNameOnly(Display display,
+    		Operations ops, OERandom rand,
+            short maxW)
+    {
+    	return new Submitter(display, ops, rand, maxW)
+		{
+			protected int mixType(final int chooseType)
+			{
+				return Submitter.ORDER_STATUS_BY_NAME;
+			}
+		};  	
+    }    
+    /**
+     * Return a Submitter than only executes payment
+     * by identifier transactions.
+     */
+    public static Submitter paymentByIdOnly(Display display,
+    		Operations ops, OERandom rand,
+            short maxW)
+    {
+    	return new Submitter(display, ops, rand, maxW)
+		{
+			protected int mixType(final int chooseType)
+			{
+				return Submitter.PAYMENT_BY_ID;
+			}
+		};  	
+    }
+    /**
+     * Return a Submitter than only executes payment
+     * by name transactions.
+     */
+    public static Submitter paymentByNameOnly(Display display,
+    		Operations ops, OERandom rand,
+            short maxW)
+    {
+    	return new Submitter(display, ops, rand, maxW)
+		{
+			protected int mixType(final int chooseType)
+			{
+				return Submitter.PAYMENT_BY_NAME;
+			}
+		};  	
+    }    
+    /**
+     * Return a Submitter than only executes new order
+     * transactions with no rollback
+     */
+    public static Submitter newOrderOnly(Display display,
+    		Operations ops, OERandom rand,
+            short maxW)
+    {
+    	return new Submitter(display, ops, rand, maxW)
+		{
+			protected int mixType(final int chooseType)
+			{
+				return Submitter.NEW_ORDER;
+			}
+		};  	
+    }        
+    
+    /**
+     * Create a submitter that has a fixed mix of transactions
+     * at input time.
+     * 
+     * @see Submitter#mixType(int)
+     */
     public Submitter(Display display, Operations ops, OERandom rand,
             short maxW)
-        throws Exception
     {
         this.display = display;
         this.ops = ops;
@@ -255,8 +356,54 @@
         }
     }
     
-    protected void runNewOrder(Object displayData, boolean forRollback) {
-        // TODO Auto-generated method stub
+    protected void runNewOrder(Object displayData, boolean forRollback)
+        throws Exception
+   {
+    	short homeWarehouse = warehouse();
+    	
+    	final int orderItemCount = rand.randomInt(5, 15);
+    	
+    	int[] items = new int[orderItemCount];
+    	short[] quantities = new short[orderItemCount];
+    	short[] supplyW = new short[orderItemCount];
+    	
+    	for (int i = 0; i < orderItemCount; i++)
+    	{
+    		// Section 2.4.1.5
+    		
+    		// 1)
+    		items[i] = rand.NURand8191();
+    		
+    		// 2)
+    		if (maxW == 1 || rand.randomInt(1, 100) > 1)
+    		{
+    			supplyW[i] = homeWarehouse;
+    		}
+    		else
+    		{
+    			short sw = warehouse();
+    			while (sw == homeWarehouse)
+    				sw = warehouse();
+    			supplyW[i] = sw;
+    		}
+    		supplyW[i] = rand.randomInt(1, 100) > 1 ?
+    				homeWarehouse : warehouse();
+    		
+    		// 3) 
+    		quantities[i] = (short) rand.randomInt(1, 10);
+    	}
+    	
+    	// Section 2.4.1.4
+    	if (forRollback)
+    	{
+    		items[orderItemCount] = 2334432;
+    	}
+    	
+        ops.newOrder(display, displayData,
+        		homeWarehouse, rand.district(),
+        		rand.NURand1023(),
+        		items, quantities, supplyW);
+        		
     }
 
     protected void runScheduleDelivery(Object displayData) {
@@ -290,6 +437,8 @@
      * @return a random warehouse
      */
     private final short warehouse() {
+    	if (maxW == 1)
+    		return 1;
         return (short) rand.randomInt(1, maxW);
     }
 
@@ -341,6 +490,8 @@
 
         out.println(transactionCount("New Order         ", noTotal, total));        
         out.println(transactionCount("Payment           ",  pyCount, total));
+        out.println(transactionCount("    By Name       ",  transactionCount[PAYMENT_BY_NAME],
total));
+        out.println(transactionCount("    By Identifier ",  transactionCount[PAYMENT_BY_ID],
total));
         out.println(transactionCount("Order Status      ",  osCount, total));
         out.println(transactionCount("    By Name       ",  transactionCount[ORDER_STATUS_BY_NAME],
total));
         out.println(transactionCount("    By Identifier ",  transactionCount[ORDER_STATUS_BY_ID],
total));

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/direct/Standard.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/direct/Standard.java?rev=575382&r1=575381&r2=575382&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/direct/Standard.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/direct/Standard.java
Thu Sep 13 10:50:54 2007
@@ -70,6 +70,25 @@
     }
     
     /**
+     * Return an Operations implementation based upon
+     * Standard with a single difference. In this implementation
+     * the reset() executed after each PreparedStatement execute
+     * does nothing. Sees if there is any performance impact
+     * of explicitly closing each ResultSet and clearing the
+     * parameters.
+     * <P>
+     * Each ResultSet will be closed implicitly either at commit
+     * time or at the next execution of the same PreparedStatement object.
+     */
+    public static Operations noReset(final Connection conn)
+        throws SQLException
+    {
+        return new Standard(conn) {
+            protected void reset(PreparedStatement ps) {}
+        };
+    }
+    
+    /**
      * Map of SQL text to its PreparedStatement.
      * This allows the SQL text to be in-line with
      * code that sets the parameters and looks at 
@@ -579,7 +598,6 @@
         // provide a different implementation of this class with
         // the sort method a no-op.
         sortOrderItems(items, quantities, supplyW);
-
         
         try {
             // Get the warehouse tax
@@ -587,6 +605,7 @@
                 "SELECT W_TAX FROM WAREHOUSE WHERE W_ID = ?");
             psWarehouseTax.setShort(1, w);
             ResultSet rs = psWarehouseTax.executeQuery();
+            rs.next();
             BigDecimal warehouseTax = (BigDecimal) rs.getObject(1);
             reset(psWarehouseTax);
             
@@ -929,22 +948,12 @@
      * It is assumed the prepared statement was just executed.
      * @throws SQLException 
      */
-    private static void reset(PreparedStatement ps) throws SQLException
+    protected void reset(PreparedStatement ps) throws SQLException
     {
         ResultSet rs = ps.getResultSet();
         if (rs != null)
             rs.close();
         ps.clearParameters();
-    }
-    
-    /**
-     * Close a PreparedStatement if it was opened.
-     */
-    private static void close(PreparedStatement ps)
-       throws SQLException
-    {
-        if (ps != null)
-            ps.close();
     }
     
     private Address getAddress(ResultSet rs, String firstColumnName) throws SQLException

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/schema/altindex.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/schema/altindex.sql?rev=575382&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/schema/altindex.sql
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/schema/altindex.sql
Thu Sep 13 10:50:54 2007
@@ -0,0 +1,23 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--    http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+;
+
+-- Indexes for the oe transactions when foreign key
+-- constraints are not created or the creation of
+-- foreign key constraints do not automatically create
+-- backing indexes (e.g. not Derby).
+
+-- Required to quickly find the most recent order for a customer
+CREATE INDEX ORDERS_CUSTOMER_STATUS ON ORDERS(O_W_ID, O_D_ID, O_C_ID);

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/schema/altindex.sql
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message