Permalink
Browse files

changes to benchmark controller to allow running stored procedure aft…

…er start of benchmark
  • Loading branch information...
Rebecca Taft
Rebecca Taft committed Apr 15, 2014
1 parent afed61d commit c34f3c0195fbbd8f59837517162f578006341240
View
@@ -1732,6 +1732,21 @@ TEST CASES
&common;
<!-- Optional sysproc -->
<arg value="PROC=${proc}" />
<arg value="PROCSTARTTIME=${proc_start_time}" />
<arg value="PARAMS=${params}" />
<arg value="PARAM0=${param0}" />
<arg value="PARAM1=${param1}" />
<arg value="PARAM2=${param2}" />
<arg value="PARAM3=${param3}" />
<arg value="PARAM4=${param4}" />
<arg value="PARAM5=${param5}" />
<arg value="PARAM6=${param6}" />
<arg value="PARAM7=${param7}" />
<arg value="PARAM8=${param8}" />
<arg value="PARAM9=${param9}" />
<!-- Benchmark Parameters -->
<arg value="benchmark.conf=${benchmark.conf}" />
<arg value="benchmark.builder=${benchmark.builder}" />
@@ -107,6 +107,10 @@
public boolean dumpDatabase;
public String dumpDatabaseDir;
public String procName;
public int procStartTime;
public Object[] params;
public final Map<String, String> clientParameters = new TreeMap<String, String>();
public final Map<String, String> siteParameters = new TreeMap<String, String>();
@@ -225,7 +229,10 @@ public BenchmarkConfig(
String evictable[],
String deferrable[],
boolean dumpDatabase,
String dumpDatabaseDir
String dumpDatabaseDir,
String procName,
int procStartTime,
Object[] params
) {
this.projectBuilderClass = benchmarkClient;
@@ -292,6 +299,10 @@ public BenchmarkConfig(
this.dumpDatabase = dumpDatabase;
this.dumpDatabaseDir = dumpDatabaseDir;
this.procName = procName;
this.procStartTime = procStartTime;
this.params = params;
this.hstore_conf = hstore_conf;
this.hstore_conf_path = hstore_conf_path;
this.benchmark_conf_path = benchmark_conf_path;
@@ -63,6 +63,7 @@
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -275,6 +276,58 @@ public void update(EventObservable<String> o, String msg) {
}
};
public class RunSysProc extends Thread {
public final int waitTime;
public final Client client;
public final String procName;
public final Object[] params;
public RunSysProc(int waitTime, Client client, String procName, Object[] params) {
this.waitTime = waitTime;
this.client = client;
this.procName = procName;
this.params = params;
}
public void run() {
long nowTime = System.currentTimeMillis();
long startTime = nowTime + waitTime;
while (nowTime < startTime) {
long sleepTime = startTime - nowTime;
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
LOG.error("Error sleeping", e);
}
nowTime = System.currentTimeMillis();
}
// run sysproc
ClientResponse cr = null;
try {
cr = client.callProcedure(procName, params);
} catch (Exception ex) {
LOG.error("Failed to execute sysproc " + procName, ex);
}
if(cr != null) {
Map<String, Object> m = new LinkedHashMap<String, Object>();
for (int i = 0; i < cr.getResults().length; i++) {
VoltTable vt = cr.getResults()[i];
m.put(String.format(" [%02d]", i), vt);
} // FOR
LOG.info(StringUtil.repeat("-", 50));
LOG.info(String.format("%s Txn #%d - Status %s\n%s",
procName,
cr.getTransactionId(),
cr.getStatus(),
cr.toString()));
}
}
}
@SuppressWarnings("unchecked")
public BenchmarkController(BenchmarkConfig config, CatalogContext catalogContext) {
this.m_config = config;
@@ -1199,6 +1252,15 @@ public void runBenchmark() throws Exception {
}
//
if(m_config.procName != null) {
Object[] params = m_config.params;
if(params == null) {
params = new Object[]{};
}
RunSysProc runSysProc = new RunSysProc(m_config.procStartTime, local_client, m_config.procName, params);
runSysProc.start();
}
long startTime = System.currentTimeMillis();
nextIntervalTime += startTime;
long nowTime = startTime;
@@ -1787,6 +1849,10 @@ public static void main(final String[] vargs) throws Exception {
boolean dumpDatabase = false;
String dumpDatabaseDir = null;
String procName = null;
Object[] params = null;
int procStartTime = 0;
// List of SiteIds that we won't start because they'll be started by the profiler
Set<Integer> profileSiteIds = new HashSet<Integer>();
@@ -2026,6 +2092,19 @@ else if (parts[0].equalsIgnoreCase("NOSITES") || parts[0].equalsIgnoreCase("NOST
} else if (parts[0].equalsIgnoreCase("DUMPDATABASEDIR")) {
dumpDatabaseDir = parts[1];
} else if (parts[0].equalsIgnoreCase("PROC")) {
procName = parts[1];
} else if (parts[0].equalsIgnoreCase("PROCSTARTTIME")) {
procStartTime = Integer.parseInt(parts[1]);
} else if (parts[0].equalsIgnoreCase("PARAMS")) {
params = new Object[]{ parts[1] };
} else if (parts[0].matches("(?i)PARAM[0-9]")) {
if(params == null) {
params = new Object[10];
}
int paramIndex = Integer.parseInt(parts[0].substring(5));
params[paramIndex] = parts[1];
} else if (parts[0].equalsIgnoreCase(HStoreConstants.BENCHMARK_PARAM_PREFIX + "INITIAL_POLLING_DELAY")) {
clientInitialPollingDelay = Integer.parseInt(parts[1]);
} else {
@@ -2147,7 +2226,10 @@ else if (hstore_conf.client.threads_per_host <= 0) {
evictable,
deferrable,
dumpDatabase,
dumpDatabaseDir
dumpDatabaseDir,
procName,
procStartTime,
params
);
// Always pass these parameters

0 comments on commit c34f3c0

Please sign in to comment.