use of org.voltdb.client.ClientConfig in project voltdb by VoltDB.
the class AsyncBenchmark method createClient.
Client createClient(int serverCount) {
ClientConfig clientConfig = new ClientConfig("", "");
clientConfig.setReconnectOnConnectionLoss(true);
if (config.autotune) {
clientConfig.enableAutoTune();
clientConfig.setAutoTuneTargetInternalLatency(config.latencytarget);
} else {
clientConfig.setMaxTransactionsPerSecond(config.ratelimit / serverCount);
}
Client client = ClientFactory.createClient(clientConfig);
return client;
}
use of org.voltdb.client.ClientConfig in project voltdb by VoltDB.
the class TestUpdateClasses method testRoleControl.
@Test
public void testRoleControl() throws Exception {
System.out.println("\n\n-----\n testRoleControl \n-----\n\n");
String pathToCatalog = Configuration.getPathToCatalogForTest("updateclasses.jar");
String pathToDeployment = Configuration.getPathToCatalogForTest("updateclasses.xml");
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("-- Don't care");
builder.setUseDDLSchema(true);
RoleInfo[] groups = new RoleInfo[] { new RoleInfo("adhoc", true, false, false, false, false, false) };
UserInfo[] users = new UserInfo[] { new UserInfo("adhocuser", "adhocuser", new String[] { "adhoc" }), new UserInfo("sysuser", "sysuser", new String[] { "ADMINISTRATOR" }) };
builder.addRoles(groups);
builder.addUsers(users);
// Test defines its own ADMIN user
builder.setSecurityEnabled(true, false);
boolean success = builder.compile(pathToCatalog, 2, 1, 0);
assertTrue("Schema compilation failed", success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
// This is maybe cheating a little bit?
InMemoryJarfile jarfile = new InMemoryJarfile();
for (Class<?> clazz : PROC_CLASSES) {
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(jarfile, clazz);
}
for (Class<?> clazz : EXTRA_CLASSES) {
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(jarfile, clazz);
}
Client auth_client = null;
try {
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
// Default client auth is going to fail, catch and keep chugging
try {
startSystem(config);
} catch (IOException ioe) {
assertTrue(ioe.getMessage().contains("Authentication rejected"));
}
m_client.close();
// reconnect m_client with auth that will connect but no sysproc powers
ClientConfig bad_config = new ClientConfig("adhocuser", "adhocuser");
m_client = ClientFactory.createClient(bad_config);
m_client.createConnection("localhost");
// Need a client with the right auth
ClientConfig auth_config = new ClientConfig("sysuser", "sysuser");
auth_client = ClientFactory.createClient(auth_config);
auth_client.createConnection("localhost");
ClientResponse resp;
resp = auth_client.callProcedure("@SystemCatalog", "CLASSES");
System.out.println(resp.getResults()[0]);
// New cluster, you're like summer vacation...
assertEquals(0, resp.getResults()[0].getRowCount());
assertFalse(VoltTableTestHelpers.moveToMatchingRow(resp.getResults()[0], "CLASS_NAME", PROC_CLASSES[0].getCanonicalName()));
boolean threw = false;
try {
resp = auth_client.callProcedure(PROC_CLASSES[0].getSimpleName());
} catch (ProcCallException pce) {
assertTrue(pce.getMessage().contains("was not found"));
threw = true;
}
assertTrue(threw);
threw = false;
try {
resp = m_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
} catch (ProcCallException pce) {
assertTrue(pce.getMessage().contains("does not have admin permission"));
threw = true;
}
assertTrue(threw);
resp = auth_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
assertEquals(ClientResponse.SUCCESS, resp.getStatus());
// Are we still like summer vacation?
resp = auth_client.callProcedure("@SystemCatalog", "CLASSES");
VoltTable results = resp.getResults()[0];
System.out.println(results);
assertEquals(3, results.getRowCount());
assertTrue(VoltTableTestHelpers.moveToMatchingRow(results, "CLASS_NAME", PROC_CLASSES[0].getCanonicalName()));
assertEquals(1L, results.getLong("VOLT_PROCEDURE"));
assertEquals(0L, results.getLong("ACTIVE_PROC"));
} finally {
if (auth_client != null) {
auth_client.close();
}
teardownSystem();
}
}
use of org.voltdb.client.ClientConfig 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.ClientConfig in project voltdb by VoltDB.
the class Eng866Client method main.
public static void main(String[] args) {
int hash_preload = Integer.valueOf(args[0]);
String commaSeparatedServers = args[1];
// parse the server list
List<String> servers = new LinkedList<String>();
String[] commaSeparatedServersParts = commaSeparatedServers.split(",");
for (String server : commaSeparatedServersParts) {
servers.add(server.trim());
}
Client client = null;
ClientConfig config = new ClientConfig("program", "none");
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);
}
}
// Fill a bunch of data into the hashtag table so the query will spin
System.out.println("Inserting " + hash_preload + " hashtag entries");
for (int i = 0; i < hash_preload; i++) {
insertNewHashtag(client, randomString(250), m_timestamp++);
}
// pause briefly
while (true) {
System.out.println("Starting cycle: " + m_timestamp);
m_expectedCounts = 2;
String rando = randomString(250);
getHashTags(client, 0, 10);
insertNewTweet(client, rando, m_timestamp);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while (m_expectedCounts > 0) {
Thread.yield();
}
System.out.println("Completed cycle");
m_timestamp++;
}
}
use of org.voltdb.client.ClientConfig in project voltdb by VoltDB.
the class KafkaImportBenchmark method dbconnect.
/**
* Connect to one or more VoltDB servers.
*
* @param servers A comma separated list of servers using the hostname:port
* syntax (where :port is optional). Assumes 21212 if not specified otherwise.
* @throws InterruptedException if anything bad happens with the threads.
*/
static void dbconnect(String servers, int ratelimit) throws InterruptedException, Exception {
final Splitter COMMA_SPLITTER = Splitter.on(",").omitEmptyStrings().trimResults();
log.info("Connecting to VoltDB Interface...");
ClientConfig clientConfig = new ClientConfig();
clientConfig.setMaxTransactionsPerSecond(ratelimit);
clientConfig.setReconnectOnConnectionLoss(true);
client = ClientFactory.createClient(clientConfig);
for (String server : COMMA_SPLITTER.split(servers)) {
log.info("..." + server);
client.createConnection(server);
}
}
Aggregations