Mercurial > stress-tester
changeset 892:c8b4ff11d1c0
GlobalConfigMain almost works
author | Devel 1 |
---|---|
date | Tue, 27 Mar 2018 15:19:12 +0200 |
parents | 75051c952983 |
children | f1ae7ba51a29 |
files | stress-tester/src/main/java/com/passus/st/GlobalConfigMain.java stress-tester/src/main/java/com/passus/st/job/TestJob.java |
diffstat | 2 files changed, 36 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/GlobalConfigMain.java Tue Mar 27 14:24:26 2018 +0200 +++ b/stress-tester/src/main/java/com/passus/st/GlobalConfigMain.java Tue Mar 27 15:19:12 2018 +0200 @@ -12,6 +12,8 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; public class GlobalConfigMain { @@ -57,17 +59,35 @@ cliHelper.printError(sb.toString()); } + final long startTime = System.currentTimeMillis(); MetricsCollector metricsCollector = testJob.getMetricsCollector(); + SummaryMetricsCollectionHandler summMetricsHandler; + ScheduledExecutorService executor; if (metricsCollector != null) { - SummaryMetricsCollectionHandler summMetricsHandler = new SummaryMetricsCollectionHandler(); + summMetricsHandler = new SummaryMetricsCollectionHandler(); metricsCollector.addHandler(summMetricsHandler); - ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); - final long startTime = System.currentTimeMillis(); + executor = Executors.newSingleThreadScheduledExecutor(); executor.scheduleAtFixedRate(() -> Main.printMetrics(summMetricsHandler.getMetrics(), startTime), 5, 5, TimeUnit.SECONDS); + } else { + summMetricsHandler = null; + executor = null; } + final Logger logger = LogManager.getLogger("GlobalConfigMain"); + testJob.start(); + logger.debug("TestJob started"); + testJob.join(); + logger.debug("TestJob finished"); + testJob.stop(); + logger.debug("TestJob stopped"); + if (metricsCollector != null && summMetricsHandler != null && executor != null) { + executor.shutdownNow(); + metricsCollector.collect(); + metricsCollector.flush(true); + Main.printMetrics(summMetricsHandler.getMetrics(), startTime); + } } catch (ParseException e) { System.out.println(e.getMessage()); printHelp(options);
--- a/stress-tester/src/main/java/com/passus/st/job/TestJob.java Tue Mar 27 14:24:26 2018 +0200 +++ b/stress-tester/src/main/java/com/passus/st/job/TestJob.java Tue Mar 27 15:19:12 2018 +0200 @@ -7,6 +7,7 @@ import com.passus.st.client.Client; import com.passus.st.client.http.HttpClient; import com.passus.st.client.http.HttpClientListener; +import com.passus.st.client.http.HttpSourceNameAwareClientWorkerDispatcher; import com.passus.st.client.http.ReporterDestination; import com.passus.st.config.TestJobConfigurator; import com.passus.st.emitter.Emitter; @@ -196,6 +197,18 @@ eventSources.forEach(src -> { src.setHandler(firstClient); }); + + // TODO: quickfix + clients.forEach((client) -> { + if (client instanceof HttpClient) { + HttpClient hc = (HttpClient) client; + if (hc.getDispatcher() instanceof HttpSourceNameAwareClientWorkerDispatcher) { + hc.setWorkersNum(eventSources.size()); + LOGGER.debug("Forcibly changing workersNum to {}", eventSources.size()); + } + } + }); + } }