Search in sources :

Example 36 with ClientConfig

use of org.voltdb.client.ClientConfig in project voltdb by VoltDB.

the class TestCSVLoader method startDatabase.

@BeforeClass
public static void startDatabase() throws Exception {
    prepare();
    String pathToCatalog = Configuration.getPathToCatalogForTest("csv.jar");
    String pathToDeployment = Configuration.getPathToCatalogForTest("csv.xml");
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("create table BLAH (" + "clm_integer integer not null, " + "clm_tinyint tinyint default 0, " + "clm_smallint smallint default 0, " + "clm_bigint bigint default 0, " + "clm_string varchar(20) default null, " + "clm_decimal decimal default null, " + "clm_float float default null, " + "clm_timestamp timestamp default null, " + "clm_point geography_point default null, " + "clm_geography geography default null, " + "PRIMARY KEY(clm_integer) " + ");");
    builder.addPartitionInfo("BLAH", "clm_integer");
    boolean success = builder.compile(pathToCatalog, 2, 1, 0);
    assertTrue(success);
    MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
    Configuration config = new Configuration();
    config.m_pathToCatalog = pathToCatalog;
    config.m_pathToDeployment = pathToDeployment;
    localServer = new ServerThread(config);
    client = null;
    localServer.start();
    localServer.waitForInitialization();
    client = ClientFactory.createClient(new ClientConfig());
    client.createConnection("localhost");
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) ServerThread(org.voltdb.ServerThread) ClientConfig(org.voltdb.client.ClientConfig) BeforeClass(org.junit.BeforeClass)

Example 37 with ClientConfig

use of org.voltdb.client.ClientConfig in project voltdb by VoltDB.

the class VerifierUtils 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 IOException
     * @throws UnknownHostException
     * @throws InterruptedException if anything bad happens with the threads.
     */
static Client dbconnect(String servers, int ratelimit) throws UnknownHostException, IOException {
    //final Splitter COMMA_SPLITTER = Splitter.on(",").omitEmptyStrings().trimResults();
    System.out.println("Connecting to VoltDB Interface...");
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setMaxTransactionsPerSecond(ratelimit);
    clientConfig.setReconnectOnConnectionLoss(true);
    Client client = ClientFactory.createClient(clientConfig);
    for (String server : servers.split(",")) {
        System.out.println("..." + server);
        client.createConnection(server);
    }
    return client;
}
Also used : ClientConfig(org.voltdb.client.ClientConfig) Client(org.voltdb.client.Client)

Example 38 with ClientConfig

use of org.voltdb.client.ClientConfig in project voltdb by VoltDB.

the class VoltDBOsmSink method connect.

private void connect(String servers) throws InterruptedException, ClassNotFoundException, SQLException {
    System.out.println("Connecting to VoltDB...");
    ClientConfig clientConfig = new ClientConfig("", "", new VoltDBOsmSink.StatusListener());
    clientConfig.setMaxTransactionsPerSecond(10000);
    client = ClientFactory.createClient(clientConfig);
    try {
        // if we have more then one server, we would connect to each one
        // individually inside a loop.
        client.createConnection(servers);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    periodicStatsContext = client.createStatsContext();
    fullStatsContext = client.createStatsContext();
}
Also used : UnknownHostException(java.net.UnknownHostException) IOException(java.io.IOException) ClientConfig(org.voltdb.client.ClientConfig)

Aggregations

ClientConfig (org.voltdb.client.ClientConfig)38 Client (org.voltdb.client.Client)25 IOException (java.io.IOException)11 VoltTable (org.voltdb.VoltTable)10 Configuration (org.voltdb.VoltDB.Configuration)9 File (java.io.File)7 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)7 ClientResponse (org.voltdb.client.ClientResponse)6 ServerThread (org.voltdb.ServerThread)5 ConnectException (java.net.ConnectException)4 UnknownHostException (java.net.UnknownHostException)4 Random (java.util.Random)4 Test (org.junit.Test)4 ClientConfigForTest (org.voltdb.client.ClientConfigForTest)4 ClientImpl (org.voltdb.client.ClientImpl)4 ProcCallException (org.voltdb.client.ProcCallException)4 FileNotFoundException (java.io.FileNotFoundException)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 VoltDB (org.voltdb.VoltDB)3