use of org.voltdb.client.NullCallback in project voltdb by VoltDB.
the class BidGenerator method run.
/**
* This is the "run" method for this Runnable subclass.
*
* Generate one new row for the bids table, and insert it.
*/
@Override
public void run() {
long bidId = m_bidId++;
long advertiserId = Math.abs(m_rand.nextLong()) % NUM_ADVERTISERS;
GeographyValue bidRegion = Regions.pickRandomRegion();
TimestampType bidStartTime = new TimestampType();
TimestampType bidEndTime = new TimestampType(bidStartTime.getTime() + AdBrokerBenchmark.BID_DURATION_SECONDS * 1000000);
// Amount of bid: a hundredth of a penny up to around a tenth of a penny.
double amount = 0.00001 + 0.01 * m_rand.nextDouble();
DecimalFormat df = new DecimalFormat("#.####");
amount = Double.valueOf(df.format(amount));
try {
m_client.callProcedure(new NullCallback(), "bids.Insert", bidId, advertiserId, bidRegion, bidStartTime, bidEndTime, amount);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.voltdb.client.NullCallback in project voltdb by VoltDB.
the class HTTPBenchmark method runBenchmark.
/**
* Core benchmark code. Connect. Initialize. Run the loop. Cleanup. Print Results.
*
* @throws Exception if anything unexpected happens.
*/
public void runBenchmark() throws Exception {
System.out.print(HORIZONTAL_RULE);
System.out.println(" Setup & Initialization");
System.out.println(HORIZONTAL_RULE);
// connect to one or more servers, loop until success
connect(config.servers);
// preload keys if requested
System.out.println();
if (config.preload) {
System.out.println("Preloading data store...");
for (int i = 0; i < config.poolsize; i++) {
client.callProcedure(new NullCallback(), "Put", String.format(processor.KeyFormat, i), processor.generateForStore().getStoreValue());
}
client.drain();
System.out.println("Preloading complete.\n");
}
System.out.print(HORIZONTAL_RULE);
System.out.println(" Starting Benchmark");
System.out.println(HORIZONTAL_RULE);
// create/start the requested number of threads
Thread[] kvThreads = new Thread[config.threads];
for (int i = 0; i < config.threads; ++i) {
kvThreads[i] = new Thread(new KVThread());
kvThreads[i].start();
}
// Run the benchmark loop for the requested warmup time
System.out.println("Warming up...");
Thread.sleep(1000l * config.warmup);
// signal to threads to end the warmup phase
warmupComplete.set(true);
// reset the stats after warmup
fullStatsContext.fetchAndResetBaseline();
periodicStatsContext.fetchAndResetBaseline();
// print periodic statistics to the console
benchmarkStartTS = System.currentTimeMillis();
schedulePeriodicStats();
// Run the benchmark loop for the requested warmup time
System.out.println("\nRunning benchmark...");
Thread.sleep(1000l * config.duration);
// stop the threads
benchmarkComplete.set(true);
// cancel periodic stats printing
timer.cancel();
// block until all outstanding txns return
client.drain();
// join on the threads
for (Thread t : kvThreads) {
t.join();
}
// print the summary results
printResults();
// close down the client connections
client.close();
// if enabled close the graphite logger
if (graphite != null) {
graphite.close();
}
// if enabled close the csv logger
if (csvlogger != null) {
csvlogger.close();
}
}
use of org.voltdb.client.NullCallback in project voltdb by VoltDB.
the class SyncBenchmark method runBenchmark.
/**
* Core benchmark code.
* Connect. Initialize. Run the loop. Cleanup. Print Results.
*
* @throws Exception if anything unexpected happens.
*/
public void runBenchmark() throws Exception {
System.out.print(HORIZONTAL_RULE);
System.out.println(" Setup & Initialization");
System.out.println(HORIZONTAL_RULE);
// connect to one or more servers, loop until success
connect(config.servers);
// preload keys if requested
System.out.println();
if (config.preload) {
System.out.println("Preloading data store...");
for (int i = 0; i < config.poolsize; i++) {
client.callProcedure(new NullCallback(), "Put", String.format(processor.KeyFormat, i), processor.generateForStore().getStoreValue());
}
client.drain();
System.out.println("Preloading complete.\n");
}
System.out.print(HORIZONTAL_RULE);
System.out.println(" Starting Benchmark");
System.out.println(HORIZONTAL_RULE);
// create/start the requested number of threads
Thread[] kvThreads = new Thread[config.threads];
for (int i = 0; i < config.threads; ++i) {
kvThreads[i] = new Thread(new KVThread());
kvThreads[i].start();
}
// Run the benchmark loop for the requested warmup time
System.out.println("Warming up...");
Thread.sleep(1000l * config.warmup);
// signal to threads to end the warmup phase
warmupComplete.set(true);
// reset the stats after warmup
fullStatsContext.fetchAndResetBaseline();
periodicStatsContext.fetchAndResetBaseline();
// print periodic statistics to the console
benchmarkStartTS = System.currentTimeMillis();
schedulePeriodicStats();
// Run the benchmark loop for the requested warmup time
System.out.println("\nRunning benchmark...");
if (config.maxops > 0) {
while (allOps.get() < config.maxops) {
Thread.sleep(5_000);
}
} else {
Thread.sleep(1000l * config.duration);
}
// stop the threads
benchmarkComplete.set(true);
// cancel periodic stats printing
timer.cancel();
// block until all outstanding txns return
client.drain();
// join on the threads
for (Thread t : kvThreads) {
t.join();
}
// print the summary results
printResults();
// close down the client connections
client.close();
// if enabled close the graphite logger
if (graphite != null) {
graphite.close();
}
// if enabled close the csv logger
if (csvlogger != null) {
csvlogger.close();
}
}
use of org.voltdb.client.NullCallback in project voltdb by VoltDB.
the class HTTPBenchmark method runBenchmark.
/**
* Core benchmark code. Connect. Initialize. Run the loop. Cleanup. Print Results.
*
* @throws Exception if anything unexpected happens.
*/
public void runBenchmark() throws Exception {
System.out.print(HORIZONTAL_RULE);
System.out.println(" Setup & Initialization");
System.out.println(HORIZONTAL_RULE);
// connect to one or more servers, loop until success
connect(config.servers);
// preload keys if requested
System.out.println();
if (config.preload) {
System.out.println("Preloading data store...");
for (int i = 0; i < config.poolsize; i++) {
client.callProcedure(new NullCallback(), "Put", String.format(processor.KeyFormat, i), processor.generateForStore().getStoreValue());
}
client.drain();
System.out.println("Preloading complete.\n");
}
System.out.print(HORIZONTAL_RULE);
System.out.println(" Starting Benchmark");
System.out.println(HORIZONTAL_RULE);
// setup the HTTP connection pool that will be used by the threads
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(config.threads * 2);
cm.setDefaultMaxPerRoute(config.threads);
CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(cm).build();
String[] servers = config.servers.split(",");
// create/start the requested number of threads
Thread[] kvThreads = new Thread[config.threads];
for (int i = 0; i < config.threads; ++i) {
HttpPost httppost = new HttpPost("http://" + servers[i % servers.length] + ":8080/api/1.0/");
kvThreads[i] = new Thread(new KVThread(httpclient, httppost));
kvThreads[i].start();
}
// Run the benchmark loop for the requested warmup time
System.out.println("Warming up...");
Thread.sleep(1000l * config.warmup);
// signal to threads to end the warmup phase
warmupComplete.set(true);
// Run the benchmark loop for the requested warmup time
System.out.println("\nRunning benchmark...");
Thread.sleep(1000l * config.duration);
// stop the threads
benchmarkComplete.set(true);
// cancel periodic stats printing
// timer.cancel();
// block until all outstanding txns return
client.drain();
// join on the threads
for (Thread t : kvThreads) {
t.join();
}
// print the summary results
printResults();
// close down the client connections
client.close();
}
use of org.voltdb.client.NullCallback in project voltdb by VoltDB.
the class SyncBenchmark method runBenchmark.
/**
* Core benchmark code.
* Connect. Initialize. Run the loop. Cleanup. Print Results.
*
* @throws Exception if anything unexpected happens.
*/
public void runBenchmark() throws Exception {
System.out.print(HORIZONTAL_RULE);
System.out.println(" Setup & Initialization");
System.out.println(HORIZONTAL_RULE);
// connect to one or more servers, loop until success
connect(config.servers);
// preload keys if requested
System.out.println();
if (config.preload) {
System.out.println("Preloading data store...");
for (int i = 0; i < config.poolsize; i++) {
client.callProcedure(new NullCallback(), "Put", String.format(processor.KeyFormat, i), processor.generateForStore().getStoreValue());
}
client.drain();
System.out.println("Preloading complete.\n");
}
System.out.print(HORIZONTAL_RULE);
System.out.println(" Starting Benchmark");
System.out.println(HORIZONTAL_RULE);
// create/start the requested number of threads
Thread[] kvThreads = new Thread[config.threads];
for (int i = 0; i < config.threads; ++i) {
kvThreads[i] = new Thread(new KVThread());
kvThreads[i].start();
}
// Run the benchmark loop for the requested warmup time
System.out.println("Warming up...");
Thread.sleep(1000l * config.warmup);
// signal to threads to end the warmup phase
warmupComplete.set(true);
// reset the stats after warmup
fullStatsContext.fetchAndResetBaseline();
periodicStatsContext.fetchAndResetBaseline();
// print periodic statistics to the console
benchmarkStartTS = System.currentTimeMillis();
schedulePeriodicStats();
// Run the benchmark loop for the requested warmup time
System.out.println("\nRunning benchmark...");
Thread.sleep(1000l * config.duration);
// stop the threads
benchmarkComplete.set(true);
// cancel periodic stats printing
timer.cancel();
// block until all outstanding txns return
client.drain();
// join on the threads
for (Thread t : kvThreads) {
t.join();
}
// print the summary results
printResults();
// close down the client connections
client.close();
}
Aggregations