Search in sources :

Example 51 with TimerTask

use of java.util.TimerTask in project voltdb by VoltDB.

the class AsyncBenchmark method main.

// Application entry point
public static void main(String[] args) {
    try {
        // ---------------------------------------------------------------------------------------------------------------------------------------------------
        // Use the AppHelper utility class to retrieve command line application parameters
        // Define parameters and pull from command line
        apph.add("displayinterval", "display_interval_in_seconds", "Interval for performance feedback, in seconds.", 10).add("duration", "run_duration_in_seconds", "Benchmark duration, in seconds.", 120).add("servers", "comma_separated_server_list", "List of VoltDB servers to connect to.", "localhost").add("port", "port_number", "Client port to connect to on cluster nodes.", 21212).add("resultsize", "result_size", "Size of the result value returned by each operation", 0).add("paramsize", "param_size", "Size of the op parameter if the op supports arbitrary size params", 0).add("operation", "operation", "The procedure to invoke", "NoArgs").add("ratelimit", "rate_limit", "Rate limit to start from (number of transactions per second).", 900000).setArguments(args);
        // Retrieve parameters
        long displayInterval = apph.longValue("displayinterval");
        duration = apph.longValue("duration");
        String servers = apph.stringValue("servers");
        int port = apph.intValue("port");
        resultSize = apph.intValue("resultsize");
        paramSize = apph.intValue("paramsize");
        long rateLimit = apph.longValue("ratelimit");
        final String csv = apph.stringValue("statsfile");
        final String op = apph.stringValue("operation");
        // Validate parameters
        apph.validate("duration", (duration > 0)).validate("displayinterval", (displayInterval > 0)).validate("resultsize", (resultSize >= 0)).validate("paramsize", (paramSize >= 0)).validate("ratelimit", (rateLimit > 0));
        // Display actual parameters, for reference
        apph.printActualUsage();
        // ---------------------------------------------------------------------------------------------------------------------------------------------------
        // Get a client connection - we retry for a while in case the server hasn't started yet
        Con = ClientConnectionPool.getWithRetry(servers, port);
        // ---------------------------------------------------------------------------------------------------------------------------------------------------
        // Create a Timer task to display performance data on the operating procedures
        timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {

            @Override
            public void run() {
                System.out.print(Con.getStatistics(op));
            }
        }, displayInterval * 1000l, displayInterval * 1000l);
        // ---------------------------------------------------------------------------------------------------------------------------------------------------
        // Pick the transaction rate limiter helping object to use based on user request (rate limiting or latency targeting)
        limiter = new RateLimiter(rateLimit);
        // Run the benchmark loop for the requested duration
        if (op.substring(0, 6).equalsIgnoreCase("noargs")) {
            runNoArgs(op.endsWith("RW") ? false : true);
        } else if (op.substring(0, 13).equalsIgnoreCase("BinaryPayload")) {
            runBinaryPayload(op.endsWith("RW") ? false : true);
        }
        // ---------------------------------------------------------------------------------------------------------------------------------------------------
        // We're done - stop the performance statistics display task
        timer.cancel();
        // ---------------------------------------------------------------------------------------------------------------------------------------------------
        // Now print application results:
        // 1. Overall performance statistics for GET/PUT operations
        System.out.println("\n\n-------------------------------------------------------------------------------------\n" + " System Statistics\n" + "-------------------------------------------------------------------------------------\n\n");
        System.out.print(Con.getStatistics(op).toString(false));
        // 2. Per-procedure detailed performance statistics
        System.out.println("\n\n-------------------------------------------------------------------------------------\n" + " Detailed Statistics\n" + "-------------------------------------------------------------------------------------\n\n");
        System.out.print(Con.getStatistics().toString(false));
        // Dump statistics to a CSV file
        Con.saveStatistics(csv);
    // ---------------------------------------------------------------------------------------------------------------------------------------------------
    } catch (org.voltdb.client.NoConnectionsException x) {
        System.out.println("Exception: " + x);
        System.out.println("\n\n-------------------------------------------------------------------------------------\n");
        System.out.print("Lost connection - will try to reconnect ... \n");
        Con.close();
        timer.cancel();
        try {
            Con = ClientConnectionPool.getWithRetry(apph.stringValue("servers"), apph.intValue("port"));
        } catch (Exception e) {
            System.out.println("Another exception, I guess " + e);
        }
    } catch (Exception x) {
        System.out.println("Exception: " + x);
        x.printStackTrace();
        System.exit(1);
    }
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask) RateLimiter(org.voltdb.client.exampleutils.RateLimiter) IRateLimiter(org.voltdb.client.exampleutils.IRateLimiter)

Example 52 with TimerTask

use of java.util.TimerTask in project voltdb by VoltDB.

the class MOBenchmark method schedulePeriodicStats.

/**
     * Create a Timer task to display performance data on the Vote procedure
     * It calls printStatistics() every displayInterval seconds
     */
public void schedulePeriodicStats() {
    timer = new Timer();
    TimerTask statsPrinting = new TimerTask() {

        @Override
        public void run() {
            printStatistics();
        }
    };
    timer.scheduleAtFixedRate(statsPrinting, config.displayinterval * 1000, config.displayinterval * 1000);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask)

Example 53 with TimerTask

use of java.util.TimerTask in project voltdb by VoltDB.

the class OneShotBenchmark method schedulePeriodicStats.

/**
     * Create a Timer task to display performance data on the Vote procedure
     * It calls printStatistics() every displayInterval seconds
     */
public void schedulePeriodicStats() {
    timer = new Timer();
    TimerTask statsPrinting = new TimerTask() {

        @Override
        public void run() {
            printStatistics();
        }
    };
    timer.scheduleAtFixedRate(statsPrinting, config.displayinterval * 1000, config.displayinterval * 1000);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask)

Example 54 with TimerTask

use of java.util.TimerTask in project voltdb by VoltDB.

the class Benchmark method schedulePeriodicCheckpoint.

/**
     * Create a Timer task to write the value of the txnCount to
     * disk to make it available to apprunner
     */
private void schedulePeriodicCheckpoint() throws IOException {
    checkpointTimer = new Timer("Checkpoint Timer", true);
    TimerTask checkpointTask = new TimerTask() {

        @Override
        public void run() {
            String count = String.valueOf(txnCount.get()) + "\n";
            try {
                FileWriter writer = new FileWriter(".checkpoint", false);
                writer.write(count);
                writer.close();
            } catch (Exception e) {
                System.err.println("Caught exception writing checkpoint file.");
            }
        }
    };
    checkpointTimer.scheduleAtFixedRate(checkpointTask, 1 * 1000, 1 * 1000);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask) FileWriter(java.io.FileWriter) IOException(java.io.IOException) ProcCallException(org.voltdb.client.ProcCallException)

Example 55 with TimerTask

use of java.util.TimerTask in project voltdb by VoltDB.

the class NbboBenchmark method schedulePeriodicStats.

/**
     * Create a Timer task to display performance data on the Vote procedure
     * It calls printStatistics() every displayInterval seconds
     */
public void schedulePeriodicStats() {
    timer = new Timer();
    TimerTask statsPrinting = new TimerTask() {

        @Override
        public void run() {
            printStatistics();
        }
    };
    timer.scheduleAtFixedRate(statsPrinting, config.displayinterval * 1000, config.displayinterval * 1000);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask)

Aggregations

TimerTask (java.util.TimerTask)900 Timer (java.util.Timer)653 IOException (java.io.IOException)90 Date (java.util.Date)58 Test (org.junit.Test)57 File (java.io.File)30 ArrayList (java.util.ArrayList)29 Intent (android.content.Intent)25 AtomicLong (java.util.concurrent.atomic.AtomicLong)21 Handler (android.os.Handler)20 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)20 HashMap (java.util.HashMap)17 List (java.util.List)14 TextView (android.widget.TextView)13 CountDownLatch (java.util.concurrent.CountDownLatch)13 View (android.view.View)12 Map (java.util.Map)12 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)12 InputMethodManager (android.view.inputmethod.InputMethodManager)11 Random (java.util.Random)11