Search in sources :

Example 1 with NullCallback

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

the class BidGenerator method run.

/**
     * This is the "run" method for this Runnable subclass.
     *
     * Generate one new row for the bids table, and insert it.
     */
@Override
public void run() {
    long bidId = m_bidId++;
    long advertiserId = Math.abs(m_rand.nextLong()) % NUM_ADVERTISERS;
    GeographyValue bidRegion = Regions.pickRandomRegion();
    TimestampType bidStartTime = new TimestampType();
    TimestampType bidEndTime = new TimestampType(bidStartTime.getTime() + AdBrokerBenchmark.BID_DURATION_SECONDS * 1000000);
    // Amount of bid: a hundredth of a penny up to around a tenth of a penny.
    double amount = 0.00001 + 0.01 * m_rand.nextDouble();
    DecimalFormat df = new DecimalFormat("#.####");
    amount = Double.valueOf(df.format(amount));
    try {
        m_client.callProcedure(new NullCallback(), "bids.Insert", bidId, advertiserId, bidRegion, bidStartTime, bidEndTime, amount);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : GeographyValue(org.voltdb.types.GeographyValue) DecimalFormat(java.text.DecimalFormat) TimestampType(org.voltdb.types.TimestampType) NullCallback(org.voltdb.client.NullCallback) ProcCallException(org.voltdb.client.ProcCallException) IOException(java.io.IOException)

Example 2 with NullCallback

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

the class HTTPBenchmark 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(), "Put", 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();
    // if enabled close the graphite logger
    if (graphite != null) {
        graphite.close();
    }
    // if enabled close the csv logger
    if (csvlogger != null) {
        csvlogger.close();
    }
}
Also used : NullCallback(org.voltdb.client.NullCallback)

Example 3 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(), "Put", 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...");
    if (config.maxops > 0) {
        while (allOps.get() < config.maxops) {
            Thread.sleep(5_000);
        }
    } else {
        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();
    // if enabled close the graphite logger
    if (graphite != null) {
        graphite.close();
    }
    // if enabled close the csv logger
    if (csvlogger != null) {
        csvlogger.close();
    }
}
Also used : NullCallback(org.voltdb.client.NullCallback)

Example 4 with NullCallback

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

the class HTTPBenchmark 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(), "Put", 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);
    // setup the HTTP connection pool that will be used by the threads
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    cm.setMaxTotal(config.threads * 2);
    cm.setDefaultMaxPerRoute(config.threads);
    CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(cm).build();
    String[] servers = config.servers.split(",");
    // create/start the requested number of threads
    Thread[] kvThreads = new Thread[config.threads];
    for (int i = 0; i < config.threads; ++i) {
        HttpPost httppost = new HttpPost("http://" + servers[i % servers.length] + ":8080/api/1.0/");
        kvThreads[i] = new Thread(new KVThread(httpclient, httppost));
        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);
    // 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 : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpPost(org.apache.http.client.methods.HttpPost) NullCallback(org.voltdb.client.NullCallback) PoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager)

Example 5 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(), "Put", 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)

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