public abstract class ThreadLocalTaskFactory extends AbstractTaskFactory
Locust.run(AbstractTask...) only accepts instances of AbstractTask and
uses them across threads, the implementation of AbstractTask must be thread-safe. It's not easy if we want to keep
some thread-local fields, like tcp connections.
Now, we can use ThreadLocalTaskFactory. Instances of AbstractTask are created after the creation of ThreadPool and
made thread-local, so the implementation of AbstractTask can keep some thread-local fields.| 构造器和说明 |
|---|
ThreadLocalTaskFactory() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
execute()
Test scenarios should be implemented in this method, like sending http request.
|
void |
onStart()
This method will be executed once before the test loop.
|
void |
onStop()
This method will be executed once after the test loop stopped, whether it ends in failure or not.
|
createTaskgetName, getWeight, runpublic void onStart()
AbstractTaskonStart 在类中 AbstractTaskpublic void execute()
throws Exception
AbstractTaskexecute 在类中 AbstractTaskException - test scenarios may throw exception.public void onStop()
AbstractTaskonStop 在类中 AbstractTaskCopyright © 2022. All rights reserved.