use of org.voltdb.client.ClientConfig in project voltdb by VoltDB.
the class RegressionSuite method getClientSha1.
/**
* Get a VoltClient instance connected to the server driven by the
* VoltServerConfig instance. Just pick from the list of listeners
* randomly.
*
* Only uses the time
*
* @return A VoltClient instance connected to the server driven by the
* VoltServerConfig instance.
*/
public Client getClientSha1(long timeout) throws IOException {
final List<String> listeners = m_config.getListenerAddresses();
final Random r = new Random();
String listener = listeners.get(r.nextInt(listeners.size()));
ClientConfig config = new ClientConfigForTest(m_username, m_password, ClientAuthScheme.HASH_SHA1);
config.setConnectionResponseTimeout(timeout);
config.setProcedureCallTimeout(timeout);
final Client client = ClientFactory.createClient(config);
// Use the port generated by LocalCluster if applicable
try {
client.createConnection(listener);
}// retry once
catch (ConnectException e) {
listener = listeners.get(r.nextInt(listeners.size()));
client.createConnection(listener);
}
m_clients.add(client);
return client;
}
use of org.voltdb.client.ClientConfig in project voltdb by VoltDB.
the class TestStatisticsSuiteDRStats method testDRPartitionStatisticsWithConsumers.
public void testDRPartitionStatisticsWithConsumers() throws Exception {
if (!VoltDB.instance().getConfig().m_isEnterprise) {
System.out.println("SKIPPING DRPRODUCERPARTITION STATS TESTS FOR COMMUNITY VERSION");
return;
}
System.out.println("\n\nTESTING DRPRODUCERPARTITION STATS\n\n\n");
Client primaryClient = getFullyConnectedClient();
List<Client> consumerClients = new ArrayList<>();
List<LocalCluster> consumerClusters = new ArrayList<>();
VoltTable expectedTable1 = new VoltTable(expectedDRPartitionStatsSchema);
ClientResponse cr = primaryClient.callProcedure("@AdHoc", "insert into employee values(1, 25);");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
// create a consumer cluster and connect to producer cluster so that there will be rows for partition stats
String secondaryRoot = "/tmp/" + System.getProperty("user.name") + "-dr-stats-secondary";
try {
int CONSUMER_CLUSTER_COUNT = 2;
for (int n = 1; n <= CONSUMER_CLUSTER_COUNT; n++) {
LocalCluster consumerCluster = LocalCluster.createLocalCluster(drSchema, SITES, HOSTS, KFACTOR, n, REPLICATION_PORT + 100 * n, REPLICATION_PORT, secondaryRoot, jarName, true);
ClientConfig clientConfig = new ClientConfig();
clientConfig.setProcedureCallTimeout(10 * 60 * 1000);
Client consumerClient = createClient(clientConfig, consumerCluster);
consumerClusters.add(consumerCluster);
consumerClients.add(consumerClient);
boolean hasSnapshotData = false;
for (int i = 0; i < 60; i++) {
cr = consumerClient.callProcedure("@AdHoc", "select count(e_id) from employee;");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
VoltTable result = cr.getResults()[0];
assertTrue(result.advanceRow());
if (result.getLong(0) == 1) {
// get all snapshot records
hasSnapshotData = true;
break;
}
Thread.sleep(1000);
}
assertTrue(hasSnapshotData);
}
//
// DRPARTITION
//
VoltTable[] results = primaryClient.callProcedure("@Statistics", "DRPRODUCERPARTITION", 0).getResults();
// one aggregate tables returned
assertEquals(1, results.length);
System.out.println("Test DR table: " + results[0].toString());
validateSchema(results[0], expectedTable1);
// One row per site (including the MPI on each host),
// don't have HSID for ease of check, just check a bunch of stuff
assertEquals(CONSUMER_CLUSTER_COUNT * (HOSTS * SITES + HOSTS), results[0].getRowCount());
results[0].advanceRow();
Map<String, String> columnTargets = new HashMap<>();
columnTargets.put("HOSTNAME", results[0].getString("HOSTNAME"));
validateRowSeenAtAllHosts(results[0], columnTargets, false);
validateRowSeenAtAllPartitions(results[0], "HOSTNAME", results[0].getString("HOSTNAME"), false);
} finally {
primaryClient.close();
for (Client consumerClient : consumerClients) {
if (consumerClient != null) {
consumerClient.close();
}
}
for (LocalCluster consumerCluster : consumerClusters) {
if (consumerCluster != null) {
consumerCluster.shutDown();
}
}
}
}
use of org.voltdb.client.ClientConfig in project voltdb by VoltDB.
the class ConnectionHelper method createConnection.
/**
* Creates a factory used to connect to a VoltDB instance.
* (Note that if a corresponding connection exists, all parameters other than 'servers' are ignored)
* @param clientId A unique identifier for the connecting client
* @param servers The comma separated list of VoltDB servers in hostname[:port] format that the instance will use.
* @param user The username for the connection
* @param password The password for the specified user
* @param ratelimit A limit on the number of transactions per second for the VoltDB instance
* @return The existing factory if a corresponding connection has already been created; the newly created
* one otherwise.
* @throws IOException Throws if a connection is already open with a different server string.
* @throws InterruptedException
*/
public static synchronized Client createConnection(Long clientId, String servers, String user, String password, int ratelimit) throws IOException, InterruptedException {
ClientConnection conn = clientMapping.get(clientId);
if (conn != null) {
return conn.m_client;
}
if (activeConnection != null && activeConnection.m_connectionCount.get() <= THREADS_PER_CLIENT) {
activeConnection.connect();
clientMapping.put(clientId, activeConnection);
return activeConnection.m_client;
}
ClientConfig config = new ClientConfig(user, password);
config.setMaxTransactionsPerSecond(ratelimit);
Client client = ClientFactory.createClient(config);
connect(client, servers);
activeConnection = new ClientConnection(client);
clientMapping.put(clientId, activeConnection);
return client;
}
use of org.voltdb.client.ClientConfig in project voltdb by VoltDB.
the class CSVLoader method main.
/**
* csvloader main. (main is directly used by tests as well be sure to reset statics that you need to start over)
*
* @param args
* @throws IOException
* @throws InterruptedException
*
*/
public static void main(String[] args) throws IOException, InterruptedException {
start = System.currentTimeMillis();
long insertTimeStart = start;
long insertTimeEnd;
final CSVConfig cfg = new CSVConfig();
cfg.parse(CSVLoader.class.getName(), args);
config = cfg;
if (config.noquotechar) {
config.quotechar = '