To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit ad34237a authored by john's avatar john
Browse files

Separated harness and additional benchmark code.

Separated Digest into a separate library for inclusion in Tomcat and default Harness.
Removed dependency in H2 benchmark code on Config (and commons cli).
Top-level harness now loads classes through a separate class loader, which has a
common parent with the benchmark class loader, but is not itself an ancestor or the
benchmark class loader.  This isolates harness code from benchmark code.
parent 44f882fe
/*
* Copyright (c) 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
import org.dacapo.harness.Benchmark;
import org.dacapo.parser.Config;
/**
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Avrora.java 738 2009-12-24 00:19:36Z steveb-oss $
*/
public class Avrora extends Benchmark {
String[] args;
public Avrora(Config config, File scratch) throws Exception {
super(config, scratch);
Class<?> clazz = Class.forName("avrora.Main", true, loader);
this.method = clazz.getMethod("main", String[].class);
}
@Override
protected void prepare(String size) throws Exception {
super.prepare(size);
args = config.preprocessArgs(size, scratch);
/* Retarget input/output files into scratch directory */
for (int i = 0; i < args.length; i++) {
if (args[i].charAt(0) != '-')
args[i] = fileInScratch(args[i]);
}
}
public void iterate(String size) throws Exception {
method.invoke(null, (Object) args);
}
}
/*
* Copyright (c) 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
import java.lang.reflect.Constructor;
import java.util.Vector;
import org.dacapo.harness.Benchmark;
import org.dacapo.parser.Config;
/**
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Batik.java 738 2009-12-24 00:19:36Z steveb-oss $
*/
public class Batik extends Benchmark {
private String[] args;
private final Constructor<?> constructor;
public Batik(Config config, File scratch) throws Exception {
super(config, scratch, false);
Class<?> clazz = Class.forName("org.apache.batik.apps.rasterizer.Main", true, loader);
this.method = clazz.getMethod("execute");
this.constructor = clazz.getConstructor(String[].class);
}
@Override
protected void prepare(String size) throws Exception {
super.prepare(size);
String[] args = config.preprocessArgs(size, scratch);
Vector<String> newArgs = new Vector<String>(args.length + 2);
for (int i = 0; i < args.length; i++) {
if (args[i].charAt(0) == '-') {
if (args[i].equals("-m") || args[i].equals("-d")) {
newArgs.add(args[i]);
newArgs.add(args[++i]);
} else
newArgs.add(args[i]);
} else
newArgs.add((new File(scratch, args[i])).getPath());
}
String[] newArgStrings = (String[]) newArgs.toArray(new String[0]);
if (getVerbose()) {
for (int i = 0; i < newArgStrings.length; i++)
System.out.print(newArgStrings[i] + " ");
System.out.println();
}
this.args = newArgStrings;
}
/**
* Args is a list of file names relative to the scratch directory
*/
public void iterate(String size) throws Exception {
Object object = constructor.newInstance((Object) args);
method.invoke(object);
}
}
......@@ -16,17 +16,21 @@
<property name="bm-files" value="${basedir}/bms/${bm-name}"/>
<property name="bm-build-dir" value="${bm-files}/build"/>
<property name="bm-output-dir" value="${bm-files}/dist"/>
<property name="bm-output-harness-dir" value="${bm-files}/dist/harness"/>
<property name="bm-output-benchmark-dir" value="${bm-files}/dist/benchmark"/>
<property name="bm-deps-output-dir" value="${bm-files}/deps"/>
<property name="bm-data" value="${bm-files}/data"/>
<available file="${bm-data}" property="bm-data-exists" type="dir"/>
<property name="bm-src-dir" value="${bm-files}/src"/>
<property name="bm-src-harness-dir" value="${bm-files}/harness"/>
<property name="bm-src-benchmark-dir" value="${bm-files}/benchmark"/>
<property name="bm-downloads" value="${bm-files}/downloads"/>
<property name="bm-jars" value="${bm-output-dir}/jar"/>
<property name="bm-dat" value="${bm-output-dir}/dat"/>
<property name="bm-cnf" value="${bm-output-dir}/cnf"/>
<property name="harness-classpath" value="harness/dist"/>
<property name="harness-classpath" value="harness/dist/harness"/>
<target name="all" depends="source, svn-source, cvs-source, pre-build, build, complete"/>
......@@ -78,7 +82,9 @@
</target>
<target name="init" depends="clean">
<mkdir dir="${bm-build-dir}"/>
<mkdir dir="${bm-output-dir}"/>
<mkdir dir="${bm-output-harness-dir}"/>
<mkdir dir="${bm-jars}"/>
<mkdir dir="${bm-dat}"/>
<mkdir dir="${bm-cnf}"/>
......@@ -96,12 +102,18 @@
<copy file="${bm-files}/${bm-name}.cnf" todir="${bm-cnf}"/>
</target>
<target name="harness" depends="bm-harness"/>
<target name="harness" depends="bm-harness-with,bm-harness-without"/>
<target name="bm-harness-without" unless="bm-harness-classpath">
<javac srcdir="${bm-src-harness-dir}" classpath="${harness-classpath}" destdir="${bm-output-harness-dir}"
includes="org/dacapo/harness/**"
debug="true" debuglevel="lines,vars,source"/>
</target>
<target name="bm-harness">
<javac srcdir="${bm-src-dir}" classpath="${harness-classpath}:${bm-harness-classpath}" destdir="${bm-output-dir}"
includes="org/dacapo/harness/**"
debug="true" debuglevel="lines,vars,source"/>
<target name="bm-harness-with" if="bm-harness-classpath">
<javac srcdir="${bm-src-harness-dir}" classpath="${harness-classpath}:${bm-harness-classpath}" destdir="${bm-output-harness-dir}"
includes="org/dacapo/harness/**"
debug="true" debuglevel="lines,vars,source"/>
</target>
<target name="dacapo-harness" unless="incremental-build">
......
......@@ -37,15 +37,6 @@
</antcall>
</target>
<target name="bm-harness">
<javac srcdir="${bm-src-dir}" destdir="${bm-output-dir}" includes="org/dacapo/harness/*.java"
debug="true" debuglevel="lines,vars,source">
<classpath>
<pathelement path="${harness-classpath}"/>
</classpath>
</javac>
</target>
<target name="unpack" depends="untar"/>
<target name="bm-build">
......
/*
* Copyright (c) 2005, 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
//import org.eclipse.core.runtime.adaptor.EclipseStarter;
import java.lang.reflect.Method;
import org.dacapo.harness.Benchmark;
import org.dacapo.parser.Config;
/**
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Eclipse.java 738 2009-12-24 00:19:36Z steveb-oss $
*/
public class Eclipse extends Benchmark {
static final String WKSP_DIRECTORY_RELATIVE_TO_SCRATCH = "workspace";
static final String PLUGIN_ID = "org.dacapo.eclipse.Harness";
static final String OSGI_BOOTSTRAP_JAR = "eclipse" + File.separator + "plugins" + File.separator + "org.eclipse.osgi_3.5.1.R35x_v20090827.jar";
static String oldJavaHome = null;
static Eclipse eclipse;
static String size;
private final Method isRunning;
private final Method run;
private final Method shutdown;
public Eclipse(Config config, File scratch) throws Exception {
super(config, scratch, false);
Class<?> clazz = Class.forName("org.eclipse.core.runtime.adaptor.EclipseStarter", true, loader);
this.method = clazz.getMethod("startup", String[].class, Runnable.class);
this.isRunning = clazz.getMethod("isRunning");
this.run = clazz.getMethod("run", Object.class);
this.shutdown = clazz.getMethod("shutdown");
}
public void preIteration(String size) throws Exception {
super.preIteration(size);
if (!((Boolean) isRunning.invoke(null, (Object[]) null)).booleanValue()) {
startup(size);
}
setJavaHomeIfRequired();
try {
String[] largePluginArgs = { "large", "unzip" };
String[] pluginArgs = { "unzip" };
run.invoke(null, new Object[] { size.equals("large") ? largePluginArgs : pluginArgs });
} catch (Exception e) {
e.printStackTrace();
}
}
public void iterate(String size) throws Exception {
try {
// String[] pluginArgs = {"setup", "alltests" }; // get this from the bm
// config
String[] pluginArgs = config.getArgs(size);
run.invoke(null, new Object[] { pluginArgs });
} catch (Exception e) {
e.printStackTrace();
}
}
public void postIteration(String size) throws Exception {
try {
String[] pluginArgs = { "teardown" };
run.invoke(null, new Object[] { pluginArgs });
} catch (Exception e) {
e.printStackTrace();
}
super.postIteration(size);
restoreJavaHomeIfRequired();
}
public void cleanup() {
try {
shutdown.invoke(null, (Object[]) null);
} catch (Exception e) {
e.printStackTrace();
}
}
private void startup(String size) {
try {
System.setProperty("osgi.os", "linux");
System.setProperty("osgi.ws", "gtk");
System.setProperty("osgi.arch", "x86");
System.setProperty("osgi.install.area", "file:" + fileInScratch("eclipse/"));
System.setProperty("osgi.noShutdown", "true");
System.setProperty("osgi.framework", "file:" + fileInScratch(OSGI_BOOTSTRAP_JAR));
setJavaHomeIfRequired();
String[] args = new String[4];
args[0] = "-data"; // identify the workspace
args[1] = fileInScratch(WKSP_DIRECTORY_RELATIVE_TO_SCRATCH);
args[2] = "-application"; // identify the plugin
args[3] = PLUGIN_ID;
method.invoke(null, new Object[] { args, null });
} catch (Exception e) {
e.printStackTrace();
}
}
private void setJavaHomeIfRequired() {
String eclipseJavaHome = System.getProperty("eclipse.java.home");
if (eclipseJavaHome != null) {
oldJavaHome = System.getProperty("java.home");
System.setProperty("java.home", eclipseJavaHome);
}
}
private void restoreJavaHomeIfRequired() {
if (oldJavaHome != null)
System.setProperty("java.home", oldJavaHome);
}
}
......@@ -17,7 +17,7 @@
<import file="../common.xml" />
<property name="bm-harness-classpath" value="${bm-jars}/fop.jar" />
<!-- <property name="bm-harness-classpath" value="${bm-jars}/fop.jar" /> -->
<property name="bm-build-top" value="${bm-build-dir}/${bm-name}-${bm-version}" />
<target name="unpack" depends="untar, patch" />
......
/*
* Copyright (c) 2005, 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
import org.dacapo.harness.Benchmark;
import org.dacapo.parser.Config;
/**
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Fop.java 738 2009-12-24 00:19:36Z steveb-oss $
*/
public class Fop extends Benchmark {
private String[] args;
public Fop(Config config, File scratch) throws Exception {
super(config, scratch);
Class<?> clazz = Class.forName("org.apache.fop.cli.Main", true, loader);
this.method = clazz.getMethod("startFOP", new Class[] { String[].class });
}
@Override
protected void prepare(String size) throws Exception {
super.prepare(size);
args = config.preprocessArgs(size, scratch);
/* Retarget input/output files into scratch directory */
for (int i = 0; i < args.length; i++)
if (args[i].charAt(0) != '-')
args[i] = fileInScratch(args[i]);
}
public void iterate(String size) throws Exception {
method.invoke(null, new Object[] { args });
}
}
......@@ -14,35 +14,23 @@
<import file="../common.xml"/>
<target name="bm-harness" depends="junit,h2,derby">
<javac srcdir="${bm-src-dir}" destdir="${bm-output-dir}"
sourcepath="${bm-src-dir}"
source="1.5"
debug="true" debuglevel="lines,vars,source">
<target name="bm-build" depends="junit,h2,derby">
<javac srcdir="${bm-src-dir}" destdir="${bm-build-dir}"
sourcepath="${bm-src-dir}"
source="1.5">
<classpath>
<!-- note that the jars build are either in the jars/sane or jars/insane
directory depending upon the build environment, however, they are
never in both directories -->
<pathelement location="${derbytesting-jar}"/>
<pathelement location="${h2-jar}"/>
<pathelement location="${junit-jar}"/>
<pathelement path="${bm-output-dir}"/>
<pathelement path="${harness-classpath}"/>
</classpath>
</javac>
<jar destfile="${bm-jars}/tpcc.jar">
<fileset dir="${bm-output-dir}">
<fileset dir="${bm-build-dir}">
<include name="org/dacapo/h2/**"/>
</fileset>
</jar>
<delete dir="${bm-output-dir}/org/dacapo/h2"/>
</target>
<target name="bm-build" depends="junit,h2,derby"/>
</project>
/*******************************************************************************
* Copyright (c) 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0
*
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: H2.java 738 2009-12-24 00:19:36Z steveb-oss $
*******************************************************************************/
package org.dacapo.harness;
import java.io.File;
import java.io.PrintStream;
import java.lang.reflect.Method;
import java.util.TreeMap;
import org.dacapo.harness.Benchmark;
import org.dacapo.parser.Config;
/**
* Dacapo benchmark harness for TPC-C like workload running on H2.
*
* Apache authored the original TPC-C like workload.
* H2 Group, H2 authored the database H2.
*
* @author Apache
* @author H2
*
*/
public class H2 extends Benchmark {
private Object tpcc;
private Method makeTPCC;
private Method prepareTPCC;
private Method preIterationTPCC;
private Method iterationTPCC;
private Method postIterationTPCC;
public H2(Config config, File scratch) throws Exception {
super(config, scratch, false);
}
@Override
protected void prepare() throws Exception {
useBenchmarkClassLoader();
try {
Class<?> tpccClazz = Class.forName("org.dacapo.h2.TPCC",true,loader);
// this.makeTPCC = tpccClazz.getMethod("make", Config.class, File.class, Boolean.class, Boolean.class);
this.makeTPCC = tpccClazz.getMethod("make", TreeMap.class, TreeMap.class, File.class, Boolean.class, Boolean.class);
this.prepareTPCC = tpccClazz.getMethod("prepare", String.class);
this.preIterationTPCC = tpccClazz.getMethod("preIteration", String.class);
this.iterationTPCC = tpccClazz.getMethod("iteration", String.class);
this.postIterationTPCC = tpccClazz.getMethod("postIteration", String.class);
TreeMap<String,String> threadMap = new TreeMap<String,String>();
TreeMap<String,String[]> argMap = new TreeMap<String,String[]>();
for(String size: config.getSizes()) {
String[] args = config.preprocessArgs(size, scratch);
argMap.put(size,args);
threadMap.put(size, Integer.toString(config.getThreadCount(size)));
}
// construct the benchmark
this.tpcc = this.makeTPCC.invoke(null, threadMap, argMap, scratch, getVerbose(), getPreserve());
} finally {
revertClassLoader();
}
}
/**
* The benchmark run
*/
@Override
public void prepare(String size) throws Exception {
useBenchmarkClassLoader();
try {
this.prepareTPCC.invoke(this.tpcc, size);
} finally {
revertClassLoader();
}
}
@Override
public void preIteration(String size) throws Exception {
useBenchmarkClassLoader();
try {
this.preIterationTPCC.invoke(this.tpcc, size);
} finally {
revertClassLoader();
}
}
@Override
public void iterate(String size) throws Exception {
useBenchmarkClassLoader();
try {
this.iterationTPCC.invoke(this.tpcc, size);
} finally {
revertClassLoader();
}
}
@Override
public void postIteration(String size) throws Exception {
useBenchmarkClassLoader();
try {
this.postIterationTPCC.invoke(this.tpcc, size);
} finally {
revertClassLoader();
super.postIteration(size);
}
}
@Override
public void cleanup() {
this.tpcc = null;
this.makeTPCC = null;
this.prepareTPCC = null;
this.preIterationTPCC = null;
this.iterationTPCC = null;
this.postIterationTPCC = null;
super.cleanup();
}
}
......@@ -24,6 +24,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.TreeMap;
import javax.sql.DataSource;
......@@ -36,7 +37,6 @@ import org.apache.derbyTesting.system.oe.direct.Standard;
import org.apache.derbyTesting.system.oe.load.ThreadInsert;
import org.apache.derbyTesting.system.oe.util.OERandom;
import org.dacapo.parser.Config;
import org.h2.tools.RunScript;
import org.h2.tools.Backup;
import org.h2.tools.Restore;
......@@ -95,7 +95,9 @@ public class TPCC {
private TPCCReporter reporter = new TPCCReporter();
private OERandom[] rands;
private Config config;
private TreeMap<String,String> threadMap;
private TreeMap<String,String[]> argMap;
private File scratch;
private boolean verbose;
private boolean preserve;
......@@ -120,12 +122,15 @@ public class TPCC {
final static long SEED = 897523978813691l;
final static int SEED_STEP = 100000;
public static TPCC make(Config config, File scratch, Boolean verbose, Boolean preserve) throws Exception {
return new TPCC(config, scratch, verbose, preserve);
public static TPCC make(TreeMap<String,String> threadMap, TreeMap<String,String[]> argMap, File scratch, Boolean verbose, Boolean preserve) throws Exception {
return new TPCC(threadMap, argMap, scratch, verbose, preserve);
}
public TPCC(Config config, File scratch, boolean verbose, boolean preserve) throws Exception {
this.config = config;
public TPCC(TreeMap<String,String> threadMap, TreeMap<String,String[]> argMap, File scratch, boolean verbose, boolean preserve) throws Exception {
this.threadMap = threadMap;
this.argMap = argMap;
this.scratch = scratch;
this.verbose = verbose;
this.preserve = preserve;
......@@ -653,9 +658,9 @@ public class TPCC {
// helper function for interpreting the configuration data
private void configure() {
String[] args = config.preprocessArgs(size, scratch);
this.numberOfTerminals = config.getThreadCount(size);
String[] args = argMap.get(size);
this.numberOfTerminals = Integer.parseInt(threadMap.get(size));
for (int i = 0; i < args.length; i++) {
if ("--numberOfTerminals".equalsIgnoreCase(args[i]))