incubator-olio-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject svn commit: r745184 [1/3] - in /incubator/olio/workload/php/trunk: ./ bin/ deploy/ src/org/ src/org/apache/ src/org/apache/olio/ src/org/apache/olio/workload/ src/org/apache/olio/workload/driver/ src/org/apache/olio/workload/fsloader/ src/org/apache/ol...
Date Tue, 17 Feb 2009 18:25:44 GMT
Author: shanti
Date: Tue Feb 17 18:25:43 2009
New Revision: 745184

URL: http://svn.apache.org/viewvc?rev=745184&view=rev
Log:
More fixes for OLIO-13.
All scripts changed to use correct package names.
Hanress hook renamed to OlioBenchmark.
The driver is now 'olio' instead of 'web20'
For now, the dbname and user/password remain as web20load and web20/web20 to
maintain compatibility with existing databases.

Added:
    incubator/olio/workload/php/trunk/src/org/   (props changed)
      - copied from r741658, incubator/olio/workload/php/trunk/src/com/
    incubator/olio/workload/php/trunk/src/org/apache/   (props changed)
      - copied from r741658, incubator/olio/workload/php/trunk/src/com/sun/
    incubator/olio/workload/php/trunk/src/org/apache/olio/
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/   (with props)
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/driver/   (with props)
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/driver/UIDriver.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/fsloader/   (with props)
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/fsloader/FileLoader.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/harness/   (with props)
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/harness/OlioBenchmark.java   (with props)
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/   (with props)
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Address.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Attendees.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Comments.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/EventTag.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Friends.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/LoadController.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Person.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/SocialEvent.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Tag.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/framework/
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/framework/Loadable.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/framework/LoadablePool.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/framework/Loader.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/framework/ThreadConnection.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/framework/ThreadResource.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/olio/
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/util/   (with props)
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/util/GrowthTest.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/util/MemCacheUtility.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/util/RandomUtil.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/util/ScaleFactors.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/util/Scramble.java
    incubator/olio/workload/php/trunk/src/org/apache/olio/workload/util/UserName.java
Removed:
    incubator/olio/workload/php/trunk/src/org/apache/web20/
    incubator/olio/workload/php/trunk/src/org/sun/
Modified:
    incubator/olio/workload/php/trunk/bin/dbloader.sh
    incubator/olio/workload/php/trunk/bin/drop.sql
    incubator/olio/workload/php/trunk/bin/fileloader.rb
    incubator/olio/workload/php/trunk/bin/fileloader.sh
    incubator/olio/workload/php/trunk/bin/loader.pl
    incubator/olio/workload/php/trunk/bin/schema.sql
    incubator/olio/workload/php/trunk/build.properties.template
    incubator/olio/workload/php/trunk/deploy/benchmark.xml
    incubator/olio/workload/php/trunk/deploy/config.xhtml
    incubator/olio/workload/php/trunk/deploy/run.xml

Modified: incubator/olio/workload/php/trunk/bin/dbloader.sh
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/bin/dbloader.sh?rev=745184&r1=745183&r2=745184&view=diff
==============================================================================
--- incubator/olio/workload/php/trunk/bin/dbloader.sh (original)
+++ incubator/olio/workload/php/trunk/bin/dbloader.sh Tue Feb 17 18:25:43 2009
@@ -25,7 +25,7 @@
 
 BINDIR=`dirname $0`
 
-# This script is in $FABAN_HOME/benchmarks/Web20Driver/bin
+# This script is in $FABAN_HOME/benchmarks/OlioDriver/bin
 # we need to go up 4 levels to get to $FABAN_HOME.
 if [ -n "$BINDIR" ]
 then
@@ -36,12 +36,12 @@
 
 B=$BENCH_HOME/lib
 L=$FABAN_HOME/lib
-CLASSPATH=$B/mysql-connector-java-5.0.6-bin.jar:$B/json.jar:$B/Web20Driver.jar:\
+CLASSPATH=$B/mysql-connector-java-5.0.6-bin.jar:$B/json.jar:$B/OlioDriver.jar:\
 $L/commons-httpclient-2.0.1.jar:$L/fabancommon.jar:$L/commons-logging.jar:\
 $L/fabandriver.jar:$L/fabanagents.jar
 export CLASSPATH
 
-$JAVA_HOME/bin/java -server com.sun.web20.loader.LoadController com.mysql.jdbc.Driver \
+$JAVA_HOME/bin/java -server org.apache.olio.workload.loader.LoadController com.mysql.jdbc.Driver \
 "jdbc:mysql://$DB_HOST/web20load?user=web20&password=web20&relaxAutoCommit=true&sessionVariables=FOREIGN_KEY_CHECKS=0" $SCALE
 EXIT_CODE=$?
 if [ "$EXIT_CODE" = 0 ] ; then

Modified: incubator/olio/workload/php/trunk/bin/drop.sql
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/bin/drop.sql?rev=745184&r1=745183&r2=745184&view=diff
==============================================================================
--- incubator/olio/workload/php/trunk/bin/drop.sql (original)
+++ incubator/olio/workload/php/trunk/bin/drop.sql Tue Feb 17 18:25:43 2009
@@ -1,7 +1,3 @@
--- Copyright ?? 2008 Sun Microsystems, Inc. All rights reserved
---
--- Use is subject to license terms.
---
 -- $Id: drop.sql,v 1.1.1.1 2008/09/29 22:33:07 sp208304 Exp $
 
 drop table PERSON_PERSON;

Modified: incubator/olio/workload/php/trunk/bin/fileloader.rb
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/bin/fileloader.rb?rev=745184&r1=745183&r2=745184&view=diff
==============================================================================
--- incubator/olio/workload/php/trunk/bin/fileloader.rb (original)
+++ incubator/olio/workload/php/trunk/bin/fileloader.rb Tue Feb 17 18:25:43 2009
@@ -1,10 +1,8 @@
 #!/opt/coolstack/bin/ruby
 ##############################################################
-#  Copyright ?? 2008 Sun Microsystems, Inc. All rights reserved
-#
-#  Use is subject to license terms.
-#
 #  $Id: fileloader.rb,v 1.1.1.1 2008/09/29 22:33:07 sp208304 Exp $
+#
+# Needs to be updated. 
 ##############################################################
 
  if ARGV.size != 1 then

Modified: incubator/olio/workload/php/trunk/bin/fileloader.sh
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/bin/fileloader.sh?rev=745184&r1=745183&r2=745184&view=diff
==============================================================================
--- incubator/olio/workload/php/trunk/bin/fileloader.sh (original)
+++ incubator/olio/workload/php/trunk/bin/fileloader.sh Tue Feb 17 18:25:43 2009
@@ -29,7 +29,7 @@
 
 BINDIR=`dirname $0`
 
-# This script is in $FABAN_HOME/benchmarks/Web20Driver/bin
+# This script is in $FABAN_HOME/benchmarks/OlioDriver/bin
 # we need to go up 4 levels to get to $FABAN_HOME.
 if [ -n "$BINDIR" ]
 then
@@ -40,11 +40,11 @@
 
 B=$BENCH_HOME/lib
 L=$FABAN_HOME/lib
-CLASSPATH=$B/Web20Driver.jar:$L/commons-httpclient-2.0.1.jar:\
+CLASSPATH=$B/OlioDriver.jar:$L/commons-httpclient-2.0.1.jar:\
 $L/fabancommon.jar:$L/commons-logging.jar:$L/fabandriver.jar:$L/fabanagents.jar
 export CLASSPATH
 
-$JAVA_HOME/bin/java -server com.sun.web20.fsloader.FileLoader \
+$JAVA_HOME/bin/java -server org.apache.olio.workload.fsloader.FileLoader \
     $BENCH_HOME/resources $TARGET $SCALE
 
 EXIT_CODE=$?

Modified: incubator/olio/workload/php/trunk/bin/loader.pl
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/bin/loader.pl?rev=745184&r1=745183&r2=745184&view=diff
==============================================================================
--- incubator/olio/workload/php/trunk/bin/loader.pl (original)
+++ incubator/olio/workload/php/trunk/bin/loader.pl Tue Feb 17 18:25:43 2009
@@ -1,10 +1,9 @@
-#!/opt/coolstack/bin/perl
+#!/usr/bin/perl
 ##############################################################
-#  Copyright ?? 2008 Sun Microsystems, Inc. All rights reserved
-#
-#  Use is subject to license terms.
-#
 #  $Id: loader.pl,v 1.1.1.1 2008/09/29 22:33:07 sp208304 Exp $
+#
+# Loader for MogileFS.
+# This is outdated. Will be fixed when we add MogileFS code fully.
 ##############################################################
 
 use Getopt::Std;

Modified: incubator/olio/workload/php/trunk/bin/schema.sql
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/bin/schema.sql?rev=745184&r1=745183&r2=745184&view=diff
==============================================================================
--- incubator/olio/workload/php/trunk/bin/schema.sql (original)
+++ incubator/olio/workload/php/trunk/bin/schema.sql Tue Feb 17 18:25:43 2009
@@ -1,7 +1,3 @@
--- Copyright ?? 2008 Sun Microsystems, Inc. All rights reserved
---
--- Use is subject to license terms.
---
 -- $Id: schema.sql,v 1.1.1.1 2008/09/29 22:33:07 sp208304 Exp $
 
 create table PERSON(

Modified: incubator/olio/workload/php/trunk/build.properties.template
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/build.properties.template?rev=745184&r1=745183&r2=745184&view=diff
==============================================================================
--- incubator/olio/workload/php/trunk/build.properties.template (original)
+++ incubator/olio/workload/php/trunk/build.properties.template Tue Feb 17 18:25:43 2009
@@ -1,7 +1,7 @@
-bench.shortname=Web20Driver
-faban.home=/home/sp208304/Projects/faban
-faban.url=http://brazilian.sfbay:9980/
+bench.shortname=OlioDriver
+faban.home=/export/home/faban
+faban.url=http://host.sfbay:9980/
 deploy.user=deployer
 deploy.password=adminadmin
 deploy.clearconfig=false
-compiler.target.version=1.5
\ No newline at end of file
+compiler.target.version=1.5

Modified: incubator/olio/workload/php/trunk/deploy/benchmark.xml
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/deploy/benchmark.xml?rev=745184&r1=745183&r2=745184&view=diff
==============================================================================
--- incubator/olio/workload/php/trunk/deploy/benchmark.xml (original)
+++ incubator/olio/workload/php/trunk/deploy/benchmark.xml Tue Feb 17 18:25:43 2009
@@ -2,9 +2,9 @@
 <benchmark>
     <!-- Note: Most of these fields are not needed for a benchmark
     implemented using the Faban driver framework.
-    <name>Sample Web Workload1</name>
+    <name>Olio Workload</name>
     <version>0.1</version -->
     <config-form>config.xhtml</config-form>
     <config-file-name>run.xml</config-file-name>
-    <benchmark-class>com.sun.web20.harness.Web20Benchmark</benchmark-class>
+    <benchmark-class>org.apache.olio.workload.harness.OlioBenchmark</benchmark-class>
 </benchmark>

Modified: incubator/olio/workload/php/trunk/deploy/config.xhtml
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/deploy/config.xhtml?rev=745184&r1=745183&r2=745184&view=diff
==============================================================================
--- incubator/olio/workload/php/trunk/deploy/config.xhtml (original)
+++ incubator/olio/workload/php/trunk/deploy/config.xhtml Tue Feb 17 18:25:43 2009
@@ -11,7 +11,7 @@
         <xforms:model id="benchmark-model">
             <xforms:instance id="benchmark-instance" src="{benchmark.template}"/>
             <xforms:submission xforms:action="schedule-run.jsp" xforms:replace="all" id="submission-debug" xforms:method="post"/>
-            <xforms:bind id="bind-web20" xforms:nodeset="/web20">
+            <xforms:bind id="bind-olio" xforms:nodeset="/olio">
                 <xforms:bind id="bind-jvmConfig" xforms:nodeset="fh:jvmConfig">
                     <xforms:bind id="bind-javaHome" xforms:nodeset="fh:javaHome"/>
                     <xforms:bind id="bind-jvmOptions" xforms:nodeset="fh:jvmOptions"/>

Modified: incubator/olio/workload/php/trunk/deploy/run.xml
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/deploy/run.xml?rev=745184&r1=745183&r2=745184&view=diff
==============================================================================
--- incubator/olio/workload/php/trunk/deploy/run.xml (original)
+++ incubator/olio/workload/php/trunk/deploy/run.xml Tue Feb 17 18:25:43 2009
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<web20>
+<olio>
     <jvmConfig xmlns="http://faban.sunsource.net/ns/fabanharness">
         <javaHome>/apps/JVMs/jdk1.6.0_03</javaHome>
         <jvmOptions>-Xmx1g -Xms256m -XX:+DisableExplicitGC</jvmOptions>
     </jvmConfig>
     
-    <fa:runConfig definition="com.sun.web20.driver.UIDriver" xmlns="http://faban.sunsource.net/ns/fabandriver" xmlns:fa="http://faban.sunsource.net/ns/faban" xmlns:fh="http://faban.sunsource.net/ns/fabanharness">
+    <fa:runConfig definition="org.apache.olio.workload.driver.UIDriver" xmlns="http://faban.sunsource.net/ns/fabandriver" xmlns:fa="http://faban.sunsource.net/ns/faban" xmlns:fh="http://faban.sunsource.net/ns/fabanharness">
         <fh:description>Enter description for this run here</fh:description>
         
         <fa:hostConfig>
@@ -77,7 +77,7 @@
             <userCommands/>
         </fa:hostConfig>
         <dbDriver>com.mysql.jdbc.Driver</dbDriver>
-        <connectURL>jdbc:mysql://abhi/web20load?user=web20&amp;password=web20&amp;relaxAutoCommit=true&amp;sessionVariables=FOREIGN_KEY_CHECKS=0</connectURL>
+        <connectURL>jdbc:mysql://localhost/web20load?user=web20&amp;password=web20&amp;relaxAutoCommit=true&amp;sessionVariables=FOREIGN_KEY_CHECKS=0</connectURL>
         <autoCommit>true</autoCommit>
         <reloadDB>true</reloadDB>
         <scale>2000</scale>
@@ -118,4 +118,4 @@
         <serverList></serverList>
     </otherServers>
     -->
-</web20>
\ No newline at end of file
+</olio>

Propchange: incubator/olio/workload/php/trunk/src/org/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: incubator/olio/workload/php/trunk/src/org/apache/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/driver/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/driver/UIDriver.java
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/src/org/apache/olio/workload/driver/UIDriver.java?rev=745184&view=auto
==============================================================================
--- incubator/olio/workload/php/trunk/src/org/apache/olio/workload/driver/UIDriver.java (added)
+++ incubator/olio/workload/php/trunk/src/org/apache/olio/workload/driver/UIDriver.java Tue Feb 17 18:25:43 2009
@@ -0,0 +1,1021 @@
+/*
+ * 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.
+ * 
+ * $Id: UIDriver.java,v 1.1.1.1 2008/09/29 22:33:08 sp208304 Exp $
+ */ 
+package org.apache.olio.workload.driver;
+
+import com.sun.faban.common.NameValuePair;
+import com.sun.faban.common.Utilities;
+import com.sun.faban.driver.*;
+import org.apache.olio.workload.util.RandomUtil;
+import org.apache.olio.workload.util.ScaleFactors;
+import org.apache.olio.workload.util.UserName;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.MultipartPostMethod;
+
+import javax.xml.xpath.XPathExpressionException;
+import java.io.File;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.logging.Logger;
+
+@BenchmarkDefinition (
+    name    = "Web20Bench",
+    version = "0.4",
+    scaleName = "Concurrent Users"
+
+)
+@BenchmarkDriver (
+    name           = "UIDriver",
+    threadPerScale    = 1
+)
+        // 90/10 Read/Write ratio
+       
+@MatrixMix (
+//    operations = {"HomePage", "Login", , "TagSearch", "EventDetail", "PersonDetail",
+//                  "Logout", "AddEvent",  "AddPerson"},
+    operations = { "HomePage", "Login", "TagSearch", "EventDetail", "PersonDetail", "AddPerson", "AddEvent" },
+
+    mix = { @Row({  0, 11, 52, 36,  0, 1,  0 }),
+            @Row({  0,  0, 60, 20,  0, 0, 20 }),
+            @Row({ 21,  6, 41, 31,  0, 1,  0 }),
+            @Row({ 72, 21,  0,  0,  6, 1,  0 }),
+            @Row({ 52,  6,  0, 31, 11, 0,  0 }),
+            @Row({ 0, 0,  0,  0,  100, 0,  0 }),
+            @Row({  0,  0, 0, 100,  0, 0,  0 })
+          }
+)
+@NegativeExponential (
+    cycleType = CycleType.CYCLETIME,
+    cycleMean = 5000,
+    cycleDeviation = 2
+)
+
+public class UIDriver {
+
+    public static final String[] HOME_STATICS = {
+        "/js/tiny_mce/tiny_mce.js",
+        "/js/prototype.js",
+        "/js/effects.js",
+        "/js/dragdrop.js",
+        "/js/controls.js",
+        "/js/application.js",
+        "/css/scaffold.css",
+        "/css/site.css",
+        "/images/bg_main.png",
+        "/images/RSS-icon-large.gif",
+        "/images/php_bg_header.gif",
+        "/images/php_main_nav_link_bg.gif",
+        "/images/php_corner_top_right.gif",
+        "/images/php_corner_top_left.gif",
+        "/images/php_corner_bottom_right.gif",
+        "/images/php_corner_bottom_left.gif",
+        "/images/php_reflec_tile.gif",
+        "/images/php_reflec_right.gif",
+        "/images/php_reflec_left.gif",
+        "/images/php_main_nav_hover_bg.gif"
+    };
+
+    public static final String[] EVENTDETAIL_STATICS = {
+        "/images/php_main_nav_hover_bg.gif",
+        "/js/tiny_mce/tiny_mce.js",
+        "/js/prototype.js",
+        "/js/effects.js",
+        "/js/dragdrop.js",
+        "/js/controls.js",
+        "/js/application.js",
+        "/css/scaffold.css",
+        "/css/site.css",
+        "/images/bg_main.png",
+        "/images/RSS-icon-large.gif",
+        "/images/php_bg_header.gif",
+        "/images/php_main_nav_link_bg.gif",
+        "/js/starrating.js",
+        "/images/php_corner_top_right.gif",
+        "/images/php_corner_top_left.gif",
+        "/images/star_on.png",
+        "/images/star_off.png",
+        "/images/php_corner_bottom_right.gif",
+        "/images/php_corner_bottom_left.gif",
+        "/images/php_reflec_tile.gif",
+        "/images/php_reflec_right.gif",
+        "/images/php_reflec_left.gif"
+    };
+
+    public static final String[] ADDPERSON_STATICS = {
+        "/js/tiny_mce/tiny_mce.js",
+        "/js/prototype.js",
+        "/js/effects.js",
+        "/js/dragdrop.js",
+        "/js/controls.js",
+        "/js/application.js",
+        "/css/scaffold.css",
+        "/css/site.css",
+        "/images/bg_main.png",
+        "/images/RSS-icon-large.gif",
+        "/images/php_bg_header.gif",
+        "/images/php_main_nav_link_bg.gif",
+        "/js/validateform.js",
+        "/images/php_corner_top_right.gif",
+        "/images/php_corner_top_left.gif",
+        "/js/tiny_mce/themes/simple/editor_template.js",
+        "/js/tiny_mce/langs/en.js",
+        "/js/tiny_mce/themes/simple/css/editor_ui.css",
+        "/images/php_corner_bottom_right.gif",
+        "/images/php_corner_bottom_left.gif",
+        "/images/php_reflec_tile.gif",
+        "/images/php_reflec_right.gif",
+        "/images/php_reflec_left.gif",
+        "/js/tiny_mce/themes/simple/images/bold.gif",
+        "/js/tiny_mce/themes/simple/images/italic.gif",
+        "/js/tiny_mce/themes/simple/images/underline.gif",
+        "/js/tiny_mce/themes/simple/images/strikethrough.gif",
+        "/js/tiny_mce/themes/simple/images/separator.gif",
+        "/js/tiny_mce/themes/simple/images/undo.gif",
+        "/js/tiny_mce/themes/simple/images/redo.gif",
+        "/js/tiny_mce/themes/simple/images/cleanup.gif",
+        "/js/tiny_mce/themes/simple/images/bullist.gif",
+        "/js/tiny_mce/themes/simple/images/numlist.gif"
+    };
+
+    public static final String[] ADDEVENT_STATICS = {
+        "/js/tiny_mce/tiny_mce.js",
+        "/js/prototype.js",
+        "/js/effects.js",
+        "/js/dragdrop.js",
+        "/js/controls.js",
+        "/js/application.js",
+        "/css/scaffold.css",
+        "/css/site.css",
+        "/images/bg_main.png",
+        "/images/RSS-icon-large.gif",
+        "/images/php_bg_header.gif",
+        "/images/php_main_nav_link_bg.gif",
+        "/images/php_corner_top_right.gif",
+        "/images/php_corner_top_left.gif",
+        "/js/tiny_mce/themes/simple/editor_template.js",
+        "/js/tiny_mce/langs/en.js",
+        "/js/tiny_mce/themes/simple/css/editor_ui.css",
+        "/js/validateform.js",
+        "/images/php_corner_bottom_right.gif",
+        "/images/php_corner_bottom_left.gif",
+        "/images/php_reflec_tile.gif",
+        "/images/php_reflec_right.gif",
+        "/images/php_reflec_left.gif",
+        "/js/tiny_mce/themes/simple/images/bold.gif",
+        "/js/tiny_mce/themes/simple/images/italic.gif",
+        "/js/tiny_mce/themes/simple/images/underline.gif",
+        "/js/tiny_mce/themes/simple/images/strikethrough.gif",
+        "/js/tiny_mce/themes/simple/images/separator.gif",
+        "/js/tiny_mce/themes/simple/images/undo.gif",
+        "/js/tiny_mce/themes/simple/images/redo.gif",
+        "/js/tiny_mce/themes/simple/images/cleanup.gif",
+        "/js/tiny_mce/themes/simple/images/bullist.gif",
+        "/js/tiny_mce/themes/simple/images/numlist.gif"
+    };
+
+
+    public static final String[] PERSON_STATICS = {
+        "/js/tiny_mce/tiny_mce.js",
+        "/js/prototype.js",
+        "/js/effects.js",
+        "/js/dragdrop.js",
+        "/js/controls.js",
+        "/js/application.js",
+        "/css/scaffold.css",
+        "/css/site.css",
+        "/images/bg_main.png",
+        "/images/RSS-icon-large.gif",
+        "/images/php_bg_header.gif",
+        "/images/php_main_nav_link_bg.gif",
+        "/images/php_corner_top_right.gif",
+        "/images/php_corner_top_left.gif",
+        "/images/php_corner_bottom_right.gif",
+        "/images/php_corner_bottom_left.gif",
+        "/images/php_reflec_tile.gif",
+        "/images/php_reflec_right.gif",
+        "/images/php_reflec_left.gif"
+    };
+
+    
+
+    public static final String[] TAGSEARCH_STATICS = {
+        "/js/tiny_mce/tiny_mce.js",
+        "/js/prototype.js",
+        "/js/effects.js",
+        "/js/dragdrop.js",
+        "/js/controls.js",
+        "/js/application.js",
+        "/css/scaffold.css",
+        "/css/site.css",
+        "/images/bg_main.png",
+        "/images/RSS-icon-large.gif",
+        "/images/php_bg_header.gif",
+        "/images/php_main_nav_link_bg.gif",
+        "/images/php_corner_top_right.gif",
+        "/images/php_corner_top_left.gif",
+        "/images/php_corner_bottom_right.gif",
+        "/images/php_corner_bottom_left.gif",
+        "/images/php_reflec_tile.gif",
+        "/images/php_reflec_right.gif",
+        "/images/php_reflec_left.gif",
+        "/images/php_main_nav_hover_bg.gif"
+    };
+
+    // We just need today's date. java.sql.date does not have any time anyway.
+    public static final java.sql.Date BASE_DATE =
+                                new java.sql.Date(System.currentTimeMillis());
+
+    private DriverContext ctx;
+    private HttpTransport http;
+    private String baseURL;
+    private String personDetailURL;
+    private String tagSearchURL;
+    private String homepageURL, loginURL, logoutURL;
+    private String addEventURL, addPersonURL, eventDetailURL;
+    private String addEventResultURL, addPersonResultURL;
+    private String addAttendeeURL; //GET update.php?id=$eventid
+    // private String updatePageURL; //POST gettextafterinsert.php list=attendees
+    private String fileServiceURL;
+    private String[] homepageStatics, personStatics, personGets,
+    tagSearchStatics, eventDetailStatics, addPersonStatics, addEventStatics;
+    File eventImg, eventThumb, eventPdf, personImg, personThumb;
+    private boolean isLoggedOn = false;
+    private String username;
+    Logger logger;
+    private com.sun.faban.driver.util.Random random;
+    private DateFormat df;
+    private String selectedEvent;
+    private int personsAdded = 0;
+    private int loadedUsers;
+    private boolean isCached;
+    private HashSet<String> cachedURLs = new HashSet<String>();
+    private LinkedHashMap<String, String> loginHeaders =
+            new LinkedHashMap<String, String>();
+    private UIDriverMetrics driverMetrics;
+    private long imgBytes = 0;
+    private int imagesLoaded = 0;
+    private String tagCloudURL;
+    private StringBuilder tags = new StringBuilder();
+    private LinkedHashSet<Integer> tagSet = new LinkedHashSet<Integer>(7);
+
+    public UIDriver() throws XPathExpressionException {
+        ctx = DriverContext.getContext();
+        int scale = ctx.getScale();
+        ScaleFactors.setActiveUsers(scale);
+        http = new HttpTransport();
+        // http.setFollowRedirects(true);
+        logger = ctx.getLogger();
+        random = ctx.getRandom();
+        driverMetrics = new UIDriverMetrics();
+        ctx.attachMetrics(driverMetrics);
+        String hostPorts = ctx.getXPathValue(
+                                "/web20/webServer/fa:hostConfig/fa:hostPorts");
+        List<NameValuePair<Integer>> hostPortList =
+                                            Utilities.parseHostPorts(hostPorts);
+        int loadedScale = Integer.parseInt(
+                                    ctx.getXPathValue("/web20/dbServer/scale"));
+        loadedUsers = ScaleFactors.USERS_RATIO * loadedScale;
+        if (scale > loadedScale)
+            throw new FatalException("Data loaded only for " + loadedScale +
+                    " concurrent users. Run is set for " + scale +
+                    " concurrent users. Please load for enough concurrent " +
+                    "users. Run terminating!");
+
+        String type = ctx.getProperty("serverType");
+        String resourcePath = ctx.getResourceDir();
+        if (!resourcePath.endsWith(File.separator))
+            resourcePath += File.separator;
+        eventImg = new File(resourcePath + "event.jpg");
+        // logger.info("eventImg: " + eventImg);
+        eventThumb = new File(resourcePath + "event_thumb.jpg");
+        // logger.info("eventThumb: " + eventThumb);
+        eventPdf = new File(resourcePath + "event.pdf");
+        // logger.info("eventPdf: " + eventPdf);
+        personImg = new File(resourcePath + "person.jpg");
+        // logger.info("personImg: " + personImg);
+        personThumb = new File(resourcePath + "person_thumb.jpg");
+        // logger.info("personThumb: " + personThumb);
+
+        int bucket = Utilities.selectBucket(ctx.getThreadId(),
+                            ctx.getClientsInDriver(), hostPortList.size());
+        NameValuePair<Integer> hostPort = hostPortList.get(bucket);
+
+        if (hostPort.value == null)
+            baseURL = "http://" + hostPort.name;
+        else
+            baseURL = "http://" + hostPort.name + ':' + hostPort.value;
+
+        personDetailURL = baseURL + "/users." + type + "?username=";
+        tagSearchURL = baseURL + "/taggedEvents." + type;
+        tagCloudURL = baseURL + "/taggedEvents." + type;
+        addEventURL = baseURL + "/addEvent." + type;
+        addEventResultURL = baseURL + "/addEventResult." + type;
+        addPersonURL = baseURL + "/addPerson." + type;
+        addPersonResultURL = baseURL + "/addPersonResult." + type;
+        homepageURL = baseURL + "/index." + type;
+        loginURL = baseURL + "/login." + type;
+        logoutURL = baseURL + "/logout." + type;
+        addAttendeeURL = baseURL + "/addAttendee." + type + "?id=";
+        // updatePageURL = baseURL + "/gettextafterinsert." + type;
+        eventDetailURL = baseURL + "/events." + type + "?socialEventID=";
+        fileServiceURL = baseURL + "/fileService." + type + '?';
+
+        homepageStatics = populateList(HOME_STATICS);
+        personStatics = populateList(PERSON_STATICS);
+        tagSearchStatics = populateList(TAGSEARCH_STATICS);
+        eventDetailStatics = populateList(EVENTDETAIL_STATICS);
+        addPersonStatics = populateList(ADDPERSON_STATICS);
+        addEventStatics = populateList(ADDEVENT_STATICS);
+
+        if (hostPort.value == null)
+            loginHeaders.put("Host", hostPort.name);
+        else
+            loginHeaders.put("Host", hostPort.name + ':' + hostPort.value);
+
+        loginHeaders.put("User-Agent", "Mozilla/5.0");
+        loginHeaders.put("Accept", "text/xml.application/xml,application/" +
+                "xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;" +
+                "q=0.5");
+        loginHeaders.put("Accept-Language", "en-us,en;q=0.5");
+        loginHeaders.put("Accept-Encoding", "gzip,deflate");
+        loginHeaders.put("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
+        loginHeaders.put("Keep-Alive", "300");
+        loginHeaders.put("Connection", "keep-alive");
+        loginHeaders.put("Referer", homepageURL);
+
+        isLoggedOn = false;
+        isCached = cached();
+    }
+
+    @BenchmarkOperation (
+        name    = "HomePage",
+        max90th = 1,
+        timing  = Timing.AUTO
+    )
+    public void doHomePage() throws IOException {
+        logger.finer("HomePage: Accessing " + homepageURL);
+
+        http.fetchURL(homepageURL);
+        imgBytes = 0;
+        imagesLoaded = 0;
+
+        StringBuilder responseBuffer = http.getResponseBuffer();
+        if (responseBuffer.length() == 0)
+            throw new IOException("Received empty response");
+
+        Set<String> images = parseImages(responseBuffer);
+        if (!isCached) {
+
+            // Fetch the CSS/JS files
+
+            loadStatics(homepageStatics);
+        }
+        loadImages(images);
+        selectedEvent = RandomUtil.randomEvent(random, responseBuffer);
+        logger.finer("Images loaded: " + imagesLoaded);
+        logger.finer("Image bytes loaded: " + imgBytes);
+        if (ctx.isTxSteadyState())
+            driverMetrics.homePageImages += images.size();
+            driverMetrics.homePageImagesLoaded += imagesLoaded;
+            driverMetrics.homePageImageBytes += imgBytes;
+    }
+
+    @BenchmarkOperation (
+        name    = "Login",
+        max90th = 1,
+        timing  = Timing.AUTO
+    )
+    public void doLogin() throws IOException, Exception {
+        logger.finer("In doLogin");
+        int randomId = 0; //use as password
+        username = null;
+
+        if (!isLoggedOn) {
+            randomId = selectUserID();
+            username = UserName.getUserName(randomId);
+            logger.fine("Logging in as " + username + ", " + randomId);
+            http.readURL(loginURL, constructLoginPost(randomId), loginHeaders);
+            // This redirects to home.
+            http.fetchURL(homepageURL);
+          
+            int loginIdx = http.getResponseBuffer().indexOf("Username");
+            if (loginIdx != -1){
+                throw new RuntimeException("Found login prompt at index " + loginIdx + ", Login as " + username + ", " +
+                                                        randomId + " failed.");
+                //throw new Exception("Found login prompt at index " + loginIdx); 
+            }
+            
+            /*
+            if (http.getResponseBuffer().indexOf("Login:") != 1290) {
+                logger.finest(http.getResponseBuffer().toString());
+                //throw new RuntimeException("Index of LOGIN = " +http.getResponseBuffer().indexOf("Login:") );
+                //logger.info(http.getResponseBuffer().toString());
+                logger.info("Index of LOGIN = " +http.getResponseBuffer().indexOf("Login:") );
+                throw new RuntimeException("Login as " + username + ", " +
+                                                        randomId + " failed.");
+            }
+            */
+            isLoggedOn=true;
+            logger.fine("Login successful as " + username + ", " + randomId);
+        } else {
+            //already logged in --> logout,then log in again
+            doLogout();
+            doLogin();
+        }
+    }
+
+
+    @BenchmarkOperation (
+        name    = "Logout",
+        max90th = 1,
+        timing  = Timing.AUTO
+    )
+    public void doLogout() throws IOException {
+        if (isLoggedOn){
+            logger.finer("Logging off = " + isLoggedOn);
+            http.fetchURL(logoutURL);
+            cachedURLs.clear();
+            isCached = cached();
+            isLoggedOn=false;
+            http = new HttpTransport(); // clear all state
+        }
+    }
+
+
+    @BenchmarkOperation (
+        name    = "TagSearch",
+        max90th = 2,
+        timing  = Timing.AUTO
+    )
+    public void doTagSearch() throws IOException {
+        String tag = RandomUtil.randomTagName(random);
+        int count = random.random(100, 150);
+        String post = "tag=" + tag + "&tagsearchsubmit=Search+Tags";
+        logger.finer("TagSearch: " + tagSearchURL + " Post: " + post);
+        http.readURL(tagSearchURL, post);
+        //if (http.getResponseCode() != 302)
+        //    logger.warning("Tag search response not redirecting.");
+      
+        http.fetchURL(tagCloudURL + "?tag=" + tag + "&count=" + count);
+        StringBuilder responseBuffer = http.getResponseBuffer();
+        if (responseBuffer.length() == 0)
+            throw new IOException("Received empty response");
+        Set<String> images = parseImages(responseBuffer);
+        loadStatics(tagSearchStatics);
+        loadImages(images);
+        String event = RandomUtil.randomEvent(random, responseBuffer);
+        if (event != null)
+            selectedEvent = event;
+        if (ctx.isTxSteadyState())
+            driverMetrics.tagSearchImages += images.size();
+    }
+
+    @BenchmarkOperation (
+        name    = "AddEvent",
+        max90th = 4,
+        timing  = Timing.MANUAL
+    )
+    public void doAddEvent() throws IOException {
+        logger.finer("doAddEvent");
+        ctx.recordTime();
+        http.readURL(addEventURL);
+        loadStatics(addEventStatics);
+
+        MultipartPostMethod post = new MultipartPostMethod(addEventResultURL);
+        if(isLoggedOn) {
+            String[] parameters = prepareEvent();
+            if (parameters[0] == null || parameters[0].length() == 0)
+                logger.warning("Socialevent title is null!");
+            else
+                logger.finer("addEvent adding event title: " + parameters[0]);
+            
+            post.addParameter("title", parameters[0]);
+            post.addParameter("description", parameters[1]);
+            post.addParameter("telephone", parameters[3]);
+            post.addParameter("timezone", parameters[4]);
+            //add the address
+            String[] addressArr = prepareAddress();
+            post.addParameter("street1", addressArr[0]);
+            post.addParameter("street2", addressArr[1]);
+            post.addParameter("city", addressArr[2]);
+            post.addParameter("state", addressArr[3]);
+            post.addParameter("zip", addressArr[4]);
+            post.addParameter("country", addressArr[5]);
+            post.addParameter("year",parameters[5]);
+            post.addParameter("month", parameters[6]);
+            post.addParameter("day", parameters[7]);
+            post.addParameter("hour", parameters[8]);
+            post.addParameter("minute", parameters[9]);
+            post.addParameter("tags", parameters[2]);
+            post.addParameter("submitter_user_name", username);
+            // We do the images last, not to split the fields into parts
+            post.addParameter("upload_image", eventImg);
+//            post.addParameter("eventThumbnail", eventThumb);
+            post.addParameter("upload_literature",eventPdf);
+            post.addParameter("addeventsubmit", "Create");
+
+            doMultiPartPost(post);
+        }
+        ctx.recordTime();
+        ++driverMetrics.addEventTotal;
+    }
+
+    @BenchmarkOperation (
+        name    = "AddPerson",
+        max90th = 3,
+        timing  = Timing.MANUAL
+    )
+    public void doAddPerson() throws IOException {
+        logger.finer("doAddPerson");
+        if (isLoggedOn)
+            doLogout();
+
+        ctx.recordTime();
+        http.readURL(addPersonURL);
+        loadStatics(addPersonStatics);
+        MultipartPostMethod post = new MultipartPostMethod(addPersonResultURL);
+        String[] parameters = preparePerson();
+        
+        // Debug
+        if (parameters[0] == null || parameters[0].length() == 0)
+            logger.warning("Username is null!");
+        else
+            logger.finer("addPerson adding user: " + parameters[0]);
+        
+        post.addParameter("add_user_name", parameters[0]);
+        post.addParameter("psword", parameters[1]);
+        post.addParameter("passwordx", parameters[1]);
+        post.addParameter("first_name", parameters[2]);
+        post.addParameter("last_name", parameters[3]);
+        post.addParameter("email",parameters[4]);
+        String[] addressArr = prepareAddress();
+        post.addParameter("street1",addressArr[0]);
+        post.addParameter("street2",addressArr[1]);
+        post.addParameter("zip", addressArr[4]);
+        post.addParameter("city", addressArr[2]);
+        post.addParameter("state", addressArr[3]);
+        post.addParameter("country", addressArr[5]);
+        post.addParameter("telephone",parameters[5]);
+        post.addParameter("timezone", parameters[7]);
+        post.addParameter("user_image", personImg);
+//        post.addParameter("user_thumbnail",personThumb);
+        post.addParameter("summary", parameters[6]);
+        post.addParameter("addpersonsubmit", "Create");
+        doMultiPartPost(post);
+        ctx.recordTime();
+        ++driverMetrics.addPersonTotal;
+    }
+
+    @BenchmarkOperation (
+        name    = "EventDetail",
+        max90th = 2,
+        timing  = Timing.AUTO
+    )
+    public void doEventDetail() throws IOException {
+        //select random event
+        logger.finer("doEventDetail");
+            http.fetchURL(eventDetailURL + selectedEvent);
+        StringBuilder responseBuffer = http.getResponseBuffer();
+        if (responseBuffer.length() == 0)
+            throw new IOException("Received empty response");
+        boolean canAddAttendee = isLoggedOn &&
+                                responseBuffer.indexOf("Attend") != -1;
+//        if (isLoggedOn && !canAddAttendee)
+//            logger.warning(responseBuffer.toString());
+        Set<String> images = parseImages(responseBuffer);
+        loadStatics(eventDetailStatics);
+        loadImages(images);
+        int card = -1;
+        if (canAddAttendee) {
+            // 10% of the time we can add ourselves, we will.
+            card = random.random(0, 9);
+            if (card == 0)
+                doAddAttendee();
+        }
+
+        if (ctx.isTxSteadyState()) {
+            driverMetrics.eventDetailImages += images.size();
+            if (canAddAttendee) {
+                ++driverMetrics.addAttendeeReadyCount;
+                if (card == 0)
+                    ++driverMetrics.addAttendeeCount;
+            }
+        }
+    }
+
+    @BenchmarkOperation (
+        name = "PersonDetail",
+        max90th = 2,
+        timing = Timing.AUTO
+    )
+    public void doPersonDetail() throws IOException {
+        logger.finer("doPersonDetail");
+        StringBuilder buffer = new StringBuilder(fileServiceURL.length() + 20);
+        
+        // TODO: account for new users when loading images, too.
+        buffer.append(fileServiceURL).append("file=p");
+        int id = random.random(1, ScaleFactors.users);
+        http.fetchURL(personDetailURL + UserName.getUserName(id));
+        StringBuilder responseBuffer = http.getResponseBuffer();
+        if (responseBuffer.length() == 0)
+            throw new IOException("Received empty response");
+
+        loadStatics(personStatics);       
+        http.readURL(buffer.append(id).append(".jpg").toString());
+    }
+
+    public void doAddAttendee() throws IOException {
+        //can only add yourself (one attendee) to party
+        http.readURL(addAttendeeURL + selectedEvent);
+        // http.readURL(updatePageURL, "list=attendees");
+    }
+
+    public Set<String> parseImages(StringBuilder buffer) {
+        LinkedHashSet<String> urlSet = new LinkedHashSet<String>();
+        String elStart = "<img ";
+        String attrStart = " src=\"";
+        int elStartLen = elStart.length() - 1; // Don't include the trailing space
+        int attrStartLen = attrStart.length();
+        int idx = 0;
+        logger.finest("Parsing images from buffer");
+        for (;;) {
+
+            // Find and copy out the element.
+            idx = buffer.indexOf(elStart, idx);
+            if (idx == -1)
+                break;
+            idx += elStartLen;
+            int endIdx = buffer.indexOf("/>", idx);
+            if (endIdx == -1)
+                break;
+            String elText = buffer.substring(idx, endIdx);
+            idx = endIdx + 1;
+
+            // Find the attribute
+            int idx2 = elText.indexOf(attrStart);
+            if (idx2 == -1) {
+                logger.finer("No img src attribute. Weird! " + elText);
+                continue;
+            }
+            endIdx = elText.indexOf("\"", idx2 + attrStartLen);
+            if (endIdx == -1) {
+                logger.warning("No img src attribute ending. Weird! " + elText);
+                continue;
+            }
+
+            String link = elText.substring(idx2 + attrStartLen, endIdx);
+            if (link.startsWith("fileService.")) {
+                String url = baseURL + '/' + link;
+
+                logger.finest("Adding " + url + " from idx " + idx);
+                urlSet.add(url);
+            }
+        }
+        return urlSet;
+    }
+
+    private void loadImages(Set<String> images) throws IOException {
+        if (images != null)
+            for (String image : images)
+                // Loads image only if not cached, means we can add to cache.
+                if (cachedURLs.add(image)) {
+                    logger.finer("Loading image " + image);
+                    int imgSize = http.readURL(image);
+                    if (imgSize < 1024) {
+                        logger.warning("Image at " + image + " size of " +
+                                        imgSize + " bytes is too small. " +
+                                        "Image may not exist");
+                    }
+                    imgBytes += imgSize;
+                    ++imagesLoaded;
+                } else {
+                    logger.finer("Image already cached: Not loading " + image);
+                }
+    }
+
+    private boolean cached() {
+        // We have to decide whether the cache is empty or not.
+        // 40% of the time, it is empty.
+        boolean cached = true;
+        int selector = random.random(0, 9);
+        if (selector < 4) {
+            cached = false;
+        }
+        return cached;
+    }
+
+    private void loadStatics(String[] urls) throws IOException {
+
+        if (!isCached)
+            for (String url : urls)
+                if (cachedURLs.add(url)) {
+                    logger.finer("Loading URL " + url);
+                    http.readURL(url);
+                } else {
+                    logger.finer("URL already cached: Not loading " + url);
+                }
+    }
+
+    public DateFormat getDateFormat() {
+        if (df == null)
+            df = new SimpleDateFormat("yyyy-MM-dd-HH-mm");
+        return df;
+    }
+
+    public int selectUserID() {
+        return random.random(0, ScaleFactors.USERS_RATIO - 1) *
+                            ScaleFactors.activeUsers + ctx.getThreadId() + 1;
+    }
+
+
+    private String[] populateList(String[] arrList) {
+
+        String[] returnList = new String[arrList.length];
+        if (arrList != null) {
+
+            try {
+                for (int i = 0; i < arrList.length; i++) {
+                    returnList[i] = baseURL + arrList[i].trim();
+
+                }
+            } catch (Exception e) {
+                System.out.println ("Exception - " + e);
+                e.printStackTrace();
+            }
+        }
+        return returnList;
+    }
+
+    private String constructLoginPost(int randomId) {
+        return "user_name=" + username + "&password=" +
+                String.valueOf(randomId) + "&submit=Login";
+    }
+
+    public void doMultiPartPost(MultipartPostMethod post) throws IOException {
+
+        HttpClient client = new HttpClient();
+        client.setConnectionTimeout(5000);
+        int status = client.executeMethod(post);
+        if(status != HttpStatus.SC_OK)
+            throw new IOException("Multipart Post did not work");
+    }
+
+    public String[] prepareEvent()  {
+
+        String fields[]  = new String[10];
+        StringBuilder buffer = new StringBuilder(256);
+        fields[0] = RandomUtil.randomText(random, 15, 20); //title
+        fields[1] = RandomUtil.randomText(random, 50, 495); // description
+
+        int numTags = random.random(1, 7); // Avg is 4 tags per event
+        for (int i = 0; i < numTags; i++)
+            while (!tagSet.add(RandomUtil.randomTagId(random, 0.1d)));
+
+        for (int tagId : tagSet)
+            tags.append(UserName.getUserName(tagId)).append(' ');
+        tags.setLength(tags.length() - 1);
+
+        fields[2]= tags.toString();
+        tags.setLength(0);
+        tagSet.clear();
+
+        fields[3]= RandomUtil.randomPhone(random, buffer); //phone
+        fields[4]= RandomUtil.randomTimeZone(random); // timezone
+        DateFormat dateFormat = getDateFormat(); // eventtimestamp
+        String dateTime = dateFormat.format( //eventtimestamp
+                random.makeDateInInterval(BASE_DATE, 0, 540));
+        StringTokenizer t = new StringTokenizer(dateTime, "-");
+        int i = 5;
+        while (t.hasMoreTokens()) {
+            fields[i++] = t.nextToken();
+        }
+        return fields;
+    }
+
+    public String[] prepareAddress() {
+
+        String[] STREETEXTS = { "Blvd", "Ave", "St", "Ln", "" };
+        StringBuilder buffer = new StringBuilder(255);
+        buffer.append(random.makeNString(1, 5)).append(' '); // number
+        RandomUtil.randomName(random, buffer, 1, 11); // street
+        String streetExt = STREETEXTS[random.random(0, STREETEXTS.length - 1)];
+        if (streetExt.length() > 0)
+            buffer.append(' ').append(streetExt);
+        String[] fields = new String[6];
+        fields[0] = buffer.toString();
+
+        int toggle = random.random(0, 1); // street2
+        if (toggle > 0)
+            fields[1] = random.makeCString(5, 20);
+        else
+            fields[1] = "";
+
+        fields[2] = random.makeCString(4, 14); // city
+        fields[3] = random.makeCString(2, 2).toUpperCase(); // state
+        fields[4] = random.makeNString(5, 5);  // zip
+
+        toggle = random.random(0, 1);
+        if (toggle == 0) {
+            fields[5] = "USA";
+        } else {
+            buffer.setLength(0);
+            fields[5] = RandomUtil.randomName(random, buffer, 6, 16).toString();
+        }
+        return fields;
+    }
+
+    public String[] preparePerson() {
+        String fields[]  = new String[8];
+        StringBuilder b = new StringBuilder(256);
+        int id = loadedUsers + personsAdded++ * ScaleFactors.activeUsers +
+                                                        ctx.getThreadId() + 1;
+        fields[0] = UserName.getUserName(id);
+        //use the same field for repeating the password field.
+        fields[1] = String.valueOf(id);
+        fields[2] = RandomUtil.randomName(random, b, 2, 12).toString();
+        b.setLength(0);
+        fields[3] = RandomUtil.randomName(random, b, 5, 15).toString();
+        fields[4] = random.makeCString(3, 10);
+        fields[4] = fields[2] + '_' + fields[3] + '@' + fields[4] + ".com";
+        b.setLength(0);
+        fields[5] = RandomUtil.randomPhone(random, b);
+        fields[6] = random.makeAString(250, 2500);
+        fields[7] = RandomUtil.randomTimeZone(random);
+        return fields;
+    }
+
+    static class UIDriverMetrics implements CustomMetrics {
+
+        int addAttendeeCount = 0;
+        int addAttendeeReadyCount = 0;
+        int homePageImages = 0;
+        int tagSearchImages = 0;
+        int eventDetailImages = 0;
+        int homePageImagesLoaded = 0;
+        long homePageImageBytes = 0;
+        int addEventTotal = 0;
+        int addPersonTotal = 0;
+
+        public void add(CustomMetrics other) {
+            UIDriverMetrics o = (UIDriverMetrics) other;
+            addAttendeeCount += o.addAttendeeCount;
+            addAttendeeReadyCount += o.addAttendeeReadyCount;
+            homePageImages += o.homePageImages;
+            tagSearchImages += o.tagSearchImages;
+            eventDetailImages += o.eventDetailImages;
+            homePageImageBytes += o.homePageImageBytes;
+            homePageImagesLoaded += o.homePageImagesLoaded;
+            addEventTotal += o.addEventTotal;
+            addPersonTotal += o.addPersonTotal;
+        }
+
+        public Element[] getResults() {
+            Result r = Result.getInstance();
+            int total = r.getOpsCountSteady("EventDetail");
+            Element[] el = new Element[10];
+            el[0] = new Element();
+            el[0].description = "% EventDetail views where attendee added";
+            el[0].target = "&gt;= 6";
+            if (total > 0) {
+                double pctAdd = 100d * addAttendeeCount / (double) total;
+                el[0].result = String.format("%.2f", pctAdd);
+                if (pctAdd >= 6d)
+                    el[0].passed = Boolean.TRUE;
+                else
+                    el[0].passed = Boolean.FALSE;
+            } else {
+                el[0].result = "";
+                el[0].passed = Boolean.FALSE;
+            }
+
+            el[1] = new Element();
+            el[1].description = "EventDetail count where attendee can be added";
+            el[1].result = String.valueOf(addAttendeeReadyCount);
+
+            int cnt = r.getOpsCountSteady("HomePage");
+            el[2] = new Element();
+            el[2].description = "Average images references on Home Page";
+            el[2].target = "10";
+            el[2].allowedDeviation = "0.5";
+            if (cnt > 0) {
+                double imagesPerPage = homePageImages / (double) cnt;
+                el[2].result = String.format("%.2f", imagesPerPage);
+                if (imagesPerPage >= 9.5d && imagesPerPage <= 10.5d)
+                    el[2].passed = Boolean.TRUE;
+                else
+                    el[2].passed = Boolean.FALSE;
+            } else {
+                el[2].result = "";
+                el[2].passed = Boolean.FALSE;
+            }
+
+            el[3] = new Element();
+            el[3].description = "Average images loaded per Home Page";
+            el[3].target = "&gt;= 3";
+            if (cnt > 0) {
+                double avgImgs = homePageImagesLoaded / (double) cnt;
+                el[3].result = String.format("%.2f", avgImgs);
+                if (avgImgs >= 3d)
+                    el[3].passed = Boolean.TRUE;
+                else
+                    el[3].passed = Boolean.FALSE;
+            } else {
+                el[3].result = "";
+                el[3].passed = Boolean.FALSE;
+            }
+
+            el[4] = new Element();
+            el[4].description = "Average image bytes received per Home Page";
+            el[4].target = "&gt;= 15000";
+            if (cnt > 0) {
+                double avgBytes = homePageImageBytes / (double) cnt;
+                el[4].result = String.format("%.2f", avgBytes);
+                if (avgBytes >= 15000)
+                    el[4].passed = Boolean.TRUE;
+                else
+                    el[4].passed = Boolean.FALSE;
+            } else {
+                el[4].result = "";
+                el[4].passed = Boolean.FALSE;
+            }
+            cnt = r.getOpsCountSteady("TagSearch");
+            el[5] = new Element();
+            el[5].description = "Average images on Tag Search Results";
+            el[5].target = "&gt;= 3.6";
+            if (cnt > 0) {
+                double avgImgs = tagSearchImages / (double) cnt;
+                el[5].result = String.format("%.2f", avgImgs);
+                if (avgImgs >= 3.6d)
+                    el[5].passed = Boolean.TRUE;
+                else
+                    el[5].passed = Boolean.FALSE;
+            } else {
+                el[5].result = "";
+                el[5].passed = Boolean.FALSE;
+            }
+            el[6] = new Element();
+            el[6].description = "Average images on Event Detail";
+            el[6].target = "&gt;= 1";
+            if (total > 0) {
+                double avgImgs = eventDetailImages / (double) total;
+                el[6].result = String.format("%.2f", avgImgs);
+                if (avgImgs >= 1d)
+                    el[6].passed = Boolean.TRUE;
+                else
+                    el[6].passed = Boolean.FALSE;
+            } else {
+                el[6].result = "";
+                el[6].passed = Boolean.FALSE;
+            }
+            el[7] = new Element();
+            el[7].description = "Total successful AddEvent calls";
+            el[7].result = String.valueOf(addEventTotal);
+            el[8] = new Element();
+            el[8].description = "Total successful AddPerson calls";
+            el[8].result = String.valueOf(addPersonTotal);
+            el[9] = new Element();
+            el[9].description = "Concurrent user to ops/sec ratio";
+            el[9].target = "&lt;= 5.25";
+            double ratio = r.getScale() / r.getMetric();
+            el[9].result = String.format("%.2f", ratio);
+            if (ratio <= 5.25d)
+                el[9].passed = true;
+            else
+                el[9].passed = false;
+            return el;
+        }
+
+        public Object clone() {
+            UIDriverMetrics clone = new UIDriverMetrics();
+            clone.addAttendeeCount = addAttendeeCount;
+            clone.addAttendeeReadyCount = addAttendeeReadyCount;
+            clone.homePageImages = homePageImages;
+            clone.tagSearchImages = tagSearchImages;
+            clone.eventDetailImages = eventDetailImages;
+            clone.homePageImageBytes = homePageImageBytes;
+            clone.homePageImagesLoaded = homePageImagesLoaded;
+            clone.addEventTotal = addEventTotal;
+            clone.addPersonTotal = addPersonTotal;
+            return clone;
+        }
+    }
+}

Propchange: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/fsloader/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/fsloader/FileLoader.java
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/src/org/apache/olio/workload/fsloader/FileLoader.java?rev=745184&view=auto
==============================================================================
--- incubator/olio/workload/php/trunk/src/org/apache/olio/workload/fsloader/FileLoader.java (added)
+++ incubator/olio/workload/php/trunk/src/org/apache/olio/workload/fsloader/FileLoader.java Tue Feb 17 18:25:43 2009
@@ -0,0 +1,185 @@
+/*
+ * 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.
+ * 
+ *  $Id: FileLoader.java,v 1.1.1.1 2008/09/29 22:33:08 sp208304 Exp $
+ */
+
+package org.apache.olio.workload.fsloader;
+
+import org.apache.olio.workload.util.ScaleFactors;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+import java.util.Formatter;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+public class FileLoader {
+
+    private static Logger logger = Logger.getLogger(FileLoader.class.getName());
+
+    public static void main(String[] args) throws Exception {
+        String srcDir = args[0];
+        String destDir = args[1];
+        ScaleFactors.setActiveUsers(Integer.parseInt(args[2]));
+        srcDir += File.separator;
+
+        // Clear the dest dir
+        File dest = new File(destDir);
+        if (!dest.isDirectory()) {
+            logger.severe(destDir + " Not a directory!");
+            System.exit(1);
+        }
+
+        logger.info("Deleting files in " + destDir);
+        File[] list = dest.listFiles();
+        for (File f : list) {
+            String name = f.getName();
+            boolean delete = false;
+            if (name.endsWith(".jpg"))
+                delete = true;
+            else if (name.endsWith(".JPG"))
+                delete = true;
+            else if (name.endsWith(".pdf"))
+                delete = true;
+            else if (name.endsWith(".PDF"))
+                delete = true;
+            if (delete && !f.delete())
+                logger.warning("Error deleting file " + f.getName());
+        }
+
+        ArrayList<LoaderThread> loaders = new ArrayList<LoaderThread>();
+
+        loaders.add(new LoaderThread(srcDir + "person.jpg",
+                destDir + File.separator + "p%d.jpg", ScaleFactors.users));
+        loaders.add(new LoaderThread(srcDir + "person_thumb.jpg",
+                destDir + File.separator + "p%dt.jpg", ScaleFactors.users));
+        loaders.add(new LoaderThread(srcDir + "event.jpg",
+                destDir + File.separator + "e%d.jpg", ScaleFactors.events));
+        loaders.add(new LoaderThread(srcDir + "event_thumb.jpg",
+                destDir + File.separator + "e%dt.jpg", ScaleFactors.events));
+        loaders.add(new LoaderThread(srcDir + "event.pdf",
+                destDir + File.separator + "e%d.pdf", ScaleFactors.events));
+
+        for (LoaderThread loader : loaders) {
+            loader.join();
+        }
+
+        for (LoaderThread loader : loaders) {
+            loader.close();
+        }
+
+        System.exit(0);
+/*
+        FileChannel img = new FileInputStream(
+                                    srcDir + "person.jpg").getChannel();
+        FileChannel thumb = new FileInputStream(
+                                    srcDir + "person_thumb.jpg").getChannel();
+        long imgSize = img.size();
+        long thumbSize = thumb.size();
+
+        logger.info("Loading user images...");
+        for (int i = 1; i <= ScaleFactors.users; i++) {
+            logger.finer("Loading files for user " + i);
+            copyTo(img, imgSize, destDir + File.separator + "p" + i + ".jpg");
+            copyTo(thumb, thumbSize,
+                    destDir + File.separator + "p" + i + "t.jpg");
+        }
+
+        img.close();
+        thumb.close();
+
+        logger.info("Loading event images and files...");
+        img = new FileInputStream(srcDir + "event.jpg").getChannel();
+        thumb = new FileInputStream(srcDir + "event_thumb.jpg").getChannel();
+        FileChannel lit = new FileInputStream(
+                                    srcDir + "event.pdf").getChannel();
+
+        imgSize = img.size();
+        thumbSize = thumb.size();
+        long litSize = lit.size();
+
+        for (int i = 1; i <= ScaleFactors.events; i++) {
+            logger.finer("Loading files for event " + i);
+            copyTo(img, imgSize, destDir + File.separator + "e" + i + ".jpg");
+            copyTo(thumb, thumbSize,
+                    destDir + File.separator + "e" + i + "t.jpg");
+            copyTo(lit, litSize, destDir + File.separator + "e" + i + ".pdf");
+        }
+
+        img.close();
+        thumb.close();
+        lit.close();
+        System.exit(0);
+*/
+    }
+
+    /*
+    private static void copyTo(FileChannel src, long size, String destFile)
+            throws IOException {
+        FileChannel dest = (new FileOutputStream(destFile)).getChannel();
+        src.transferTo(0, size, dest);
+        dest.close();
+    }
+    */
+
+    static class LoaderThread extends Thread {
+
+        FileChannel src;
+        int count;
+        long size;
+        String pattern;
+        Formatter format;
+
+        public LoaderThread(String src, String destPattern, int count)
+                throws IOException {
+            this.src = new FileInputStream(src).getChannel();
+            size = this.src.size();
+            this.count = count;
+            this.pattern = destPattern;
+            format = new Formatter();
+            start();
+        }
+
+        public void run() {
+            for (int i = 1; i <= count; i++) {
+                String dest = format.format(pattern, i).toString();
+                if (i % 1000 == 0) {
+                    logger.info("Copying to " + dest);
+                }
+                ((StringBuilder) format.out()).setLength(0);
+                try {
+                    FileChannel destChannel = new FileOutputStream(dest).
+                                                            getChannel();
+                    src.transferTo(0, size, destChannel);
+                    destChannel.close();
+                } catch (IOException e) {
+                    logger.log(Level.WARNING, "Error writing file " + dest, e);
+                }
+            }
+        }
+
+        public void close() throws IOException {
+            src.close();
+        }
+    }
+}

Propchange: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/harness/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/harness/OlioBenchmark.java
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/src/org/apache/olio/workload/harness/OlioBenchmark.java?rev=745184&view=auto
==============================================================================
--- incubator/olio/workload/php/trunk/src/org/apache/olio/workload/harness/OlioBenchmark.java (added)
+++ incubator/olio/workload/php/trunk/src/org/apache/olio/workload/harness/OlioBenchmark.java Tue Feb 17 18:25:43 2009
@@ -0,0 +1,245 @@
+/*
+ * 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.
+ * 
+ * $Id: OlioBenchmark.java,v 1.1.1.1 2008/09/29 22:33:08 sp208304 Exp $
+ */
+
+package org.apache.olio.workload.harness;
+
+import com.sun.faban.common.Command;
+import com.sun.faban.common.CommandHandle;
+import com.sun.faban.common.NameValuePair;
+import com.sun.faban.harness.DefaultFabanBenchmark;
+import com.sun.faban.harness.RunContext;
+import com.sun.faban.harness.engine.*;
+
+import java.io.File;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.logging.Logger;
+
+import static com.sun.faban.harness.RunContext.*;
+
+/**
+ * Harness hook for the sample web benchmark. This class is not needed
+ * for benchmarks implemented using the Faban Driver Framework if the
+ * default behavior is sufficient. We just show the hooks you can
+ * customize in this class. If the default behavior is desired, you can
+ * leave out the benchmark-class element in benchmark.xml.
+ *
+ * @author Akara Sucharitakul
+ */
+public class OlioBenchmark extends DefaultFabanBenchmark {
+    
+    static Logger logger = Logger.getLogger(
+                                        OlioBenchmark.class.getName());
+    int totalRunningTimeInSecs = 0;
+    private List<NameValuePair<Integer>> memcacheServers;
+    private String webServerBinPath, webServerLogPath, webServerConfPath;
+    private String webServerPidPath, phpIniPath, cacheBinPath, dbConfPath;
+    WebServerService webServerService;
+    MemcachedService memcachedService = MemcachedService.getHandle();
+
+    /**
+     * This method is called to configure the specific benchmark run
+     * Tasks done in this method include reading user parameters,
+     * logging them and initializing various local variables.
+     *
+     * @throws Exception If configuration was not successful
+     */
+    public void configure() throws Exception {
+        
+        params = getParamRepository();
+
+        //Obtaining configuration parameters
+        String webserverType = params.getParameter("webServer/type");
+ 
+        webServerBinPath = params.getParameter("webServer/hostBinPath");
+        webServerLogPath = params.getParameter("webServer/hostLogPath");
+        webServerConfPath = params.getParameter("webServer/hostConfPath");
+        webServerPidPath = params.getParameter("webServer/hostPidPath");
+        phpIniPath = params.getParameter("webServer/phpIniPath");
+        cacheBinPath = params.getParameter("cacheServers/cacheBinPath");
+        dbConfPath = params.getParameter("dbServer/dbConfPath");
+        String[] dbhosts = params.getParameter(
+                            "dbServer/fa:hostConfig/fa:host").split(" ");
+        String[] webhosts = params.getParameter(
+                            "webServer/fa:hostConfig/fa:host").split(" ");
+
+        if ("apache".equals(webserverType)) {
+            webServerService = ApacheHttpdService.getHandle();
+            for (String webhost : webhosts) {
+                RunContext.getFile(webhost, webServerConfPath +
+                        File.separator + "httpd.conf", RunContext.getOutDir() +
+                        "httpd_conf.log." + getHostName(webhost));
+            }
+        } else if ("lighttpd".equals(webserverType)) {
+            webServerService = LighttpdService.getHandle();
+            for (String webhost : webhosts) {
+                RunContext.getFile(webhost, webServerConfPath +
+                        File.separator + "lighttpd.conf",
+                        RunContext.getOutDir() + "lighttpd_conf.log." +
+                        getHostName(webhost));
+            }
+        } else if ("glassfish".equals(webserverType)) {
+            webServerService = GlassfishService.getHandle();
+            for (String webhost : webhosts) {
+                RunContext.getFile(webhost, webServerConfPath +
+                        File.separator + "domain.xml",
+                        RunContext.getOutDir() + "domain_xml.log." +
+                        getHostName(webhost));
+            }
+        }
+        if (phpIniPath != null && phpIniPath.length() > 0)
+            for (String webhost : webhosts) {
+                RunContext.getFile(webhost, phpIniPath + "/php.ini",
+                        RunContext.getOutDir() + "php_ini.log." +
+                        getHostName(webhost));
+            }
+
+        for (String dbhost : dbhosts) {
+            RunContext.getFile(dbhost, dbConfPath + "/my.cnf",
+            RunContext.getOutDir() + "my_cnf.log." + getHostName(dbhost));
+        }
+
+        // Reloading database and media as necessary.
+        boolean reloadDB = Boolean.parseBoolean(
+                params.getParameter("dbServer/reloadDB"));
+        boolean reloadMedia = Boolean.parseBoolean(
+                params.getParameter("dataStorage/reloadMedia"));
+
+        int scale = -1;
+        if (reloadDB || reloadMedia)
+            scale =Integer.parseInt(params.getParameter("dbServer/scale"));
+
+        CommandHandle dbHandle = null;
+        CommandHandle mediaHandle = null;
+        if (reloadDB) {
+            logger.info("Reloading the database for " + scale + " users!");
+            String dbhost = dbhosts[0];
+            String driver = params.getParameter("dbServer/dbDriver");
+            String connectURL = params.getParameter("dbServer/connectURL");
+            // Un-escape the URL.
+            connectURL = connectURL.replace("&amp;", "&");
+
+            boolean autoCommit = Boolean.parseBoolean(params.getParameter(
+                                                    "dbServer/autoCommit"));
+            ArrayList<String> cmdList = new ArrayList<String>();
+            if (autoCommit)
+                cmdList.add("-Dcommit.tx=false");
+            cmdList.add("com.sun.web20.loader.LoadController");
+            cmdList.add(driver);
+            cmdList.add(connectURL);
+            cmdList.add(String.valueOf(scale));
+            Command c = new Command(cmdList);
+            c.setSynchronous(false);
+            dbHandle = java(dbhost, c);
+        }
+
+        if (reloadMedia) {
+            logger.info("Reloading images/media for " + scale + " users!");
+            String mediaHost = params.getParameter(
+                                        "dataStorage/fa:hostConfig/fa:host");
+            String mediaDir = params.getParameter("dataStorage/mediaDir");
+            Command c = new Command("com.sun.web20.fsloader.FileLoader",
+                        getBenchmarkDir() + "resources", mediaDir,
+                        String.valueOf(scale));
+            c.setSynchronous(false);
+            mediaHandle = java(mediaHost, c);
+        }
+        
+        if (dbHandle != null)
+            dbHandle.waitFor();
+        
+        if (mediaHandle != null)
+            mediaHandle.waitFor();
+        
+        //start the memcache servers
+        memcacheServers =
+                 params.getHostPorts("cacheServers/fa:hostConfig/fa:hostPorts");
+
+         // Assign the default port.
+         for (NameValuePair<Integer> hostPort : memcacheServers) {
+             if (hostPort.value == null)
+                 hostPort.value = 11211;
+         }
+
+        int index = 0;
+        String memServers[] = new String[memcacheServers.size()];
+        int ports[] = new int[memcacheServers.size()];
+        for (NameValuePair<Integer> thisCacheServer : memcacheServers) {
+            memServers[index] = thisCacheServer.name;
+            ports[index++] = thisCacheServer.value;
+        } 
+        memcachedService.setup(memServers, ports, "-u mysql -m 256",
+                cacheBinPath);
+        if ( !memcachedService.restartServers())
+            throw (new Exception("Memcached server(s) restart failed"));
+        
+        // Now start the web servers
+        if (webServerService != null) {
+            webServerService.setup(webhosts, webServerBinPath, webServerLogPath,
+                                    webServerConfPath, webServerPidPath);
+            if (!webServerService.restartServers())
+                throw (new Exception("Webserver(s) restart failed"));
+        }
+
+        //calculate total running time, including rampUp, steadyState,
+        // and rampDown
+        String rampUp = params.getParameter(
+                               "fa:runConfig/fa:runControl/fa:rampUp");
+        String steadyState = params.getParameter(
+                               "fa:runConfig/fa:runControl/fa:steadyState");
+        String rampDown = params.getParameter(
+                               "fa:runConfig/fa:runControl/fa:rampDown");
+
+        this.totalRunningTimeInSecs = Integer.parseInt(rampUp) +
+                Integer.parseInt(steadyState) + Integer.parseInt(rampDown);
+
+        super.configure();
+    }
+
+    /* override DefaultBenchmark's end method to collect webserver log file
+     * via the OlioBenchmark harness class
+     */
+    public void end () throws Exception {
+     
+        super.end();
+        //stop the memcached servers
+        //logger.info("Stopping Memcached servers");
+        //memcachedService.stopServers();
+
+        if (webServerService != null) {
+            // xfer logs
+            logger.info("Transferring webserver error logs");
+            webServerService.xferLogs(totalRunningTimeInSecs);
+
+            // stop web servers
+            logger.info("Stopping web servers");
+            webServerService.stopServers();
+        }
+    }
+
+    /* Override DefaultBenchmark's kill method to stop the servers.
+     */
+    public void kill() throws Exception {
+        memcachedService.stopServers();
+        if (webServerService != null)
+            webServerService.kill();
+        super.kill();
+    }
+}

Propchange: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/harness/OlioBenchmark.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Address.java
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Address.java?rev=745184&view=auto
==============================================================================
--- incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Address.java (added)
+++ incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Address.java Tue Feb 17 18:25:43 2009
@@ -0,0 +1,99 @@
+
+/*
+ * 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.
+ *  
+ * $Id: Address.java,v 1.1.1.1 2008/09/29 22:33:08 sp208304 Exp $
+ */
+package org.apache.olio.workload.loader;
+
+import com.sun.faban.driver.util.Random;
+import org.apache.olio.workload.util.RandomUtil;
+import org.apache.olio.workload.loader.framework.Loadable;
+import org.apache.olio.workload.loader.framework.ThreadConnection;
+import org.apache.olio.workload.loader.framework.ThreadResource;
+
+import java.util.logging.Logger;
+import java.util.logging.Level;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Types;
+
+/**
+ * Address loader.
+ */
+public class Address extends Loadable {
+
+    private static final String STATEMENT = "insert into ADDRESS (street1, " +
+            "street2, city, state, zip, country, latitude, longitude)" +
+            "values (?, ?, ?, ?, ?, ?, ?, ?)";
+    public static final String[] STREETEXTS = { "Blvd", "Ave", "St", "Ln", "" };
+    static Logger logger = Logger.getLogger(Address.class.getName());
+
+    String[] fields = new String[8];
+
+    public String getClearStatement() {
+        return "truncate table ADDRESS";
+    }
+
+    public void prepare() {
+        ThreadResource tr = ThreadResource.getInstance();
+        Random r = tr.getRandom();
+        StringBuilder buffer = tr.getBuffer();
+        buffer.append(r.makeNString(1, 5)).append(' '); // number
+        RandomUtil.randomName(r, buffer, 1, 11); // street
+        String streetExt = STREETEXTS[r.random(0, STREETEXTS.length - 1)];
+        if (streetExt.length() > 0)
+            buffer.append(' ').append(streetExt);
+
+        fields[0] = buffer.toString();
+
+        int toggle = r.random(0, 1); // street2
+        if (toggle > 0)
+            fields[1] = r.makeCString(5, 20);
+
+        fields[2] = r.makeCString(4, 14); // city
+        fields[3] = r.makeCString(2, 2).toUpperCase(); // state
+        fields[4] = r.makeNString(5, 5);  // zip
+
+        toggle = r.random(0, 1);
+        if (toggle == 0) {
+            fields[5] = "USA";
+        } else {
+            buffer.setLength(0);
+            fields[5] = RandomUtil.randomName(r, buffer, 6, 16).toString();
+        }
+        // Latitude, we do not get addresses in polar circles. So the limit
+        fields[6] = String.format("%.6f", r.drandom(-66.560556d, 66.560556d));
+
+        fields[7] = String.format("%.6f", r.drandom(-179.999999d, 180d));
+    }
+
+    public void load() {
+        ThreadConnection c = ThreadConnection.getInstance();
+        try {
+            PreparedStatement s = c.prepareStatement(STATEMENT);
+            for (int i = 0; i < fields.length; i++)
+                if (fields[i] != null)
+                    s.setString(i + 1, fields[i]);
+                else
+                    s.setNull(i + 1, Types.VARCHAR);
+            c.addBatch();
+        } catch (SQLException e) {
+            logger.log(Level.SEVERE, e.getMessage(), e);
+        }
+    }
+}

Added: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Attendees.java
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Attendees.java?rev=745184&view=auto
==============================================================================
--- incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Attendees.java (added)
+++ incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Attendees.java Tue Feb 17 18:25:43 2009
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ * 
+ * $Id: Attendees.java,v 1.1.1.1 2008/09/29 22:33:08 sp208304 Exp $
+ */
+package org.apache.olio.workload.loader;
+
+import com.sun.faban.driver.util.Random;
+import org.apache.olio.workload.util.ScaleFactors;
+import org.apache.olio.workload.util.UserName;
+import org.apache.olio.workload.loader.framework.Loadable;
+import org.apache.olio.workload.loader.framework.ThreadConnection;
+import org.apache.olio.workload.loader.framework.ThreadResource;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.LinkedHashSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Attendees Loader
+ */
+public class Attendees extends Loadable {
+    // We use on average of 55 attendees per event. Random 10..100 Attendees.
+
+    private static final String STATEMENT = "insert into " +
+            "PERSON_SOCIALEVENT " +
+            "(username, socialeventid) values (?, ?)";
+
+    static Logger logger = Logger.getLogger(Attendees.class.getName());
+
+    int eventId;
+    String[] userNames;
+
+    public String getClearStatement() {
+        return "truncate table PERSON_SOCIALEVENT";
+    }
+
+    public void prepare() {
+        eventId = getSequence();
+        ++eventId;
+        ThreadResource tr = ThreadResource.getInstance();
+        Random r = tr.getRandom();
+        int attendees = r.random(10, 100);
+        LinkedHashSet<Integer> userIdSet = 
+                                    new LinkedHashSet<Integer>(attendees);
+        for (int i = 0; i <attendees; i++)
+            while(!userIdSet.add(r.random(1, ScaleFactors.users)));
+
+        userNames = new String[userIdSet.size()];
+        int idx = 0;
+        for (int userId : userIdSet)
+            userNames[idx++] = UserName.getUserName(userId);
+    }
+
+
+    public void load() {
+        ThreadConnection c = ThreadConnection.getInstance();
+        try {
+            for (String userName : userNames) {
+                PreparedStatement s = c.prepareStatement(STATEMENT);
+                s.setString(1, userName);
+                s.setInt(2, eventId);
+                c.addBatch();
+            }
+        } catch (SQLException e) {
+            logger.log(Level.SEVERE, e.getMessage(), e);
+        }
+    }
+}

Added: incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Comments.java
URL: http://svn.apache.org/viewvc/incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Comments.java?rev=745184&view=auto
==============================================================================
--- incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Comments.java (added)
+++ incubator/olio/workload/php/trunk/src/org/apache/olio/workload/loader/Comments.java Tue Feb 17 18:25:43 2009
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ * 
+ * $Id: Comments.java,v 1.1.1.1 2008/09/29 22:33:08 sp208304 Exp $
+ */
+package org.apache.olio.workload.loader;
+
+import com.sun.faban.driver.util.Random;
+import org.apache.olio.workload.util.ScaleFactors;
+import org.apache.olio.workload.util.UserName;
+import org.apache.olio.workload.loader.framework.Loadable;
+import org.apache.olio.workload.loader.framework.ThreadConnection;
+import org.apache.olio.workload.loader.framework.ThreadResource;
+
+import java.sql.Date;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+/**
+ * Comments Loader.
+ */
+public class Comments extends Loadable {
+    // We use on average of 10 comments per event. Random 0..20 comments..
+    public static final Date BASE_DATE = new Date(System.currentTimeMillis());
+    private static final String STATEMENT = "insert into COMMENTS_RATING " +
+            "(username, socialeventid, comments, ratings, created_at) values (?, ?, ?, ?, ?)";
+
+    static Logger logger = Logger.getLogger(Comments.class.getName());
+
+    int eventId;
+    String[] userNames;
+    String[] comments;
+    int[] ratings;
+    Date created_at;
+    
+    public String getClearStatement() {
+        return "truncate table COMMENTS_RATING";
+    }
+
+    public void prepare() {
+        eventId = getSequence();
+        ++eventId;
+        ThreadResource tr = ThreadResource.getInstance();
+        Random r = tr.getRandom();
+        int commentCount = r.random(0, 20);
+        userNames = new String[commentCount];
+        comments = new String[commentCount];
+        ratings = new int[commentCount];
+        for (int i = 0; i < userNames.length; i++) {
+            int userId = r.random(1, ScaleFactors.users);
+            userNames[i] = UserName.getUserName(userId);
+            comments[i] = r.makeCString(10, 1000);
+            ratings[i] = r.random(2, 5);
+        }
+        created_at = r.makeDateInInterval( BASE_DATE, -540, 0);
+    }
+
+
+    public void load() {
+        ThreadConnection c = ThreadConnection.getInstance();
+        try {
+            for (int i = 0; i < userNames.length; i++) {
+                PreparedStatement s = c.prepareStatement(STATEMENT);
+                s.setString(1, userNames[i]);
+                s.setInt(2, eventId);
+                s.setString(3, comments[i]);
+                s.setInt(4, ratings[i]);                
+                s.setDate(5, created_at);
+                c.addBatch();
+            }
+        } catch (SQLException e) {
+            logger.log(Level.SEVERE, e.getMessage(), e);
+        }
+    }
+
+}



Mime
View raw message