}
private void warmup() throws InterruptedException {
long startTime = System.currentTimeMillis();
TaskRunner runner = new TaskRunner(NUM_THREADS);
log.warn("Starting warmup");
// creates all the Fqns since this can be expensive and we don't really want to measure this (for now)
for (final Fqn fqn : fqns) {
runner.execute(new Runnable() {
public void run() {
try {
// this will create the necessary nodes.
cache.put(fqn, "key", Collections.emptyMap());
}
catch (Exception e) {
log.warn("Caught Exception", e);
}
}
});
}
// loop through WARMUP_LOOPS gets and puts for JVM optimisation
for (int i = 0; i < WARMUP_LOOPS; i++) {
runner.execute(new Runnable() {
public void run() {
try {
Fqn fqn = Generator.getRandomElement(fqns);
DummyTransactionManager.getInstance().begin();
cache.get(fqn, "key");
DummyTransactionManager.getInstance().commit();
DummyTransactionManager.getInstance().begin();
cache.put(fqn, "key", "Value");
DummyTransactionManager.getInstance().commit();
DummyTransactionManager.getInstance().begin();
cache.remove(fqn, "key");
DummyTransactionManager.getInstance().commit();
}
catch (Exception e) {
log.warn("Caught Exception", e);
}
}
});
}
runner.stop();
long duration = System.currentTimeMillis() - startTime;
log.warn("Finished warmup. " + printDuration(duration));
//cache.removeNode(Fqn.ROOT);
// cache.stop();