Search in sources :

Example 1 with ManagementSupport

use of org.apache.axis2.transport.base.ManagementSupport in project wso2-axis2-transports by wso2.

the class AxisTestClient method afterReceive.

public void afterReceive() throws Exception {
    if (sender instanceof ManagementSupport) {
        ManagementSupport sender = (ManagementSupport) this.sender;
        synchronized (metrics) {
            long start = System.currentTimeMillis();
            while (true) {
                try {
                    Assert.assertEquals(1, metrics.getMessagesSent());
                    Assert.assertEquals(messagesSent + 1, sender.getMessagesSent());
                    long thisBytesSent = metrics.getBytesSent();
                    Assert.assertTrue("No increase in bytes sent in message level metrics", thisBytesSent != 0);
                    long newBytesSent = sender.getBytesSent();
                    Assert.assertTrue("No increase in bytes sent in transport level metrics", newBytesSent > bytesSent);
                    Assert.assertEquals("Mismatch between message and transport level metrics", thisBytesSent, newBytesSent - bytesSent);
                    break;
                } catch (AssertionFailedError ex) {
                    // SYNAPSE-491: Maybe the transport sender didn't finish updating the
                    // metrics yet. We give it a couple of seconds to do so.
                    long remaining = start + 5000 - System.currentTimeMillis();
                    if (remaining <= 0) {
                        throw ex;
                    } else {
                        log.debug("The transport sender didn't update the metrics yet (" + ex.getMessage() + "). Waiting for " + remaining + " ms.");
                        metrics.wait(remaining);
                    }
                }
            }
        }
        log.debug("Message level metrics check OK");
    }
}
Also used : ManagementSupport(org.apache.axis2.transport.base.ManagementSupport) AssertionFailedError(junit.framework.AssertionFailedError)

Example 2 with ManagementSupport

use of org.apache.axis2.transport.base.ManagementSupport in project wso2-axis2-transports by wso2.

the class AxisTestClient method beforeSend.

public void beforeSend() throws Exception {
    if (sender instanceof ManagementSupport) {
        ManagementSupport sender = (ManagementSupport) this.sender;
        messagesSent = sender.getMessagesSent();
        bytesSent = sender.getBytesSent();
        metrics = new MessageLevelMetricsCollectorImpl();
    } else {
        metrics = null;
    }
}
Also used : MessageLevelMetricsCollectorImpl(org.apache.axis2.transport.testkit.axis2.util.MessageLevelMetricsCollectorImpl) ManagementSupport(org.apache.axis2.transport.base.ManagementSupport)

Aggregations

ManagementSupport (org.apache.axis2.transport.base.ManagementSupport)2 AssertionFailedError (junit.framework.AssertionFailedError)1 MessageLevelMetricsCollectorImpl (org.apache.axis2.transport.testkit.axis2.util.MessageLevelMetricsCollectorImpl)1