Revision: 78
http://polepos.svn.sourceforge.net/polepos/?rev=78&view=rev
Author: carlrosenberger
Date: 2008-11-13 15:55:27 +0000 (Thu, 13 Nov 2008)
Log Message:
-----------
cr: Changed the Team configuration interface to be able to pass in ConfigurationSetting callbacks. This way we can test a wider variety of configurations without
having to introduce an option parameter for each one. Also changed Db4oCar to work with non-static configuration.
Modified Paths:
--------------
trunk/polepos/src/org/polepos/Db4oVersionRace.java
trunk/polepos/src/org/polepos/framework/Team.java
trunk/polepos/src/org/polepos/runner/db4o/AbstractDb4oVersionsRaceRunner.java
trunk/polepos/src/org/polepos/teams/db4o/Db4oCar.java
trunk/polepos/src/org/polepos/teams/db4o/Db4oTeam.java
trunk/polepos/src/org/polepos/teams/hibernate/HibernateTeam.java
trunk/polepos/src/org/polepos/teams/jdbc/JdbcTeam.java
trunk/polepos/src/org/polepos/teams/jdo/JdoTeam.java
trunk/polepos/src/org/polepos/teams/jorm/JormTeam.java
Added Paths:
-----------
trunk/polepos/src/org/polepos/framework/ConfigurationSetting.java
Modified: trunk/polepos/src/org/polepos/Db4oVersionRace.java
===================================================================
--- trunk/polepos/src/org/polepos/Db4oVersionRace.java 2008-06-12 12:31:29 UTC (rev 77)
+++ trunk/polepos/src/org/polepos/Db4oVersionRace.java 2008-11-13 15:55:27 UTC (rev 78)
@@ -52,13 +52,13 @@
String db4oCurrentVersion = System.getProperty("polepos.db4o.current");
if (db4oCurrentVersion != null) {
- teamList.add(db4oTeam(db4oCurrentVersion, null));
+ teamList.add(db4oTeam(db4oCurrentVersion));
teamList.add(db4oTeam(db4oCurrentVersion, options));
}
- teamList.add(db4oTeam(Db4oVersions.JAR63, null));
- teamList.add(db4oTeam(Db4oVersions.JAR57, null));
- teamList.add(db4oTeam(Db4oVersions.JAR45, null));
+ teamList.add(db4oTeam(Db4oVersions.JAR63));
+ teamList.add(db4oTeam(Db4oVersions.JAR57));
+ teamList.add(db4oTeam(Db4oVersions.JAR45));
teamList.add(db4oTeam(Db4oVersions.JAR63, options));
Added: trunk/polepos/src/org/polepos/framework/ConfigurationSetting.java
===================================================================
--- trunk/polepos/src/org/polepos/framework/ConfigurationSetting.java (rev 0)
+++ trunk/polepos/src/org/polepos/framework/ConfigurationSetting.java 2008-11-13 15:55:27 UTC (rev 78)
@@ -0,0 +1,28 @@
+/*
+This file is part of the PolePosition database benchmark
+http://www.polepos.org
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with this program; if not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+package org.polepos.framework;
+
+public interface ConfigurationSetting {
+
+ public void apply(Object config);
+
+ public String name();
+
+}
Modified: trunk/polepos/src/org/polepos/framework/Team.java
===================================================================
--- trunk/polepos/src/org/polepos/framework/Team.java 2008-06-12 12:31:29 UTC (rev 77)
+++ trunk/polepos/src/org/polepos/framework/Team.java 2008-11-13 15:55:27 UTC (rev 78)
@@ -50,13 +50,6 @@
return concurrent;
}
- /**
- * Possibility to add a switch for different configurations
- * and to call from the outside, even throug different
- * ClassLoaders
- */
- public abstract void configure(int[] options);
-
public abstract String name();
public abstract String description();
@@ -89,5 +82,12 @@
vec.toArray(result);
return result;
}
+
+ /**
+ * Override to apply special options and configuration settings to the test run
+ */
+ public void configure(int[] options, ConfigurationSetting[] configurations) {
+
+ }
}
Modified: trunk/polepos/src/org/polepos/runner/db4o/AbstractDb4oVersionsRaceRunner.java
===================================================================
--- trunk/polepos/src/org/polepos/runner/db4o/AbstractDb4oVersionsRaceRunner.java 2008-06-12 12:31:29 UTC (rev 77)
+++ trunk/polepos/src/org/polepos/runner/db4o/AbstractDb4oVersionsRaceRunner.java 2008-11-13 15:55:27 UTC (rev 78)
@@ -35,15 +35,28 @@
private String _workspace;
+
+ public Team db4oTeam(String jarName) {
+ return db4oTeam(jarName, null);
+ }
+
+ /*
+ * ConfigurationSettings will have to be run against TRUNK only
+ * otherwise we get ClassCastExceptions in the callback.
+ */
+ public Team configuredDb4oTeam(ConfigurationSetting[] configurations) {
+ return db4oTeam(workspace(), null, drivers(), configurations);
+ }
+
public Team db4oTeam(String jarName, int[] options) {
- return db4oTeam(workspace(), jarName, options, drivers()) ;
+ return db4oTeam(jarName, options, drivers(), null) ;
}
- public Team db4oTeam(String jarName, int[] options, Driver[] drivers) {
- return db4oTeam(workspace(), jarName, options, drivers) ;
+ private Team db4oTeam(String jarName, int[] options, Driver[] drivers, ConfigurationSetting[] configurations) {
+ return db4oTeam(workspace(), jarName, options, drivers, configurations) ;
}
- private Team db4oTeam(String workspace, String jarName, int[] options, Driver[] drivers) {
+ private Team db4oTeam(String workspace, String jarName, int[] options, Driver[] drivers, ConfigurationSetting[] configurations) {
try {
Team team = null;
if(jarName == null){
@@ -61,7 +74,7 @@
ClassLoader loader=new VersionClassLoader(new URL[]{poleposClassURL, classURL, jarURL},prefixes);
team = (Team)loader.loadClass(Db4oTeam.class.getName()).newInstance();
}
- team.configure(options);
+ team.configure(options, configurations);
if(jarName != null){
team.getClass().getMethod("setJarName", new Class[]{String.class}).invoke(team, jarName);
}
Modified: trunk/polepos/src/org/polepos/teams/db4o/Db4oCar.java
===================================================================
--- trunk/polepos/src/org/polepos/teams/db4o/Db4oCar.java 2008-06-12 12:31:29 UTC (rev 77)
+++ trunk/polepos/src/org/polepos/teams/db4o/Db4oCar.java 2008-11-13 15:55:27 UTC (rev 78)
@@ -19,11 +19,10 @@
package org.polepos.teams.db4o;
-import java.io.*;
-
import org.polepos.framework.*;
import com.db4o.*;
+import com.db4o.config.*;
import com.db4o.ext.*;
@@ -32,9 +31,12 @@
private String name;
private int[] _options;
+
+ private ConfigurationSetting[] _configurations;
- public Db4oCar(int[] options) {
+ public Db4oCar(int[] options, ConfigurationSetting[] configurations) {
_options = options;
+ _configurations = configurations;
name = Db4o.version().substring(5);
}
@@ -52,12 +54,14 @@
*/
public ExtObjectContainer createObjectContainer()
{
+ final Configuration config = Db4o.newConfiguration();
+ configure(config);
if (!isClientServer()) {
- return Db4o.openFile(Db4oTeam.PATH).ext();
+ return Db4o.openFile(config, Db4oTeam.PATH).ext();
}
if(isClientServerOverTcp()){
- return Db4o.openClient(Db4oTeam.SERVER_HOST, Db4oTeam.SERVER_PORT, Db4oTeam.SERVER_USER, Db4oTeam.SERVER_PASSWORD).ext();
+ return Db4o.openClient(config, Db4oTeam.SERVER_HOST, Db4oTeam.SERVER_PORT, Db4oTeam.SERVER_USER, Db4oTeam.SERVER_PASSWORD).ext();
}
// embedded client server mode
return Db4oTeam.server.openClient().ext();
@@ -70,4 +74,54 @@
private boolean isClientServerOverTcp() {
return Db4oOptions.containsOption(_options, Db4oOptions.CLIENT_SERVER_TCP);
}
+
+
+
+ public void configure(Configuration config) {
+
+ if(_configurations != null){
+ for(ConfigurationSetting setting : _configurations){
+ setting.apply(config);
+ }
+ }
+
+ if(_options != null){
+ for (int i = 0; i < _options.length; i++) {
+ try{
+ switch (_options[i]){
+ case Db4oOptions.NO_FLUSH:
+ config.flushFileBuffers(false);
+ break;
+ case Db4oOptions.MEMORY_IO:
+ config.io(new com.db4o.io.MemoryIoAdapter());
+ break;
+ case Db4oOptions.CACHED_BTREE_ROOT:
+ config.bTreeCacheHeight(1);
+ break;
+ case Db4oOptions.LAZY_QUERIES:
+ config.queries().evaluationMode(QueryEvaluationMode.LAZY);
+ break;
+ case Db4oOptions.SNAPSHOT_QUERIES:
+ config.queries().evaluationMode(QueryEvaluationMode.SNAPSHOT);
+ break;
+ case Db4oOptions.INDEX_FREESPACE:
+ config.freespace().useIndexSystem();
+ break;
+ case Db4oOptions.BTREE_FREESPACE:
+ config.freespace().useBTreeSystem();
+ break;
+ default:
+
+ }
+ }catch (Throwable t){
+ System.err.println("db4o option not available in this version");
+ t.printStackTrace();
+ }
+ }
+ }
+ }
+
+
+
+
}
Modified: trunk/polepos/src/org/polepos/teams/db4o/Db4oTeam.java
===================================================================
--- trunk/polepos/src/org/polepos/teams/db4o/Db4oTeam.java 2008-06-12 12:31:29 UTC (rev 77)
+++ trunk/polepos/src/org/polepos/teams/db4o/Db4oTeam.java 2008-11-13 15:55:27 UTC (rev 78)
@@ -36,6 +36,8 @@
private final List<Driver> _drivers;
private int[] _options;
+
+ private ConfigurationSetting[] _configurations;
public static ObjectServer server;
@@ -85,7 +87,7 @@
@Override
public Car[] cars(){
- return new Car[]{ new Db4oCar(_options) };
+ return new Car[]{ new Db4oCar(_options, _configurations) };
}
public void addDriver(Driver driver){
@@ -113,9 +115,17 @@
}
@Override
- public void configure(int[] options) {
+ public void configure(int[] options, ConfigurationSetting[] configurations) {
_options = options;
+ _configurations = configurations;
_name = db4oName();
+
+ if(configurations != null){
+ for (int i = 0; i < configurations.length; i++) {
+ _name += " " + configurations[i].name();
+ }
+ }
+
if(options != null){
for (int i = 0; i < options.length; i++) {
try{
Modified: trunk/polepos/src/org/polepos/teams/hibernate/HibernateTeam.java
===================================================================
--- trunk/polepos/src/org/polepos/teams/hibernate/HibernateTeam.java 2008-06-12 12:31:29 UTC (rev 77)
+++ trunk/polepos/src/org/polepos/teams/hibernate/HibernateTeam.java 2008-11-13 15:55:27 UTC (rev 78)
@@ -69,10 +69,4 @@
return "http://www.hibernate.org";
}
- @Override
- public void configure(int[] options) {
- // TODO Auto-generated method stub
-
- }
-
}
Modified: trunk/polepos/src/org/polepos/teams/jdbc/JdbcTeam.java
===================================================================
--- trunk/polepos/src/org/polepos/teams/jdbc/JdbcTeam.java 2008-06-12 12:31:29 UTC (rev 77)
+++ trunk/polepos/src/org/polepos/teams/jdbc/JdbcTeam.java 2008-11-13 15:55:27 UTC (rev 78)
@@ -76,11 +76,5 @@
// not supported yet
return null;
}
-
- @Override
- public void configure(int[] options) {
- // TODO Auto-generated method stub
- }
-
}
Modified: trunk/polepos/src/org/polepos/teams/jdo/JdoTeam.java
===================================================================
--- trunk/polepos/src/org/polepos/teams/jdo/JdoTeam.java 2008-06-12 12:31:29 UTC (rev 77)
+++ trunk/polepos/src/org/polepos/teams/jdo/JdoTeam.java 2008-11-13 15:55:27 UTC (rev 78)
@@ -102,14 +102,5 @@
public String website() {
return null;
}
-
-
- @Override
- public void configure(int[] options) {
- // TODO Auto-generated method stub
-
- }
-
-
}
Modified: trunk/polepos/src/org/polepos/teams/jorm/JormTeam.java
===================================================================
--- trunk/polepos/src/org/polepos/teams/jorm/JormTeam.java 2008-06-12 12:31:29 UTC (rev 77)
+++ trunk/polepos/src/org/polepos/teams/jorm/JormTeam.java 2008-11-13 15:55:27 UTC (rev 78)
@@ -41,11 +41,6 @@
DB.session().delete(Persistent.class);
}
-
- public void configure(int[] options) {
-
- }
-
public String name(){
return "GNA-JORM";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|