Package org.apache.qpid.junit.extensions

Examples of org.apache.qpid.junit.extensions.TimingController


        String messageCorrelationId = Long.toString(corellationIdGenerator.incrementAndGet());
        _logger.debug("messageCorrelationId = " + messageCorrelationId);

        // Initialize the count and timing controller for the new correlation id.
        PerCorrelationId perCorrelationId = new PerCorrelationId();
        TimingController tc = getTimingController().getControllerForCurrentThread();
        perCorrelationId._tc = tc;
        perCorrelationId._expectedCount = numPings;
        perCorrelationIds.put(messageCorrelationId, perCorrelationId);

        // Attach the chained message listener to the ping producer to listen asynchronously for the replies to these
        // messages.
        pingClient.setChainedMessageListener(batchedResultsListener);

        // Generate a sample message of the specified size.
        Message msg =
            pingClient.getTestMessage(perThreadSetup._pingClient.getReplyDestinations().get(0),
                testParameters.getPropertyAsInteger(PingPongProducer.MESSAGE_SIZE_PROPNAME),
                testParameters.getPropertyAsBoolean(PingPongProducer.PERSISTENT_MODE_PROPNAME));

        // Send the requested number of messages, and wait until they have all been received.
        long timeout = Long.parseLong(testParameters.getProperty(PingPongProducer.TIMEOUT_PROPNAME));
        int numReplies = pingClient.pingAndWaitForReply(msg, numPings, timeout, null);

        // Check that all the replies were received and log a fail if they were not.
        if (numReplies < numPings)
        {
            tc.completeTest(false, 0);
        }

        // Remove the chained message listener from the ping producer.
        pingClient.removeChainedMessageListener();
View Full Code Here


                // if a test times out.
                PerCorrelationId perCorrelationId = perCorrelationIds.get(correlationId);
                if (perCorrelationId != null)
                {
                    // Get the timing controller and expected count for this correlation id.
                    TimingController tc = perCorrelationId._tc;
                    int expected = perCorrelationId._expectedCount;

                    // Calculate how many messages were actually received in the last batch. This will be the batch size
                    // except where the number expected is not a multiple of the batch size and this is the first remaining
                    // count to cross a batch size boundary, in which case it will be the number expected modulo the batch
                    // size.
                    int receivedInBatch = ((expected - remainingCount) < _batchSize) ? (expected % _batchSize) : _batchSize;

                    // Register a test result for the correlation id.
                    try
                    {
                        tc.completeTest(true, receivedInBatch, latency);
                    }
                    catch (InterruptedException e)
                    {
                        // Ignore this. It means the test runner wants to stop as soon as possible.
                        _logger.warn("Got InterruptedException.", e);
View Full Code Here

        // Initialize the count and timing controller for the new correlation id.
        // This perCorrelationId is only used for controlling the test.
        // The PingClient itself uses its own perCorrelationId see in PingPongProducer
        PerCorrelationId perCorrelationId = new PerCorrelationId();
        TimingController tc = getTimingController().getControllerForCurrentThread();
        perCorrelationId._tc = tc;
        perCorrelationId._expectedCount = pingClient.getExpectedNumPings(numPings + preFill);
        perCorrelationIds.put(perThreadSetup._correlationId, perCorrelationId);

        // Must be called before pingAndWaitForReply to setup the CorrelationID.
View Full Code Here

                // if a test times out.
                PerCorrelationId perCorrelationId = perCorrelationIds.get(correlationId);
                if (perCorrelationId != null)
                {
                    // Get the timing controller and expected count for this correlation id.
                    TimingController tc = perCorrelationId._tc;
                    int expected = perCorrelationId._expectedCount;

                    // Calculate how many messages were actually received in the last batch. This will be the batch size
                    // except where the number expected is not a multiple of the batch size and this is the first remaining
                    // count to cross a batch size boundary, in which case it will be the number expected modulo the batch
                    // size.
                    int receivedInBatch = ((expected - remainingCount) < _batchSize) ? (expected % _batchSize) : _batchSize;

                    // Register a test result for the correlation id.
                    try
                    {
                        // Record the total latency for the batch.
                        // if batchSize=1 then this will just be the message latency
                        tc.completeTest(true, receivedInBatch, null, _batchSize == 1 ? latency : _batchLatency);
                        // Reset latency
                        _batchLatency = 0;
                    }
                    catch (InterruptedException e)
                    {
View Full Code Here

        // String messageCorrelationId = perThreadSetup._correlationId;
        // _logger.debug("messageCorrelationId = " + messageCorrelationId);

        // Initialize the count and timing controller for the new correlation id.
        PerCorrelationId perCorrelationId = new PerCorrelationId();
        TimingController tc = getTimingController().getControllerForCurrentThread();
        perCorrelationId._tc = tc;
        perCorrelationId._expectedCount = pingClient.getExpectedNumPings(numPings);
        perCorrelationIds.put(perThreadSetup._correlationId, perCorrelationId);

        // Send the requested number of messages, and wait until they have all been received.
View Full Code Here

                // if a test times out.
                PerCorrelationId perCorrelationId = perCorrelationIds.get(correlationId);
                if (perCorrelationId != null)
                {
                    // Get the timing controller and expected count for this correlation id.
                    TimingController tc = perCorrelationId._tc;
                    int expected = perCorrelationId._expectedCount;

                    // Calculate how many messages were actually received in the last batch. This will be the batch size
                    // except where the number expected is not a multiple of the batch size and this is the first remaining
                    // count to cross a batch size boundary, in which case it will be the number expected modulo the batch
                    // size.
                    int receivedInBatch = ((expected - remainingCount) < _batchSize) ? (expected % _batchSize) : _batchSize;

                    // Register a test result for the correlation id.
                    try
                    {
                        tc.completeTest(true, receivedInBatch);
                    }
                    catch (InterruptedException e)
                    {
                        // Ignore this. It means the test runner wants to stop as soon as possible.
                        _logger.warn("Got InterruptedException.", e);
View Full Code Here

        // Initialize the count and timing controller for the new correlation id.
        // This perCorrelationId is only used for controlling the test.
        // The PingClient itself uses its own perCorrelationId see in PingPongProducer
        PerCorrelationId perCorrelationId = new PerCorrelationId();
        TimingController tc = getTimingController().getControllerForCurrentThread();
        perCorrelationId._tc = tc;
        perCorrelationId._expectedCount = pingClient.getExpectedNumPings(numPings + preFill);
        perCorrelationIds.put(perThreadSetup._correlationId, perCorrelationId);

        // Must be called before pingAndWaitForReply to setup the CorrelationID.
View Full Code Here

                // if a test times out.
                PerCorrelationId perCorrelationId = perCorrelationIds.get(correlationId);
                if (perCorrelationId != null)
                {
                    // Get the timing controller and expected count for this correlation id.
                    TimingController tc = perCorrelationId._tc;
                    int expected = perCorrelationId._expectedCount;

                    // Calculate how many messages were actually received in the last batch. This will be the batch size
                    // except where the number expected is not a multiple of the batch size and this is the first remaining
                    // count to cross a batch size boundary, in which case it will be the number expected modulo the batch
                    // size.
                    int receivedInBatch = ((expected - remainingCount) < _batchSize) ? (expected % _batchSize) : _batchSize;

                    // Register a test result for the correlation id.
                    try
                    {
                        // Record the total latency for the batch.
                        // if batchSize=1 then this will just be the message latency
                        tc.completeTest(true, receivedInBatch, null, _batchSize == 1 ? latency : _batchLatency);
                        // Reset latency
                        _batchLatency = 0;
                    }
                    catch (InterruptedException e)
                    {
View Full Code Here

TOP

Related Classes of org.apache.qpid.junit.extensions.TimingController

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.