use of org.voltdb.client.exampleutils.AppHelper in project voltdb by VoltDB.
the class JDBCBenchmark 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(JDBCBenchmark.class.getCanonicalName()).add("threads", "thread_count", "Number of concurrent threads attacking the database.", 1).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).setArguments(args);
// Retrieve parameters
final int threadCount = apph.intValue("threads");
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 String csv = apph.stringValue("statsfile");
// Validate parameters
apph.validate("duration", (duration > 0)).validate("threads", (threadCount > 0)).validate("poolsize", (poolSize > 0)).validate("wait", (wait >= 0));
// Display actual parameters, for reference
apph.printActualUsage();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// We need only do this once, to "hot cache" the JDBC driver reference so the JVM may realize it's there.
Class.forName("org.voltdb.jdbc.Driver");
// Prepare the JDBC URL for the VoltDB driver
String url = "jdbc:voltdb://" + servers + ":" + port;
// Get a client connection - we retry for a while in case the server hasn't started yet
System.out.printf("Connecting to: %s\n", url);
int sleep = 1000;
while (true) {
try {
Con = DriverManager.getConnection(url, "", "");
break;
} catch (Exception e) {
System.err.printf("Connection failed - retrying in %d second(s).\n", sleep / 1000);
try {
Thread.sleep(sleep);
} catch (Exception tie) {
}
if (sleep < 8000)
sleep += sleep;
}
}
System.out.println("Connected. Starting benchmark.");
// ---------------------------------------------------------------------------------------------------------------------------------------------------
final ClientStatsContext fullStatsContext = ((IVoltDBConnection) Con).createStatsContext();
periodicStatsContext = ((IVoltDBConnection) Con).createStatsContext();
benchmarkStartTS = System.currentTimeMillis();
// Create a Timer task to display performance data on the procedure
Timer timer = new Timer();
TimerTask statsPrinting = new TimerTask() {
@Override
public void run() {
printStatistics();
}
};
timer.scheduleAtFixedRate(statsPrinting, displayInterval * 1000l, displayInterval * 1000l);
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Create multiple processing threads
ArrayList<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < threadCount; i++) threads.add(new Thread(new ClientThread(url, procedure, poolSize, wait, duration)));
// Start threads
for (Thread thread : threads) thread.start();
// Wait for threads to complete
for (Thread thread : threads) thread.join();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// 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");
try {
System.out.print(fullStatsContext.getStatsForProcedure(procedure).toString());
} catch (Exception e) {
e.printStackTrace();
}
// Dump statistics to a CSV file
Con.unwrap(IVoltDBConnection.class).saveStatistics(fullStatsContext.getStats(), csv);
Con.close();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
} catch (Exception x) {
System.out.println("Exception: " + x);
x.printStackTrace();
}
}
use of org.voltdb.client.exampleutils.AppHelper in project voltdb by VoltDB.
the class SyncBenchmark 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(SyncBenchmark.class.getCanonicalName()).add("threads", "thread_count", "Number of concurrent threads attacking the database.", 1).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).setArguments(args);
// Retrieve parameters
final int threadCount = apph.intValue("threads");
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 String csv = apph.stringValue("statsfile");
// Validate parameters
apph.validate("duration", (duration > 0)).validate("threads", (threadCount > 0)).validate("poolsize", (poolSize > 0)).validate("wait", (wait >= 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);
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// Create multiple processing threads
ArrayList<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < threadCount; i++) threads.add(new Thread(new ClientThread(servers, port, procedure, poolSize, wait, duration)));
// Start threads
for (Thread thread : threads) thread.start();
// Wait for threads to complete
for (Thread thread : threads) thread.join();
// ---------------------------------------------------------------------------------------------------------------------------------------------------
// 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.AppHelper in project voltdb by VoltDB.
the class DeletesClient method main.
public static void main(String[] args) {
// Use the AppHelper utility class to retrieve command line application parameters
// Define parameters and pull from command line
AppHelper apph = new AppHelper(DeletesClient.class.getCanonicalName()).add("duration", "run_duration_in_seconds", "Benchmark duration, in seconds.", 240).add("average-batch-size", "average_batch_size", "Average batch size", 150000).add("batches", "num_batches_to_keep", "Number of batches to keep", 5).add("cleanup-freq", "cleanup_frequency", "Cleanup frequency, in seconds.", 6).add("snapshot-freq", "cycles_between_snapshots", "Snapshot frequency, in seconds. -1 to turn off snapshots", -1).add("block-snapshots", "use_blocking_snapshots_snapshots", "Blocking snapshots (true|false)", "false").add("small-strings", "use_inline_strings", "Forces all the strings to be inlined strings (true|false)", "false").add("servers", "comma_separated_server_list", "List of VoltDB servers to connect to.", "localhost").setArguments(args);
m_averageBatchSize = apph.intValue("average-batch-size");
m_batchesToKeep = apph.intValue("batches");
m_deceasedCleanupFreq = apph.intValue("cleanup-freq");
m_snapshotFreq = apph.intValue("snapshot-freq");
m_blockingSnapshots = apph.booleanValue("block-snapshots");
m_smallStrings = apph.booleanValue("small-strings");
long duration = apph.longValue("duration");
String commaSeparatedServers = apph.stringValue("servers");
apph.validate("average-batch-size", (m_averageBatchSize > 0));
apph.validate("batches", (m_batchesToKeep >= 0));
apph.validate("duration", (duration >= 0));
apph.validate("cleanup-freq", (m_deceasedCleanupFreq > 0));
apph.printActualUsage();
System.out.println("Starting Deletes app with:");
System.out.printf("\tAverage batch size of %d\n", m_averageBatchSize);
System.out.printf("\tKeeping %d batches\n", m_batchesToKeep);
System.out.printf("\tCleaning up deceased every %d batches\n", m_deceasedCleanupFreq);
System.out.printf("\tSnapshotting every %d batches\n", m_snapshotFreq);
// parse the server list
List<String> servers = new LinkedList<String>();
String[] commaSeparatedServersParts = commaSeparatedServers.split(",");
for (String server : commaSeparatedServersParts) {
servers.add(server.trim());
}
File tmpdir = new File(m_snapshotDir);
tmpdir.mkdir();
generateNames(16);
Client client = null;
ClientConfig config = new ClientConfig("program", "none");
config.setProcedureCallTimeout(Long.MAX_VALUE);
client = ClientFactory.createClient(config);
for (String server : servers) {
try {
client.createConnection(server);
} catch (UnknownHostException e) {
e.printStackTrace();
System.exit(-1);
} catch (IOException e) {
System.err.println("Could not connect to database, terminating: (" + server + ")");
System.exit(-1);
}
}
// Start with the maximum data set we could possibly fill
for (int i = 0; i < m_batchesToKeep; i++) {
insertBatch(client, true);
}
// now add a batch and remove a batch
long deceased_counter = 0;
long snapshot_counter = 0;
long max_batch_counter = 0;
boolean fill_max = false;
long max_batch_remaining = 0;
final long endTime = System.currentTimeMillis() + (1000l * duration);
final long startTime = System.currentTimeMillis();
while (endTime > System.currentTimeMillis()) {
// if (max_batch_counter == m_maxBatchFreq)
// {
// fill_max = true;
// max_batch_remaining = m_batchesToKeep;
// max_batch_counter = 0;
// }
// else if (fill_max)
// {
// max_batch_remaining--;
// fill_max = true;
// if (max_batch_remaining == 0)
// {
// fill_max = false;
// }
// }
// else
// {
// max_batch_counter++;
// fill_max = false;
// }
insertBatch(client, fill_max);
collectStats(client);
snapshot_counter++;
if (snapshot_counter == m_snapshotFreq) {
performSnapshot(client);
snapshot_counter = 0;
}
deceased_counter++;
if (deceased_counter == m_deceasedCleanupFreq) {
deleteDeceased(client);
deceased_counter = 0;
}
countBatch(client, m_batchNumber - m_batchesToKeep - 1);
deleteBatch(client, m_batchesToKeep);
}
System.out.printf("\tTotal runtime: %d seconds\n", (System.currentTimeMillis() - startTime) / 1000l);
}
use of org.voltdb.client.exampleutils.AppHelper 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.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("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