Search in sources :

Example 16 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);
    // preload keys if requested
    System.out.println();
    if (config.preload) {
        System.out.println("Preloading data store...");
        for (int i = config.preloadLowKey; i < config.poolsize; i++) {
            client.callProcedure(new NullCallback(), "Put", String.format(processor.KeyFormat, i), processor.generateForStore().getStoreValue());
            lastSuccessfulResponse = System.currentTimeMillis();
        }
        client.drain();
        System.out.println("Preloading complete.\n");
    }
    if (!config.runbenchmark) {
        System.out.println("Benchmark run disabled by --runbenchmark option, exiting now");
        System.exit(0);
    }
    System.out.print(HORIZONTAL_RULE);
    System.out.println("Starting Benchmark");
    System.out.println(HORIZONTAL_RULE);
    // The throughput may be throttled depending on client configuration
    if (config.warmup > 0) {
        System.out.println("Warming up...");
        final long warmupEndTime = System.currentTimeMillis() + (1000l * config.warmup);
        while (warmupEndTime > System.currentTimeMillis()) {
            // Decide whether to perform a GET or PUT operation
            if (rand.nextDouble() < config.getputratio) {
                // Get a key/value pair, asynchronously
                client.callProcedure(new NullCallback(), "Get", processor.generateRandomKeyForRetrieval());
            } else {
                // Put a key/value pair, asynchronously
                final PayloadProcessor.Pair pair = processor.generateForStore();
                client.callProcedure(new NullCallback(), "Put", pair.Key, pair.getStoreValue());
            }
            lastSuccessfulResponse = System.currentTimeMillis();
        }
    }
    // 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 or txn count
    // The throughput may be throttled depending on client configuration
    System.out.println("\nRunning benchmark...");
    final long benchmarkEndTime = System.currentTimeMillis() + (1000l * config.duration);
    long currentTime = System.currentTimeMillis();
    long diff = benchmarkEndTime - currentTime;
    int i = 1;
    long putCount = 0;
    double mpRand;
    String msg = "";
    while (benchmarkEndTime > currentTime && putCount < config.maxputs) {
        if (debug && diff != 0 && diff % 5000.00 == 0 && i % 5 == 0) {
            msg = "i = " + i + ", Time remaining in seconds: " + diff / 1000l + ", totalConnections = " + totalConnections.get();
            prt(msg);
            i++;
        }
        if (totalConnections.get() < 1) {
            if (debug) {
                msg = "i = " + i + ", diff = '" + diff + ", totalConnections = " + totalConnections.get() + "\n";
            }
            msg += "All connections are lost! VoltDB could be down!!";
            prt(msg);
            System.exit(1);
        }
        // Decide whether to perform a GET or PUT operation
        if (rand.nextDouble() < config.getputratio) {
            // Get a key/value pair, asynchronously
            mpRand = rand.nextDouble();
            if (mpRand < config.multisingleratio) {
                if (totalConnections.get() > 1 && config.poolsize > 10000) {
                    slow = true;
                    debug = true;
                } else
                    debug = false;
                client.callProcedure(new GetCallback(mpRand), "GetMp", processor.generateRandomKeyForRetrieval());
            } else {
                client.callProcedure(new GetCallback(mpRand), "Get", processor.generateRandomKeyForRetrieval());
            }
        } else {
            // Put a key/value pair, asynchronously
            putCount++;
            final PayloadProcessor.Pair pair = processor.generateForStore();
            mpRand = rand.nextDouble();
            if (rand.nextDouble() < config.multisingleratio) {
                if (totalConnections.get() > 1 && config.poolsize > 10000) {
                    slow = true;
                    debug = true;
                } else
                    debug = false;
                client.callProcedure(new PutCallback(pair, mpRand), "PutMp", pair.Key, pair.getStoreValue());
            } else {
                client.callProcedure(new PutCallback(pair, mpRand), "Put", pair.Key, pair.getStoreValue());
            }
        }
        currentTime = System.currentTimeMillis();
        diff = benchmarkEndTime - currentTime;
    }
    timer.cancel();
}
Also used : NullCallback(org.voltdb.client.NullCallback)

Example 17 with NullCallback

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

the class AdBrokerBenchmark method requestAd.

/**
     * Invoke the stored procedure GetHighestBidForLocation, which, given a random
     * point, returns the id of the bid that has the highest dollar amount.
     */
private void requestAd() {
    long deviceId = Math.abs(m_rand.nextLong()) % AdBrokerBenchmark.NUM_DEVICES;
    GeographyPointValue point = getRandomPoint();
    try {
        m_client.callProcedure(new NullCallback(), "GetHighestBidForLocation", deviceId, point);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : NullCallback(org.voltdb.client.NullCallback) IOException(java.io.IOException) GeographyPointValue(org.voltdb.types.GeographyPointValue)

Example 18 with NullCallback

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

the class SyncBenchmark 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);
    // preload keys if requested
    System.out.println();
    if (config.preload) {
        System.out.println("Preloading data store...");
        for (int i = 0; i < config.poolsize; i++) {
            client.callProcedure(new NullCallback(), "STORE.upsert", String.format(processor.KeyFormat, i), processor.generateForStore().getStoreValue());
        }
        client.drain();
        System.out.println("Preloading complete.\n");
    }
    System.out.print(HORIZONTAL_RULE);
    System.out.println(" Starting Benchmark");
    System.out.println(HORIZONTAL_RULE);
    // create/start the requested number of threads
    Thread[] kvThreads = new Thread[config.threads];
    for (int i = 0; i < config.threads; ++i) {
        kvThreads[i] = new Thread(new KVThread());
        kvThreads[i].start();
    }
    // Run the benchmark loop for the requested warmup time
    System.out.println("Warming up...");
    Thread.sleep(1000l * config.warmup);
    // signal to threads to end the warmup phase
    warmupComplete.set(true);
    // 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 warmup time
    System.out.println("\nRunning benchmark...");
    Thread.sleep(1000l * config.duration);
    // stop the threads
    benchmarkComplete.set(true);
    // cancel periodic stats printing
    timer.cancel();
    // block until all outstanding txns return
    client.drain();
    // join on the threads
    for (Thread t : kvThreads) {
        t.join();
    }
    // print the summary results
    printResults();
    // close down the client connections
    client.close();
}
Also used : NullCallback(org.voltdb.client.NullCallback)

Example 19 with NullCallback

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

the class NibbleDeleter method run.

/**
     * Remove aged-out data from the ad_requests table.  This table is partitioned,
     * and may be large, so use the "run-everywhere" pattern to minimize impact
     * to throughput.
     *
     * Also remove old expired bids from the bids table.
     */
@Override
public void run() {
    try {
        VoltTable partitionKeys = null;
        partitionKeys = m_client.callProcedure("@GetPartitionKeys", "INTEGER").getResults()[0];
        while (partitionKeys.advanceRow()) {
            m_client.callProcedure(new NullCallback(), "DeleteOldAdRequests", partitionKeys.getLong("PARTITION_KEY"), m_expiredAgeInSeconds);
        }
        m_client.callProcedure(new NullCallback(), "DeleteExpiredBids");
    } catch (IOException | ProcCallException ex) {
        ex.printStackTrace();
    }
}
Also used : NullCallback(org.voltdb.client.NullCallback) IOException(java.io.IOException) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

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