-1

I'm making a load test tool that launches multiple thread to simulate load on the target server. Each thread executes a predefined set of commands in the structure of TestSuite - TestCase- TestStep and each level returns results objects (of respective types). Each thread loops its predefined commands, so a series of TestSuite results are generated and it takes a while for all the loops to finish.

I'm trying to find the best way to show results generated in the still running threads. I've thought about a few possible ways:

  1. Use BlockingQueue and producer - consumer pattern. This requires heavy concurrency programming and I haven't been very clear on how I should handle different levels of results - suite results, case results and step results.

  2. Use a concurrent map to hold reference to results, and poll that map periodically to show what's available. This can be very inefficient. How do I just get the new results every time I poll?

  3. Develop a custom Log4J logger, so I can add appenders which will receive results on-the-fly. I haven't researched on how much work is involved if I use this approach. Is it even possible? Considering the level of result types it needs to handle.

0

This sounds like a pretty standard multi-threading problem which can be solved by well-established techniques.

My suggestion would be:

  • Set up a singleton class whose job in life is to log events. Synchronize the methods to ensure it is thread safe.
  • Have each test regularly call the thread-safe logger to do any logging work. Make sure that the logging message includes a thread ID.

As your logging class is thread-safe, you are free to attach whatever appenders suit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.