commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r558551 - in /jakarta/commons/sandbox/performance/trunk: ./ src/java/org/apache/commons/performance/ src/java/org/apache/commons/performance/dbcp/
Date Sun, 22 Jul 2007 21:19:53 GMT
Author: psteitz
Date: Sun Jul 22 14:19:48 2007
New Revision: 558551

URL: http://svn.apache.org/viewvc?view=rev&rev=558551
Log:
Moved ConfigurationException to performance package
Renamed build.xml, config.xml to *-dbcp
Made peak and min mean load both configurable
Fixed some errors in ClientThread delay method

Added:
    jakarta/commons/sandbox/performance/trunk/build-dbcp.xml
      - copied unchanged from r557160, jakarta/commons/sandbox/performance/trunk/build.xml
    jakarta/commons/sandbox/performance/trunk/config-dbcp.xml
      - copied, changed from r557160, jakarta/commons/sandbox/performance/trunk/config.xml
    jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ConfigurationException.java
Removed:
    jakarta/commons/sandbox/performance/trunk/build.xml
    jakarta/commons/sandbox/performance/trunk/config.xml
    jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/ConfigurationException.java
Modified:
    jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ClientThread.java
    jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPClientThread.java
    jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java

Copied: jakarta/commons/sandbox/performance/trunk/config-dbcp.xml (from r557160, jakarta/commons/sandbox/performance/trunk/config.xml)
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/performance/trunk/config-dbcp.xml?view=diff&rev=558551&p1=jakarta/commons/sandbox/performance/trunk/config.xml&r1=557160&p2=jakarta/commons/sandbox/performance/trunk/config-dbcp.xml&r2=558551
==============================================================================
--- jakarta/commons/sandbox/performance/trunk/config.xml (original)
+++ jakarta/commons/sandbox/performance/trunk/config-dbcp.xml Sun Jul 22 14:19:48 2007
@@ -72,7 +72,8 @@
     <query-type>integerIndexed</query-type>
     <iterations>1000</iterations>
     <clients>50</clients>
-    <delay-mean>250</delay-mean>
+    <delay-min>250</delay-min>
+    <delay-max>500</delay-max>
     <delay-sigma>50</delay-sigma>
     <!-- constant, gaussian, or poisson -->
     <delay-type>gaussian</delay-type>

Modified: jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ClientThread.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ClientThread.java?view=diff&rev=558551&r1=558550&r2=558551
==============================================================================
--- jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ClientThread.java
(original)
+++ jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ClientThread.java
Sun Jul 22 14:19:48 2007
@@ -36,8 +36,10 @@
 
     /** Number of iterations */
     protected long iterations;
-    /** Mean time between requests */
-    protected long delay;
+    /** Minimum mean time between requests */
+    protected long minDelay;
+    /** Maxiimum mean time between requests */
+    protected long maxDelay;
     /** Standard deviation of delay distribution */
     protected double sigma;
     /** Delay type - determines how next start times are computed */
@@ -67,19 +69,21 @@
      * Create a client thread.
      * 
      * @param iterations number of iterations
-     * @param delay mean time between client requests
+     * @param minDelay minumum mean time between client requests
+     * @param maxDelay maximum mean time between client requests
      * @param delayType distribution of time between client requests
      * @param period period of cycle for cyclic load
      * @param cycleType type of cycle for mean delay
      * @param logger common logger shared by all clients
      * @param statsList List of SummaryStatistics to add results to
      */
-    public ClientThread(long iterations, long delay, double sigma, 
-            String delayType, long period, String cycleType,
-            String rampType, Logger logger, 
+    public ClientThread(long iterations, long minDelay, long maxDelay,
+            double sigma, String delayType, long period, String cycleType,
+            String rampType, Logger logger,
             List <SummaryStatistics> statsList) {
         this.iterations = iterations;
-        this.delay = delay;
+        this.minDelay = minDelay;
+        this.maxDelay = maxDelay;
         this.sigma = sigma;
         this.delayType = delayType;
         this.period = period;
@@ -105,7 +109,7 @@
         SummaryStatistics stats = new SummaryStatisticsImpl();
         randomData = new RandomDataImpl();
         periodStart = System.currentTimeMillis();
-        lastMean = (double) (2 * delay); // Ramp up, if any, starts here
+        lastMean = (double) maxDelay; // Ramp up, if any, starts here
         for (int i = 0; i < iterations; i++) {
             try {
                 setup();
@@ -163,24 +167,24 @@
     
     /**
      * <p>Computes the next interarrival time (time to wait between requests)
-     * based on configured values for mean delay, delay type, cycle type, 
+     * based on configured values for min/max delay, delay type, cycle type, 
      * ramp type and period.
      * </p>
-     * <p>Currently supports constant (just returning mean delay time), Poisson
-     * and Gaussian distributed random time delays, linear and random ramps,
-     * and oscillating / non-oscillating cycle types.
+     * <p>Currently supports constant (always returning minDelay delay time),
+     * Poisson and Gaussian distributed random time delays, linear and random
+     * ramps, and oscillating / non-oscillating cycle types.
      * </p>
-     * <p>If delayType = "constant" the configured delay mean is always returned.
-     * If delayType is "gaussian" or "exponential" and cycleType is "none",
+     * <p>If delayType = "constant" the configured minDelay is always returned.
+     * If delayType is "gaussian" or "poisson" and cycleType is "none",
      * random deviates with the configured parameters are returned.
      * </p>
      * <p>If delayType is not "constant" and cycleType is "oscillating", means
-     * of random deviates ramp up and down between delay and twice delay. Ramp
+     * of random deviates ramp up and down between minDelay and maxDelay. Ramp
      * type is controlled by rampType.  Linear rampType means the means
      * increase or decrease linearly over the time of the period.  Random
      * makes random jumps up or down toward the next peak or trough. "None" for
-     * rampType under oscillating cycleType makes the means alternate bttween
-     * peak (delay) and trough (twice delay) with no ramp between.
+     * rampType under oscillating cycleType makes the means alternate between
+     * peak (minDelay) and trough (maxDelay) with no ramp between.
      * </p>
      * <p>For non-oscillating, non-constant runs, linear and random rampTypes
      * work similarly, but over just one ramp up period at the beginning of
@@ -195,67 +199,67 @@
         double mean = 0;
         if (delayType.equals("constant")) { 
             //TODO: should support single ramp up to constant
-            return delay;
+            return minDelay;
         } else { // delay not constant, use random variate
-            
             // Determine mean to use 
-            double doubleDelay = (double) delay;
-            double top = 2d * doubleDelay; // delay is peak, ramp starts at top
+            double dMinDelay = (double) minDelay;
+            double dMaxDelay = (double) maxDelay;
+            double delayDifference = dMaxDelay - dMinDelay;
             if (cycleType.equals("none")) {
                 if (rampType.equals("none") || 
-                        (currentTime - startTime) > period) { 
-                    // use configured mean
-                    mean = doubleDelay;
+                        (currentTime - startTime) > period) { // ramped up
+                    mean = dMinDelay;
                 } else if (rampType.equals("linear")) { // single period linear
-                    double prop = (double) (currentTime - startTime) / period ;
-                    mean =  top - doubleDelay * prop;
+                    double prop = 
+                        (double) (currentTime - startTime) / (double) period;
+                    mean =  dMaxDelay - delayDifference * prop;
                 } else { // Random jumps down to delay - single period
-                    // Where we last were as proportion of way down to delay
+                    // TODO: govern size of jumps as in oscillating
+                    // Where we last were as proportion of way down to minDelay
                     double lastProp = 
-                        (top - lastMean) / doubleDelay;
+                        (dMaxDelay - lastMean) / delayDifference;
                     // Make a random jump toward 1 (1 = all the way down)
                     double prop = randomData.nextUniform(lastProp, 1);
-                    mean = top - doubleDelay * prop;
+                    mean = dMaxDelay - delayDifference * prop;
                 }
             } else if (cycleType.equals("oscillating")) {
                 // First check if we need to change directions
                 if ((currentTime - periodStart) >= period) {
                     if (rampingUp) {
                         rampingUp = false;
-                        lastMean = doubleDelay;
+                        lastMean = dMinDelay;
                     } else {
                         rampingUp = true;
-                        lastMean = top;
+                        lastMean = dMaxDelay;
                     }
                     periodStart = currentTime;
                 }
-                if (rampType.equals("none")) { // mean or twice mean, no ramp
+                if (rampType.equals("none")) { // minDelay or maxDelay, no ramp
                     if (rampingUp) {
-                        mean = top;
+                        mean = dMaxDelay;
                     } else {
-                        mean = doubleDelay;
+                        mean = dMinDelay;
                     }
                 } else if (rampType.equals("linear")) { // ramp down, then up
                     double prop = 
                         (double)(currentTime - periodStart) / (double) period;
                     if (rampingUp) {
-                        mean =  top - doubleDelay * prop; 
+                        mean =  dMaxDelay - delayDifference * prop; 
                     } else {
-                        mean = doubleDelay + doubleDelay * prop;
+                        mean = dMinDelay + delayDifference * prop;
                     }
                 } else { // random jumps down, then back up
-                    // Where we last were as proportion of way down to delay
+                    // Where we last were as proportion of way down to minDelay
                     double lastProp = 
-                        (top - lastMean) / doubleDelay;
+                        (dMaxDelay - lastMean) / delayDifference;
                     // Where we would be if this were a linear ramp
                     double linearProp = 
                         (double)(currentTime - periodStart) / (double) period;
                     // Need to govern size of jumps, otherwise "convergence"
                     // can be too fast - use linear ramp as governor
                     if ((rampingUp && (lastProp > linearProp)) || 
-                       (!rampingUp && (lastProp < linearProp))) { // Slow down
-                        lastProp = linearProp;
-                    }
+                            (!rampingUp && ((1 - lastProp) > linearProp))) 
+                        lastProp = rampingUp ? linearProp : (1 - linearProp);
                     double prop = 0;
                     if (rampingUp) { // Random jump toward 1
                         prop = randomData.nextUniform(lastProp, 1);
@@ -264,23 +268,24 @@
                     }
                     // Make sure sequence is monotone
                     if (rampingUp) {
-                        mean = Math.min(lastMean, top - doubleDelay * prop);
+                        mean = Math.min(lastMean, 
+                                maxDelay - delayDifference * prop);
                     } else {
-                        mean = Math.max(lastMean, top - doubleDelay * prop);
+                        mean = Math.max(lastMean, 
+                                minDelay + delayDifference * prop);
                     }
                 }
             }
-            
+
             // Remember last mean for ramp up / down
             lastMean = mean;
-            
+
             // Generate and return random deviate
             if (delayType.equals("gaussian")) {
                 return Math.round(randomData.nextGaussian(mean, sigma));
             } else { // must be Poisson
                 return Math.round(randomData.nextPoisson(mean));
             }
-        }  
+        } 
     }
-
 }

Added: jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ConfigurationException.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ConfigurationException.java?view=auto&rev=558551
==============================================================================
--- jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ConfigurationException.java
(added)
+++ jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/ConfigurationException.java
Sun Jul 22 14:19:48 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+package org.apache.commons.performance;
+
+public class ConfigurationException extends Exception {
+
+    public ConfigurationException() {
+        super();
+    }
+
+    public ConfigurationException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    public ConfigurationException(String arg0) {
+        super(arg0);
+    }
+
+    public ConfigurationException(Throwable arg0) {
+        super(arg0);
+    }
+
+}

Modified: jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPClientThread.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPClientThread.java?view=diff&rev=558551&r1=558550&r2=558551
==============================================================================
--- jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPClientThread.java
(original)
+++ jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPClientThread.java
Sun Jul 22 14:19:48 2007
@@ -59,12 +59,12 @@
      * @param dataSource DataSource for connections
      * @param statsList List of SummaryStatistics to add results to
      */
-    public DBCPClientThread(long iterations, long delay, double sigma, 
-            String delayType, String queryType, long period, String cycleType,
-            String rampType, Logger logger, DataSource dataSource,
-            List <SummaryStatistics> statsList) {
+    public DBCPClientThread(long iterations, long minDelay, long maxDelay,
+            double sigma, String delayType, String queryType, long period,
+            String cycleType, String rampType, Logger logger, 
+            DataSource dataSource,List <SummaryStatistics> statsList) {
         
-        super(iterations, delay, sigma, delayType, period, cycleType,
+        super(iterations, minDelay, maxDelay, sigma, delayType, period, cycleType,
                 rampType, logger, statsList);
         
         this.dataSource = dataSource;

Modified: jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java?view=diff&rev=558551&r1=558550&r2=558551
==============================================================================
--- jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java
(original)
+++ jakarta/commons/sandbox/performance/trunk/src/java/org/apache/commons/performance/dbcp/DBCPSoak.java
Sun Jul 22 14:19:48 2007
@@ -16,6 +16,8 @@
  */
 
 package org.apache.commons.performance.dbcp;
+
+import org.apache.commons.performance.ConfigurationException;
 import java.sql.Connection;
 import java.sql.Driver;
 import java.sql.DriverManager;
@@ -74,7 +76,8 @@
     private int maxIdle;
     private int minIdle;
     private long maxWait;
-    private long delay;
+    private long minDelay;
+    private long maxDelay;
     private double sigma;
     private String delayType;
     private String queryType;
@@ -181,9 +184,9 @@
         // Spawn and execute client threads
 		ExecutorService ex = Executors.newFixedThreadPool((int)numClients);
 		for (int i = 0; i < numClients; i++) {
-			ex.execute(new DBCPClientThread(iterations, delay, sigma, delayType,
-                    queryType, period, cycleType, rampType, logger,
-                    dataSource, statsList));
+			ex.execute(new DBCPClientThread(iterations, minDelay, maxDelay,
+                    sigma, delayType, queryType, period, cycleType, rampType,
+                    logger, dataSource, statsList));
 		} 
         ex.shutdown();
         // hard time limit of one day for now 
@@ -274,13 +277,15 @@
     }
     
     public void configureRun(String queryType, String iterations,
-            String clients, String delay, String sigma, String delayType,
-            String rampType, String period, String cycleType) 
+            String clients, String minDelay, String maxDelay, String sigma,
+            String delayType, String rampType, String period, String cycleType) 
             throws ConfigurationException {
+     
         this.queryType = queryType;
         this.iterations = Long.parseLong(iterations);
         this.numClients = Long.parseLong(clients);
-        this.delay = Long.parseLong(delay);
+        this.minDelay = Long.parseLong(minDelay);
+        this.maxDelay = Long.parseLong(maxDelay);
         this.sigma = Double.parseDouble(sigma);
         this.delayType = delayType;
         this.rampType = rampType;
@@ -380,7 +385,7 @@
                 "configuration/pool/type", 11);
         
         digester.addCallMethod("configuration/run", 
-                "configureRun", 9);
+                "configureRun", 10);
         digester.addCallParam(
                 "configuration/run/query-type", 0);
         digester.addCallParam(
@@ -388,17 +393,19 @@
         digester.addCallParam(
                 "configuration/run/clients", 2);
         digester.addCallParam(
-                "configuration/run/delay-mean", 3);
+                "configuration/run/delay-min", 3);
+        digester.addCallParam(
+                "configuration/run/delay-max", 4);
         digester.addCallParam(
-                "configuration/run/delay-sigma", 4);
+                "configuration/run/delay-sigma", 5);
         digester.addCallParam(
-                "configuration/run/delay-type", 5);
+                "configuration/run/delay-type", 6);
         digester.addCallParam(
-                "configuration/run/ramp-type", 6);
+                "configuration/run/ramp-type", 7);
         digester.addCallParam(
-                "configuration/run/period", 7);
+                "configuration/run/period", 8);
         digester.addCallParam(
-                "configuration/run/cycle-type", 8);
+                "configuration/run/cycle-type", 9);
         
         digester.addCallMethod("configuration/abandoned-config",
                 "configureAbandonedConfig", 3);
@@ -409,7 +416,7 @@
         digester.addCallParam(
                 "configuration/abandoned-config/abandoned-timeout", 2);
         
-        digester.parse("/home/phil/dbcpTest/config.xml");
+        digester.parse("config-dbcp.xml");
         
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message