public interface MessageGenerator
A definition of contract for all message generators.
A message generator controls how many threads are being used to generate the messages, is responsible for creating and submitting
SenderTasks
and controls the other components involved in the performance test execution.
A message generator is the most crucial and complicated component of PerfCake and it is highly recommended to reuse one of existing implementations as they already offer mostly wanted features.
The main task of a message generator is to take care of the sending threads, create SenderTask
s as needed and monitor test progress.
It is important to properly shutdown the message generation for both time and iteration based test length control. In the case of an iteration based
control, a generator must wait for all the messages to be processed. In the case of a time based control, the test stops immediately after the time
has elapsed.
Each SenderTask
takes a MessageGenerator
instance to be able to notify the parent generator of any errors that might
have occurred.
When there is a separate message channel used to receive messages, a Correlator
is set to match requests and responses. The Correlator
is also
passed to the SenderTask
so it can register sent messages with it.
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes and finalizes the generator.
|
void |
generate()
Generates the messages.
|
int |
getActiveThreadsCount()
Gets the number of active threads used currently by the generator.
|
long |
getTasksInQueue()
Gets the number of sender tasks in the queue awaiting to be processed.
|
int |
getThreads()
Gets the number of threads that should be used to generate the messages.
|
void |
init(MessageSenderManager messageSenderManager,
List<MessageTemplate> messageStore)
Initializes the generator.
|
void |
interrupt(Exception exception)
Interrupts the execution with a message from failed sender.
|
boolean |
isFailFast()
Tells whether we should interrupt the generator immediately after a first error occurred.
|
void |
setCorrelator(Correlator correlator)
Sets a
Correlator to match requests and responses when a separate message channel is used for receiving responses. |
void |
setReportManager(ReportManager reportManager)
Sets the
ReportManager to be used for the current performance test execution. |
void |
setRunInfo(RunInfo runInfo)
Sets the current
RunInfo to control generating of the messages. |
void |
setSequenceManager(SequenceManager sequenceManager)
Sets a manager of sequences that can be used to replace placeholders in a message template and sender's target.
|
MessageGenerator |
setThreads(int threads)
Sets the number of threads used to generate the messages.
|
void |
setValidationManager(ValidationManager validationManager)
Configures the
ValidationManager to be used for the performance test execution. |
void init(MessageSenderManager messageSenderManager, List<MessageTemplate> messageStore) throws PerfCakeException
MessageSenderManager
should be initialized as well.messageSenderManager
- Message sender manager.messageStore
- Message store where the messages are taken from.PerfCakeException
- When it was not possible to initialize the generator.void generate() throws Exception
Exception
- When it was not possible to generate the messages.void interrupt(Exception exception)
exception
- The cause of the interruption.void close() throws PerfCakeException
MessageSenderManager
must be closed as well.PerfCakeException
- When it was not possible to smoothly finalize the generator.void setRunInfo(RunInfo runInfo)
RunInfo
to control generating of the messages.runInfo
- RunInfo
to be used.void setReportManager(ReportManager reportManager)
ReportManager
to be used for the current performance test execution.reportManager
- ReportManager
to be used.void setValidationManager(ValidationManager validationManager)
ValidationManager
to be used for the performance test execution.validationManager
- ValidationManager
to be usedvoid setSequenceManager(SequenceManager sequenceManager)
sequenceManager
- The SequenceManager
to be used to replace placeholders in a message template and sender's target.int getThreads()
MessageGenerator setThreads(int threads)
threads
- The number of threads to be used.int getActiveThreadsCount()
long getTasksInQueue()
void setCorrelator(Correlator correlator)
Correlator
to match requests and responses when a separate message channel is used for receiving responses.
Null means that no correlator and no receiver is used.correlator
- The correlator to be used to match requests and responses.boolean isFailFast()
perfcake.fail.fast
system property.Copyright © 2010–2017 PerfCake Community. All rights reserved.