Search in sources :

Example 6 with ClientConfig

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;
}
Also used : ClientConfig(org.voltdb.client.ClientConfig) Client(org.voltdb.client.Client)

Example 7 with ClientConfig

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();
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) Configuration(org.voltdb.VoltDB.Configuration) UserInfo(org.voltdb.compiler.VoltProjectBuilder.UserInfo) IOException(java.io.IOException) VoltTable(org.voltdb.VoltTable) VoltDB(org.voltdb.VoltDB) VoltCompiler(org.voltdb.compiler.VoltCompiler) RoleInfo(org.voltdb.compiler.VoltProjectBuilder.RoleInfo) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) InMemoryJarfile(org.voltdb.utils.InMemoryJarfile) Configuration(org.voltdb.VoltDB.Configuration) Client(org.voltdb.client.Client) ClientConfig(org.voltdb.client.ClientConfig) ProcCallException(org.voltdb.client.ProcCallException) Test(org.junit.Test)

Example 8 with ClientConfig

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);
}
Also used : UnknownHostException(java.net.UnknownHostException) IOException(java.io.IOException) LinkedList(java.util.LinkedList) AppHelper(org.voltdb.client.exampleutils.AppHelper) Client(org.voltdb.client.Client) ClientConfig(org.voltdb.client.ClientConfig) File(java.io.File)

Example 9 with ClientConfig

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++;
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) IOException(java.io.IOException) Client(org.voltdb.client.Client) ClientConfig(org.voltdb.client.ClientConfig) LinkedList(java.util.LinkedList)

Example 10 with ClientConfig

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);
    }
}
Also used : Splitter(com.google_voltpatches.common.base.Splitter) 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