use of org.voltdb.client.exampleutils.RateLimiter 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
apph.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("resultsize", "result_size", "Size of the result value returned by each operation", 0).add("paramsize", "param_size", "Size of the op parameter if the op supports arbitrary size params", 0).add("operation", "operation", "The procedure to invoke", "NoArgs").add("ratelimit", "rate_limit", "Rate limit to start from (number of transactions per second).", 900000).setArguments(args);
// Retrieve parameters
long displayInterval = apph.longValue("displayinterval");
duration = apph.longValue("duration");
String servers = apph.stringValue("servers");
int port = apph.intValue("port");
resultSize = apph.intValue("resultsize");
paramSize = apph.intValue("paramsize");
long rateLimit = apph.longValue("ratelimit");
final String csv = apph.stringValue("statsfile");
final String op = apph.stringValue("operation");
// Validate parameters
apph.validate("duration", (duration > 0)).validate("displayinterval", (displayInterval > 0)).validate("resultsize", (resultSize >= 0)).validate("paramsize", (paramSize >= 0)).validate("ratelimit", (rateLimit > 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 operating procedures
timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
System.out.print(Con.getStatistics(op));
}
}, displayInterval * 1000l, displayInterval * 1000l);
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Pick the transaction rate limiter helping object to use based on user request (rate limiting or latency targeting)
limiter = new RateLimiter(rateLimit);
// Run the benchmark loop for the requested duration
if (op.substring(0, 6).equalsIgnoreCase("noargs")) {
runNoArgs(op.endsWith("RW") ? false : true);
} else if (op.substring(0, 13).equalsIgnoreCase("BinaryPayload")) {
runBinaryPayload(op.endsWith("RW") ? false : true);
}
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// We're done - stop the performance statistics display task
timer.cancel();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Now print application results:
// 1. Overall performance statistics for GET/PUT operations
System.out.println("\n\n-------------------------------------------------------------------------------------\n" + " System Statistics\n" + "-------------------------------------------------------------------------------------\n\n");
System.out.print(Con.getStatistics(op).toString(false));
// 2. Per-procedure detailed performance statistics
System.out.println("\n\n-------------------------------------------------------------------------------------\n" + " Detailed Statistics\n" + "-------------------------------------------------------------------------------------\n\n");
System.out.print(Con.getStatistics().toString(false));
// Dump statistics to a CSV file
Con.saveStatistics(csv);
// ---------------------------------------------------------------------------------------------------------------------------------------------------
} catch (org.voltdb.client.NoConnectionsException x) {
System.out.println("Exception: " + x);
System.out.println("\n\n-------------------------------------------------------------------------------------\n");
System.out.print("Lost connection - will try to reconnect ... \n");
Con.close();
timer.cancel();
try {
Con = ClientConnectionPool.getWithRetry(apph.stringValue("servers"), apph.intValue("port"));
} catch (Exception e) {
System.out.println("Another exception, I guess " + e);
}
} catch (Exception x) {
System.out.println("Exception: " + x);
x.printStackTrace();
System.exit(1);
}
}
use of org.voltdb.client.exampleutils.RateLimiter 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();
}
}
use of org.voltdb.client.exampleutils.RateLimiter in project voltdb by VoltDB.
the class AdhocSmash method main.
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(AdhocSmash.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("ratelimit", "rate_limit", "Rate limit to start from (number of transactions per second).", 100000).setArguments(args);
// Retrieve parameters
long displayInterval = apph.longValue("displayinterval");
long duration = apph.longValue("duration");
String servers = apph.stringValue("servers");
int port = apph.intValue("port");
long rateLimit = apph.longValue("ratelimit");
Random rand = new Random();
// Validate parameters
apph.validate("duration", (duration > 0)).validate("displayinterval", (displayInterval > 0)).validate("ratelimit", (rateLimit > 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);
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Pick the transaction rate limiter helping object to use based on user request (rate limiting or latency targeting)
IRateLimiter limiter = null;
limiter = new RateLimiter(rateLimit);
int cycle = 0;
// Run the benchmark loop for the requested duration
final long endTime = System.currentTimeMillis() + (1000l * duration);
while (endTime > System.currentTimeMillis()) {
// First, Insert
if (rand.nextInt(1000) < 5) {
//System.out.println("Insert adhoc");
String query = "insert into votes (phone_number, state, contestant_number) values (" + cycle + ", 'MA', 999);";
ClientResponse response = Con.execute("@AdHoc", query);
InsertCallback blah = new InsertCallback(true, cycle);
blah.clientCallback(response);
} else {
//System.out.println("Insert regular");
Con.executeAsync(new InsertCallback(false, cycle), "VOTES.insert", cycle, "MA", 999);
}
// Then, update
if (rand.nextInt(1000) < 5) {
//System.out.println("Update adhoc");
ClientResponse response = Con.execute("@AdHoc", "update votes set state='RI', contestant_number=" + cycle + " where phone_number=" + cycle + ";");
UpdateCallback blah = new UpdateCallback(true, cycle);
blah.clientCallback(response);
} else {
//System.out.println("Update regular");
Con.executeAsync(new UpdateCallback(false, cycle), "VOTES.update", cycle, "MA", cycle, cycle);
}
// Finally, delete
if (rand.nextInt(1000) < 5) {
//System.out.println("Delete adhoc");
ClientResponse response = Con.execute("@AdHoc", "delete from votes where contestant_number=" + cycle + ";");
DeleteCallback blah = new DeleteCallback(true, cycle);
blah.clientCallback(response);
} else {
//System.out.println("Delete regular");
Con.executeAsync(new DeleteCallback(false, cycle), "Delete", cycle);
}
cycle++;
// Use the limiter to throttle client activity
limiter.throttle();
}
// --------------------------------------------------------------------------------------------------------
Con.close();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
} catch (Exception x) {
System.out.println("Exception: " + x);
x.printStackTrace();
}
}
use of org.voltdb.client.exampleutils.RateLimiter 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("pool-size", "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.", "UpdateKey").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("latency-target", "latency_target", "Execution latency to target to tune transaction rate (in milliseconds).", 10.0d).add("run-loader", "Run the leveldb loader", "true").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("pool-size");
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("latency-target");
final String csv = apph.stringValue("stats");
final boolean runLoader = apph.booleanValue("run-loader");
// Validate parameters
apph.validate("duration", (duration > 0)).validate("pool-size", (duration > 0)).validate("wait", (wait >= 0)).validate("ratelimit", (rateLimit > 0)).validate("latency-target", (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 = autoTune ? new LatencyLimiter(Con, procedure, latencyTarget, rateLimit) : new RateLimiter(rateLimit);
// Run the loader first.
if (runLoader) {
doLoader(poolSize);
}
// Run the benchmark loop for the requested duration
final long endTime = System.currentTimeMillis() + (1000l * duration);
Random rand = new Random();
while (endTime > System.currentTimeMillis()) {
doBenchmark(procedure, poolSize, rand, 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