Package org.voltdb.client.exampleutils

Examples of org.voltdb.client.exampleutils.IRateLimiter


            , displayInterval*1000l
            , displayInterval*1000l
            );

            // Pick the transaction rate limiter helping object to use based on user request (rate limiting or latency targeting)
            IRateLimiter limiter = autoTune ?
                    new LatencyLimiter(Con, procedure, latencyTarget, rateLimit) :
                    new RateLimiter(rateLimit);

            // Run the loader first.
            if (runLoader) {
                doLoader(poolSize);
            }

            // Run the benchmark loop for the requested duration
            final long endTime = System.currentTimeMillis() + (1000l * duration);
            Random rand = new Random();
            while (endTime > System.currentTimeMillis())
            {
                doBenchmark(procedure, poolSize, rand, wait);

                // Use the limiter to throttle client activity
                limiter.throttle();
            }

            // We're done - stop the performance statistics display task
            timer.cancel();

View Full Code Here


            Con = ClientConnectionPool.getWithRetry(servers, port);

// ---------------------------------------------------------------------------------------------------------------------------------------------------

            // Pick the transaction rate limiter helping object to use based on user request (rate limiting or latency targeting)
            IRateLimiter limiter = null;
            limiter = new RateLimiter(rateLimit);

            int cycle = 0;
            // Run the benchmark loop for the requested duration
            final long endTime = System.currentTimeMillis() + (1000l * duration);
            while (endTime > System.currentTimeMillis())
            {
                // So, here's how we'll expose out-of-order replicated adhoc writes:
                // 1) do an insert/update/delete cycle on a given primary key
                // 2) some small fraction of the time, make one of these operations adhoc
                //    -- We do the adhoc synchronously on the master so that the ordering
                //       is deterministic
                // 3) Add in replication and watch the DRagent go boom when the adhoc
                //    queries are performed asynchronously and out-of-order on the replica
                // First, Insert
                if (rand.nextInt(1000) < 5)
                {
                    //System.out.println("Insert adhoc");
                    String query = "insert into votes (phone_number, state, contestant_number) values (" + cycle + ", 'MA', 999);";
                    ClientResponse response = Con.execute("@AdHoc", query);
                    InsertCallback blah = new InsertCallback(true, cycle);
                    blah.clientCallback(response);
                }
                else
                {
                    //System.out.println("Insert regular");
                    Con.executeAsync(new InsertCallback(false, cycle),
                                     "VOTES.insert", cycle, "MA", 999);
                }

                // Then, update
                if (rand.nextInt(1000) < 5)
                {
                    //System.out.println("Update adhoc");
                    ClientResponse response = Con.execute("@AdHoc", "update votes set state='RI', contestant_number=" + cycle + " where phone_number=" + cycle + ";");
                    UpdateCallback blah = new UpdateCallback(true, cycle);
                    blah.clientCallback(response);
                }
                else
                {
                    //System.out.println("Update regular");
                    Con.executeAsync(new UpdateCallback(false, cycle),
                                     "VOTES.update", cycle, "MA", cycle, cycle);
                }

                // Finally, delete
                if (rand.nextInt(1000) < 5)
                {
                    //System.out.println("Delete adhoc");
                    ClientResponse response = Con.execute("@AdHoc", "delete from votes where contestant_number=" + cycle + ";");
                    DeleteCallback blah = new DeleteCallback(true, cycle);
                    blah.clientCallback(response);
                }
                else
                {
                    //System.out.println("Delete regular");
                    Con.executeAsync(new DeleteCallback(false, cycle),
                                     "Delete", cycle);
                }
                cycle++;
                // Use the limiter to throttle client activity
                limiter.throttle();
            }

// --------------------------------------------------------------------------------------------------------

            Con.close();
View Full Code Here

            );

// ---------------------------------------------------------------------------------------------------------------------------------------------------

            // Pick the transaction rate limiter helping object to use based on user request (rate limiting or latency targeting)
            IRateLimiter limiter = null;
            if (autoTune)
                limiter = new LatencyLimiter(Con, procedure, latencyTarget, rateLimit);
            else
                limiter = new RateLimiter(rateLimit);

            // Run the benchmark loop for the requested duration
            final long endTime = System.currentTimeMillis() + (1000l * duration);
            Random rand = new Random();
            while (endTime > System.currentTimeMillis())
            {
                // Post the request, asynchronously
                Con.executeAsync(new ProcedureCallback()
                {
                    @Override
                    public void clientCallback(ClientResponse response) throws Exception
                    {
                        // Track the result of the request (Success, Failure)
                        if (response.getStatus() == ClientResponse.SUCCESS)
                            TrackingResults.incrementAndGet(0);
                        else
                            TrackingResults.incrementAndGet(1);
                    }
                }
                , procedure
                , (long)rand.nextInt(poolSize)
                , wait
                );

                // Use the limiter to throttle client activity
                limiter.throttle();
            }

// ---------------------------------------------------------------------------------------------------------------------------------------------------

            // We're done - stop the performance statistics display task
View Full Code Here

TOP

Related Classes of org.voltdb.client.exampleutils.IRateLimiter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.