use of org.apache.qpid.disttest.message.ParticipantResult in project qpid-broker-j by apache.
the class ConsumerParticipant method startTest.
@Override
public void startTest(String registeredClientName, ResultReporter resultReporter) throws Exception {
final int acknowledgeMode = _jmsDelegate.getAcknowledgeMode(_command.getSessionName());
final String providerVersion = _jmsDelegate.getProviderVersion(_command.getSessionName());
final String protocolVersion = _jmsDelegate.getProtocolVersion(_command.getSessionName());
if (_command.isSynchronous()) {
synchronousRun();
} else {
LOGGER.debug("Consumer {} registering listener", getName());
_jmsDelegate.registerListener(_command.getParticipantName(), new MessageListener() {
@Override
public void onMessage(Message message) {
processAsyncMessage(message);
}
});
waitUntilMsgListenerHasFinished();
rethrowAnyAsyncMessageListenerException();
}
Date end = new Date();
final Date start = new Date(_startTime);
int numberOfMessagesReceived = _totalNumberOfMessagesReceived.get();
long totalPayloadSize = _totalPayloadSizeOfAllMessagesReceived.get();
int payloadSize = getPayloadSizeForResultIfConstantOrZeroOtherwise(_allConsumedPayloadSizes);
LOGGER.info("Consumer {} finished consuming. Number of messages consumed: {}", getName(), numberOfMessagesReceived);
ParticipantResult result = _resultFactory.createForConsumer(getName(), registeredClientName, _command, acknowledgeMode, numberOfMessagesReceived, payloadSize, totalPayloadSize, start, end, _messageLatencies, providerVersion, protocolVersion);
resultReporter.reportResult(result);
}
use of org.apache.qpid.disttest.message.ParticipantResult in project qpid-broker-j by apache.
the class ResultsForAllTests method getAllParticipantsResult.
public List<ITestResult> getAllParticipantsResult() {
List<ITestResult> results = new ArrayList<>(_results.size());
for (ITestResult testResult : _results) {
for (ParticipantResult participantResult : testResult.getParticipantResults()) {
if (TestResultAggregator.ALL_PARTICIPANTS_NAME.equals(participantResult.getParticipantName())) {
TestResult summaryTestResult = new TestResult(testResult.getName());
summaryTestResult.addParticipantResult(participantResult);
results.add(summaryTestResult);
}
}
}
return results;
}
use of org.apache.qpid.disttest.message.ParticipantResult in project qpid-broker-j by apache.
the class ProducerParticipant method startTest.
@Override
public void startTest(String registeredClientName, ResultReporter resultReporter) throws Exception {
long startTime = 0;
Message lastPublishedMessage = null;
int numberOfMessagesSent = 0;
long totalPayloadSizeOfAllMessagesSent = 0;
NavigableSet<Integer> allProducedPayloadSizes = new TreeSet<>();
LOGGER.debug("Producer {} about to send messages. Duration limit: {} ms Message Limit : {}", getName(), _maximumDuration, _numberOfMessages);
while (_stopTestLatch.getCount() != 0) {
if (_rateLimiter != null) {
_rateLimiter.acquire();
}
if (_collectData) {
if (startTime == 0) {
startTime = System.currentTimeMillis();
}
if ((_maximumDuration > 0 && System.currentTimeMillis() - startTime >= _maximumDuration) || (_numberOfMessages > 0 && numberOfMessagesSent >= _numberOfMessages)) {
ParticipantResult result = finaliseResults(registeredClientName, startTime, numberOfMessagesSent, totalPayloadSizeOfAllMessagesSent, allProducedPayloadSizes);
resultReporter.reportResult(result);
_collectData = false;
}
lastPublishedMessage = _jmsDelegate.sendNextMessage(_command);
numberOfMessagesSent++;
int lastPayloadSize = _jmsDelegate.calculatePayloadSizeFrom(lastPublishedMessage);
totalPayloadSizeOfAllMessagesSent += lastPayloadSize;
allProducedPayloadSizes.add(lastPayloadSize);
LOGGER.trace("message {} sent by {}", numberOfMessagesSent, this);
final boolean batchLimitReached = (_batchSize <= 0 || numberOfMessagesSent % _batchSize == 0);
if (batchLimitReached) {
if (LOGGER.isTraceEnabled() && _batchSize > 0) {
LOGGER.trace("Committing: batch size " + _batchSize);
}
_jmsDelegate.commitIfNecessary(_command.getSessionName());
doSleepForInterval();
}
} else {
if (_maximumDuration > 0) {
_jmsDelegate.sendNextMessage(_command);
_jmsDelegate.commitIfNecessary(_command.getSessionName());
LOGGER.trace("Pre-message sent by {}", this);
}
if (_rateLimiter == null && _maximumDuration == 0) {
if (!_startDataCollectionLatch.await(1, TimeUnit.SECONDS)) {
LOGGER.debug("Producer {} still waiting for collectingData command from coordinator", getName());
}
}
}
}
_hasStoppedLatch.countDown();
}
use of org.apache.qpid.disttest.message.ParticipantResult in project qpid-broker-j by apache.
the class ParticipantResultFactory method createForError.
public ParticipantResult createForError(String participantName, String clientRegisteredName, String errorMessage) {
ParticipantResult result = new ParticipantResult();
result.setParticipantName(participantName);
result.setRegisteredClientName(clientRegisteredName);
result.setErrorMessage(errorMessage);
return result;
}
use of org.apache.qpid.disttest.message.ParticipantResult in project qpid-broker-j by apache.
the class ResultsDbWriterTest method testWriteResults.
@Test
public void testWriteResults() throws Exception {
Context context = getContext();
ResultsForAllTests results = _resultsTestFixture.createResultsForAllTests();
String runId = "myRunId";
ResultsDbWriter resultsDbWriter = new ResultsDbWriter(context, runId, _clock);
resultsDbWriter.begin();
resultsDbWriter.writeResults(results, "testfile");
ParticipantResult expectedResult = _resultsTestFixture.getFirstParticipantResult(results);
assertResultsAreInDb(context, expectedResult, runId);
}
Aggregations