Search in sources :

Example 6 with NullCallback

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

the class AsyncBenchmark method runBenchmark.

/**
     * Core benchmark code.
     * Connect. Initialize. Run the loop. Cleanup. Print Results.
     *
     * @throws Exception if anything unexpected happens.
     */
public void runBenchmark() throws Exception {
    System.out.print(HORIZONTAL_RULE);
    System.out.println(" Setup & Initialization");
    System.out.println(HORIZONTAL_RULE);
    // connect to one or more servers, loop until success
    connect(config.servers);
    // initialize using synchronous call
    System.out.println("\nPopulating Static Tables\n");
    client.callProcedure("Initialize", config.contestants, CONTESTANT_NAMES_CSV);
    System.out.print(HORIZONTAL_RULE);
    System.out.println("Starting Benchmark");
    System.out.println(HORIZONTAL_RULE);
    // Run the benchmark loop for the requested warmup time
    // The throughput may be throttled depending on client configuration
    System.out.println("Warming up...");
    final long warmupEndTime = System.currentTimeMillis() + (1000l * config.warmup);
    while (warmupEndTime > System.currentTimeMillis()) {
        // Get the next phone call
        PhoneCallGenerator.PhoneCall call = switchboard.receive();
        // asynchronously call the "Vote" procedure
        client.callProcedure(new NullCallback(), "Vote", call.phoneNumber, call.contestantNumber, config.maxvotes);
    }
    // reset the stats after warmup
    fullStatsContext.fetchAndResetBaseline();
    periodicStatsContext.fetchAndResetBaseline();
    // print periodic statistics to the console
    benchmarkStartTS = System.currentTimeMillis();
    schedulePeriodicStats();
    // Run the benchmark loop for the requested duration
    // The throughput may be throttled depending on client configuration
    System.out.println("\nRunning benchmark...");
    final long benchmarkEndTime = System.currentTimeMillis() + (1000l * config.duration);
    while (benchmarkEndTime > System.currentTimeMillis()) {
        // Get the next phone call
        PhoneCallGenerator.PhoneCall call = switchboard.receive();
        // asynchronously call the "Vote" procedure
        client.callProcedure(new VoterCallback(), "Vote", call.phoneNumber, call.contestantNumber, config.maxvotes);
    }
    // cancel periodic stats printing
    timer.cancel();
    // block until all outstanding txns return
    client.drain();
    // print the summary results
    printResults();
    // close down the client connections
    client.close();
}
Also used : NullCallback(org.voltdb.client.NullCallback)

Example 7 with NullCallback

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

the class ExportBenchmark method doInserts.

/**
     * Inserts values into the export table for the test. First it does warmup
     * inserts, then tracked inserts.
     * @throws InterruptedException
     * @throws NoConnectionsException
     */
public void doInserts(Client client) {
    // Don't track warmup inserts
    System.out.println("Warming up...");
    long now = System.currentTimeMillis();
    AtomicLong rowId = new AtomicLong(0);
    while (benchmarkWarmupEndTS > now) {
        try {
            client.callProcedure(new NullCallback(), "InsertExport", rowId.getAndIncrement(), 0);
            // Check the time every 50 transactions to avoid invoking System.currentTimeMillis() too much
            if (++totalInserts % 50 == 0) {
                now = System.currentTimeMillis();
            }
        } catch (Exception ignore) {
        }
    }
    System.out.println("Warmup complete");
    rowId.set(0);
    // reset the stats after warmup is done
    fullStatsContext.fetchAndResetBaseline();
    periodicStatsContext.fetchAndResetBaseline();
    schedulePeriodicStats();
    // Insert objects until we've run for long enough
    System.out.println("Running benchmark...");
    now = System.currentTimeMillis();
    while (benchmarkEndTS > now) {
        try {
            client.callProcedure(new ExportCallback(), "InsertExport", rowId.getAndIncrement(), 0);
            // Check the time every 50 transactions to avoid invoking System.currentTimeMillis() too much
            if (++totalInserts % 50 == 0) {
                now = System.currentTimeMillis();
            }
        } catch (Exception e) {
            System.err.println("Couldn't insert into VoltDB\n");
            e.printStackTrace();
            System.exit(1);
        }
    }
    try {
        client.drain();
    } catch (Exception e) {
        e.printStackTrace();
    }
    System.out.println("Benchmark complete: wrote " + successfulInserts.get() + " objects");
    System.out.println("Failed to insert " + failedInserts.get() + " objects");
    testFinished.set(true);
    if (config.target.equals("socket")) {
        statsSocketSelector.wakeup();
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) NullCallback(org.voltdb.client.NullCallback) IOException(java.io.IOException) JSONException(org.json_voltpatches.JSONException) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException)

Example 8 with NullCallback

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

the class ScanBenchmark method runBenchmark.

/**
     * Core benchmark code.
     * Connect. Initialize. Run the loop. Cleanup. Print Results.
     *
     * @throws Exception if anything unexpected happens.
     */
public void runBenchmark() throws Exception {
    System.out.print(HORIZONTAL_RULE);
    System.out.println(" Setup & Initialization");
    System.out.println(HORIZONTAL_RULE);
    // connect to one or more servers, loop until success
    connect(config.servers);
    System.out.print(HORIZONTAL_RULE);
    System.out.println("Loading Tuples");
    System.out.println(HORIZONTAL_RULE);
    String loadproc = null;
    String tablename = null;
    String scanproc = null;
    if (config.test.equals("sequential")) {
        loadproc = "NARROW_P.insert";
        tablename = "narrow_p";
        scanproc = "MinSeqScan";
    } else if (config.test.equals("index")) {
        loadproc = "NARROW_INDEX_P.insert";
        tablename = "narrow_index_p";
        scanproc = "MinIndexScan";
    }
    for (long i = 0; i < config.rows; i++) {
        client.callProcedure(new NullCallback(), loadproc, i % 509, /* radom prime */
        i);
        if ((i % 100000) == 0) {
            System.out.printf("Loading row at index %d.\n", i);
        }
    }
    client.drain();
    ClientResponse cr = client.callProcedure("@AdHoc", "select count(*) from " + tablename + ";");
    long rows = cr.getResults()[0].asScalarLong();
    System.out.printf("Loaded %d rows.\n", rows);
    assert (rows == config.rows);
    System.out.print(HORIZONTAL_RULE);
    System.out.println("Starting Benchmark");
    System.out.println(HORIZONTAL_RULE);
    // reset the stats after warmup
    fullStatsContext.fetchAndResetBaseline();
    periodicStatsContext.fetchAndResetBaseline();
    benchmarkStartTS = System.currentTimeMillis();
    System.out.printf("\nRunning %s scan benchmark...\n", config.test);
    for (int i = 0; i < config.runs; i++) {
        client.callProcedure(scanproc);
    }
    benchmarkEndTS = System.currentTimeMillis();
    // print the summary results
    printResults();
    // close down the client connections
    client.close();
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) NullCallback(org.voltdb.client.NullCallback)

Example 9 with NullCallback

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

the class MOBenchmark method runBenchmark.

/**
     * Core benchmark code.
     * Connect. Initialize. Run the loop. Cleanup. Print Results.
     *
     * @throws Exception if anything unexpected happens.
     */
public void runBenchmark() throws Exception {
    System.out.print(HORIZONTAL_RULE);
    System.out.println(" Setup & Initialization");
    System.out.println(HORIZONTAL_RULE);
    // connect to one or more servers, loop until success
    connect(config.servers);
    System.out.print(HORIZONTAL_RULE);
    System.out.println("Starting Benchmark");
    System.out.println(HORIZONTAL_RULE);
    // Run the benchmark loop for the requested warmup time
    // The throughput may be throttled depending on client configuration
    System.out.println("Warming up...");
    final long warmupEndTime = System.currentTimeMillis() + (1000l * config.warmup);
    while (warmupEndTime > System.currentTimeMillis()) {
        // asynchronously call the next procedure
        client.callProcedure(new NullCallback(), nextProc().getFirst(), rand.nextInt(), payload);
    }
    // reset the stats after warmup
    fullStatsContext.fetchAndResetBaseline();
    periodicStatsContext.fetchAndResetBaseline();
    // print periodic statistics to the console
    benchmarkStartTS = System.currentTimeMillis();
    schedulePeriodicStats();
    // Run the benchmark loop for the requested duration
    // The throughput may be throttled depending on client configuration
    System.out.println("\nRunning benchmark...");
    final long benchmarkEndTime = System.currentTimeMillis() + (1000l * config.duration);
    while (benchmarkEndTime > System.currentTimeMillis()) {
        // asynchronously call the next procedure
        Pair<String, AtomicLong> next = nextProc();
        client.callProcedure(new MOCallback(next.getSecond()), next.getFirst(), rand.nextInt(), payload);
    }
    // cancel periodic stats printing
    timer.cancel();
    // block until all outstanding txns return
    client.drain();
    // print the summary results
    printResults();
    // close down the client connections
    client.close();
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) NullCallback(org.voltdb.client.NullCallback)

Example 10 with NullCallback

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

the class TestIndexesSuite method callHelper.

void callHelper(Client client, String procname, Object... objects) throws InterruptedException, IOException {
    NullCallback nullCallback = new NullCallback();
    boolean done;
    do {
        done = client.callProcedure(nullCallback, procname, objects);
        if (!done) {
            client.backpressureBarrier();
        }
    } while (!done);
}
Also used : NullCallback(org.voltdb.client.NullCallback)

Aggregations

NullCallback (org.voltdb.client.NullCallback)19 IOException (java.io.IOException)6 ProcCallException (org.voltdb.client.ProcCallException)4 VoltTable (org.voltdb.VoltTable)3 ClientResponse (org.voltdb.client.ClientResponse)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Client (org.voltdb.client.Client)2 GeographyPointValue (org.voltdb.types.GeographyPointValue)2 GeographyValue (org.voltdb.types.GeographyValue)2 TimestampType (org.voltdb.types.TimestampType)2 File (java.io.File)1 BigDecimal (java.math.BigDecimal)1 InetSocketAddress (java.net.InetSocketAddress)1 ByteBuffer (java.nio.ByteBuffer)1 ServerSocketChannel (java.nio.channels.ServerSocketChannel)1 SocketChannel (java.nio.channels.SocketChannel)1 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Random (java.util.Random)1