use of org.voltdb.client.exampleutils.AppHelper in project voltdb by VoltDB.
the class AsyncExportClient method main.
// Application entry point
public static void main(String[] args) {
try {
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Use the AppHelper utility class to retrieve command line application parameters
// Define parameters and pull from command line
AppHelper apph = new AppHelper(AsyncBenchmark.class.getCanonicalName()).add("displayinterval", "display_interval_in_seconds", "Interval for performance feedback, in seconds.", 10).add("duration", "run_duration_in_seconds", "Benchmark duration, in seconds.", 120).add("servers", "comma_separated_server_list", "List of VoltDB servers to connect to.", "localhost").add("port", "port_number", "Client port to connect to on cluster nodes.", 21212).add("poolsize", "pool_size", "Size of the record pool to operate on - larger sizes will cause a higher insert/update-delete rate.", 100000).add("procedure", "procedure_name", "Procedure to call.", "JiggleExportSinglePartition").add("ratelimit", "rate_limit", "Rate limit to start from (number of transactions per second).", 100000).add("autotune", "auto_tune", "Flag indicating whether the benchmark should self-tune the transaction rate for a target execution latency (true|false).", "true").add("latencytarget", "latency_target", "Execution latency to target to tune transaction rate (in milliseconds).", 10).add("catalogswap", "catlog_swap", "Swap catalogs from the client", "true").add("exportgroups", "export_groups", "Multiple export connections", "false").add("timeout", "export_timeout", "max seconds to wait for export to complete", 300).setArguments(args);
config = new ConnectionConfig(apph);
// Retrieve parameters
final boolean catalogSwap = apph.booleanValue("catalogswap");
final String csv = apph.stringValue("statsfile");
TxnIdWriter writer = new TxnIdWriter("dude", "clientlog");
// Validate parameters
apph.validate("duration", (config.duration > 0)).validate("poolsize", (config.poolSize > 0)).validate("ratelimit", (config.rateLimit > 0)).validate("latencytarget", (config.latencyTarget > 0));
// Display actual parameters, for reference
apph.printActualUsage();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Get a client connection - we retry for a while in case the server hasn't started yet
createClient();
connect();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Create a Timer task to display performance data on the procedure
Timer timer = new Timer(true);
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
printStatistics(periodicStatsContext, true);
}
}, config.displayInterval * 1000l, config.displayInterval * 1000l);
// ---------------------------------------------------------------------------------------------------------------------------------------------------
benchmarkStartTS = System.currentTimeMillis();
AtomicLong rowId = new AtomicLong(0);
// Run the benchmark loop for the requested duration
final long endTime = benchmarkStartTS + (1000l * config.duration);
int swap_count = 0;
boolean first_cat = false;
while (endTime > System.currentTimeMillis()) {
long currentRowId = rowId.incrementAndGet();
// Post the request, asynchronously
try {
clientRef.get().callProcedure(new AsyncCallback(writer, currentRowId), config.procedure, currentRowId, 0);
} catch (Exception e) {
System.err.println("Exception: " + e);
e.printStackTrace();
System.exit(-1);
}
swap_count++;
if (((swap_count % CATALOG_SWAP_INTERVAL) == 0) && catalogSwap) {
System.out.println("Changing catalogs...");
clientRef.get().updateApplicationCatalog(catalogs[first_cat ? 0 : 1], deployment);
first_cat = !first_cat;
}
}
shutdown.compareAndSet(false, true);
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// We're done - stop the performance statistics display task
timer.cancel();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
clientRef.get().drain();
Thread.sleep(10000);
waitForStreamedAllocatedMemoryZero(clientRef.get(), config.exportTimeout);
System.out.println("Writing export count as: " + TrackingResults.get(0));
//Write to export table to get count to be expected on other side.
if (config.exportGroups) {
clientRef.get().callProcedure("JiggleExportGroupDoneTable", TrackingResults.get(0));
} else {
clientRef.get().callProcedure("JiggleExportDoneTable", TrackingResults.get(0));
}
writer.close(true);
// Now print application results:
// 1. Tracking statistics
System.out.printf("-------------------------------------------------------------------------------------\n" + " Benchmark Results\n" + "-------------------------------------------------------------------------------------\n\n" + "A total of %d calls was received...\n" + " - %,9d Succeeded\n" + " - %,9d Failed (Transaction Error)\n" + "\n\n" + "-------------------------------------------------------------------------------------\n", TrackingResults.get(0) + TrackingResults.get(1), TrackingResults.get(0), TrackingResults.get(1));
// 3. Performance statistics (we only care about the procedure that we're benchmarking)
System.out.println("\n\n-------------------------------------------------------------------------------------\n" + " System Statistics\n" + "-------------------------------------------------------------------------------------\n\n");
printStatistics(fullStatsContext, false);
// Dump statistics to a CSV file
clientRef.get().writeSummaryCSV(fullStatsContext.getStatsByProc().get(config.procedure), csv);
clientRef.get().close();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
} catch (Exception x) {
System.err.println("Exception: " + x);
x.printStackTrace();
}
}
use of org.voltdb.client.exampleutils.AppHelper in project voltdb by VoltDB.
the class AsyncBenchmark method main.
// Application entry point
public static void main(String[] args) {
try {
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Use the AppHelper utility class to retrieve command line application parameters
// Define parameters and pull from command line
AppHelper apph = new AppHelper(AsyncBenchmark.class.getCanonicalName()).add("displayinterval", "display_interval_in_seconds", "Interval for performance feedback, in seconds.", 10).add("duration", "run_duration_in_seconds", "Benchmark duration, in seconds.", 120).add("servers", "comma_separated_server_list", "List of VoltDB servers to connect to.", "localhost").add("port", "port_number", "Client port to connect to on cluster nodes.", 21212).add("poolsize", "pool_size", "Size of the record pool to operate on - larger sizes will cause a higher insert/update-delete rate.", 100000).add("procedure", "procedure_name", "Procedure to call.", "JiggleSinglePartition").add("wait", "wait_duration", "Wait duration (only when calling one of the Wait procedures), in milliseconds.", 0).add("ratelimit", "rate_limit", "Rate limit to start from (number of transactions per second).", 100000).add("autotune", "auto_tune", "Flag indicating whether the benchmark should self-tune the transaction rate for a target execution latency (true|false).", "true").add("latencytarget", "latency_target", "Execution latency to target to tune transaction rate (in milliseconds).", 10.0d).setArguments(args);
// Retrieve parameters
final long displayInterval = apph.longValue("displayinterval");
final long duration = apph.longValue("duration");
final String servers = apph.stringValue("servers");
final int port = apph.intValue("port");
final int poolSize = apph.intValue("poolsize");
final String procedure = apph.stringValue("procedure");
final long wait = apph.intValue("wait");
final long rateLimit = apph.longValue("ratelimit");
final boolean autoTune = apph.booleanValue("autotune");
final double latencyTarget = apph.doubleValue("latencytarget");
final String csv = apph.stringValue("statsfile");
// Validate parameters
apph.validate("duration", (duration > 0)).validate("poolsize", (duration > 0)).validate("wait", (wait >= 0)).validate("ratelimit", (rateLimit > 0)).validate("latencytarget", (latencyTarget > 0));
// Display actual parameters, for reference
apph.printActualUsage();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Get a client connection - we retry for a while in case the server hasn't started yet
Con = ClientConnectionPool.getWithRetry(servers, port);
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Create a Timer task to display performance data on the procedure
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
System.out.print(Con.getStatistics(procedure));
}
}, displayInterval * 1000l, displayInterval * 1000l);
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Pick the transaction rate limiter helping object to use based on user request (rate limiting or latency targeting)
IRateLimiter limiter = null;
if (autoTune)
limiter = new LatencyLimiter(Con, procedure, latencyTarget, rateLimit);
else
limiter = new RateLimiter(rateLimit);
// Run the benchmark loop for the requested duration
final long endTime = System.currentTimeMillis() + (1000l * duration);
Random rand = new Random();
while (endTime > System.currentTimeMillis()) {
// Post the request, asynchronously
Con.executeAsync(new ProcedureCallback() {
@Override
public void clientCallback(ClientResponse response) throws Exception {
// Track the result of the request (Success, Failure)
if (response.getStatus() == ClientResponse.SUCCESS)
TrackingResults.incrementAndGet(0);
else
TrackingResults.incrementAndGet(1);
}
}, procedure, (long) rand.nextInt(poolSize), wait);
// Use the limiter to throttle client activity
limiter.throttle();
}
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// We're done - stop the performance statistics display task
timer.cancel();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Now print application results:
// 1. Tracking statistics
System.out.printf("-------------------------------------------------------------------------------------\n" + " Benchmark Results\n" + "-------------------------------------------------------------------------------------\n\n" + "A total of %d calls was received...\n" + " - %,9d Succeeded\n" + " - %,9d Failed (Transaction Error)\n" + "\n\n" + "-------------------------------------------------------------------------------------\n", TrackingResults.get(0) + TrackingResults.get(1), TrackingResults.get(0), TrackingResults.get(1));
// 3. Performance statistics (we only care about the procedure that we're benchmarking)
System.out.println("\n\n-------------------------------------------------------------------------------------\n" + " System Statistics\n" + "-------------------------------------------------------------------------------------\n\n");
System.out.print(Con.getStatistics(procedure).toString(false));
// Dump statistics to a CSV file
Con.saveStatistics(csv);
Con.close();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
} catch (Exception x) {
System.out.println("Exception: " + x);
x.printStackTrace();
}
}
Aggregations