Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable advanced monitoring for SQLServer & Postgres. #300

Merged
merged 87 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
7204ab4
bump sqlserver jdbc version - see also PR #231
bpkroth Jan 19, 2023
f55d7a6
Initial work on SqlServer monitor tweaks
anjagruenheid Jan 19, 2023
d2e0801
Merge branch 'main' into add-sqlserver-monitoring
bpkroth Apr 6, 2023
f9327b0
Streamlined new code, removed superfluous protos.
anjagruenheid Apr 10, 2023
8be549e
Fix system events extraction bug.
anjagruenheid Apr 10, 2023
16aa2bd
Change OS counters to be instance-specific.
anjagruenheid Apr 10, 2023
d83d434
Bugfix
anjagruenheid Apr 10, 2023
dba1c68
Variable name change.
anjagruenheid Apr 10, 2023
256aaf1
Add throughput vs advanced monitoring.
anjagruenheid Apr 10, 2023
e11d8da
Fix missing option in commandline.
anjagruenheid Apr 10, 2023
bdddd00
debugging
anjagruenheid Apr 10, 2023
4213e87
More debugging.
anjagruenheid Apr 10, 2023
2c5da87
String comparison fix.
anjagruenheid Apr 10, 2023
b7122e9
Remove debugging messages.
anjagruenheid Apr 10, 2023
c43157f
Update to README.
anjagruenheid Apr 10, 2023
b8f3862
Merge branch 'cmu-db:main' into add-sqlserver-monitoring
anjagruenheid Apr 10, 2023
d2d8793
Update src/main/java/com/oltpbenchmark/api/collectors/monitoring/Data…
anjagruenheid Apr 20, 2023
794d4d7
Update src/main/java/com/oltpbenchmark/api/collectors/monitoring/READ…
anjagruenheid Apr 20, 2023
7ec4e0e
Address some of the comments from Brian's review.
anjagruenheid Apr 21, 2023
4e3af64
Merge branch 'add-sqlserver-monitoring' of https://github.com/anjagru…
anjagruenheid Apr 21, 2023
7a9bc29
First draft for generic monitoring prefix (incl TPCC).
anjagruenheid Apr 26, 2023
442a2aa
Bugfix for wrong monitoring type.
anjagruenheid Apr 26, 2023
778db5c
Adjust SqlStmt usage to be dialect-compliant.
anjagruenheid Apr 26, 2023
e49679b
Bugfixes for query strings.
anjagruenheid Apr 26, 2023
6a54235
Debugging
anjagruenheid Apr 26, 2023
4693a05
Enable new monitoring in SQLServer & Postgres monitors.
anjagruenheid Apr 26, 2023
f768e4b
Remove superfluous monitoring references and shift prefix addition to…
anjagruenheid Apr 26, 2023
b9f0c31
Expand advanced monitoring to bugfix issues.
anjagruenheid Apr 26, 2023
a44b518
Make advanced monitoring analogous to loading dialects.
anjagruenheid Apr 26, 2023
888bdf6
Remove superfluous strings.
anjagruenheid Apr 26, 2023
6f22cf5
debugging
anjagruenheid Apr 26, 2023
fda6d31
remove logging
anjagruenheid Apr 26, 2023
af03f99
Same structure as dialects.
anjagruenheid Apr 26, 2023
80f0cc3
bugfix
anjagruenheid Apr 26, 2023
725645f
Reverse changes to Twitter/TPC-H.
anjagruenheid Apr 27, 2023
4e80e50
Debugging advanced monitoring.
anjagruenheid Apr 27, 2023
c29dbe0
Remove debugging message.
anjagruenheid Apr 27, 2023
a2932a2
Reset phase (not part of this PR).
anjagruenheid Apr 27, 2023
31187f7
reset phase #2
anjagruenheid Apr 27, 2023
f2dc2bc
reset
anjagruenheid Apr 27, 2023
b75e74b
Update src/main/java/com/oltpbenchmark/api/collectors/monitoring/READ…
anjagruenheid Apr 27, 2023
002be63
Update src/main/java/com/oltpbenchmark/api/collectors/monitoring/READ…
anjagruenheid Apr 27, 2023
a93605a
Update src/main/java/com/oltpbenchmark/api/collectors/monitoring/READ…
anjagruenheid Apr 27, 2023
431a64e
Revert untouched files.
anjagruenheid Apr 27, 2023
8a299ec
revert
anjagruenheid Apr 27, 2023
5d9c890
Merge branch 'add-sqlserver-monitoring' of https://github.com/anjagru…
anjagruenheid Apr 27, 2023
ce4e60e
Proper revert!
anjagruenheid Apr 27, 2023
45eed70
Merge branch 'main' into add-sqlserver-monitoring
bpkroth Apr 27, 2023
6de6378
Update src/main/java/com/oltpbenchmark/DBWorkload.java
anjagruenheid Apr 28, 2023
56680ab
Update src/main/java/com/oltpbenchmark/WorkloadConfiguration.java
anjagruenheid Apr 28, 2023
f7fe6a2
Update src/main/java/com/oltpbenchmark/api/Procedure.java
anjagruenheid Apr 28, 2023
5491cb6
Reset TPC-C, add worker rejoin variable.
anjagruenheid Apr 28, 2023
3b66449
Merge branch 'add-sqlserver-monitoring' of https://github.com/anjagru…
anjagruenheid Apr 28, 2023
34be7b4
Quick bugfixes due to changes in naming.
anjagruenheid Apr 28, 2023
3d5d61c
Monitor option parsing update.
anjagruenheid Apr 28, 2023
8d04915
Regex pattern extraction #1
anjagruenheid Apr 28, 2023
8ab9fed
SQLServer instance extraction fix.
anjagruenheid Apr 28, 2023
c87f141
Function consolidation.
anjagruenheid Apr 28, 2023
0d4ab70
Merge branch 'main' into add-sqlserver-monitoring
bpkroth May 1, 2023
a238e7d
Add advanced monitoring check to CI pipeline.
anjagruenheid May 17, 2023
a910a10
Merge branch 'main' into add-sqlserver-monitoring
anjagruenheid Jun 27, 2023
0be3132
Merge branch 'main' into add-sqlserver-monitoring
anjagruenheid Jun 30, 2023
c242dd7
Merge branch 'main' into add-sqlserver-monitoring
anjagruenheid Aug 28, 2023
aeaad23
Modify directory check
anjagruenheid Aug 28, 2023
d8060ab
Merge branch 'add-sqlserver-monitoring' of https://github.com/anjagru…
anjagruenheid Aug 28, 2023
9c231b3
try modified command
anjagruenheid Aug 29, 2023
c3ce912
Minor modifications to documentation.
anjagruenheid Aug 29, 2023
8fe7b7a
Update to main, formatting.
anjagruenheid Mar 26, 2024
07fc430
fmt plugin
anjagruenheid Mar 26, 2024
0e7bfab
bugfix
anjagruenheid Mar 26, 2024
76ce64d
Merge branch 'main' into add-sqlserver-monitoring
bpkroth May 9, 2024
b45368c
Enable use of pg_stat_statement extension in local docker-compose and…
bpkroth May 10, 2024
88af8e6
Enable use of pg_stat_statement extension in local docker-compose and…
bpkroth May 10, 2024
1e56148
enable advanced monitoring for pg as well
bpkroth May 10, 2024
3733b18
allow selectively upping services
bpkroth May 10, 2024
43dacf8
down service
bpkroth May 10, 2024
f41255e
fixup
bpkroth May 10, 2024
4a62240
Merge branch 'enable-pg-stat-extension' into add-sqlserver-monitoring
bpkroth May 10, 2024
0bdb341
Merge branch 'main' into add-sqlserver-monitoring
bpkroth May 10, 2024
9231f1c
tweaks
bpkroth May 10, 2024
8488870
quiet
bpkroth May 10, 2024
65a72af
Merge branch 'main' into add-sqlserver-monitoring
bpkroth May 13, 2024
b605eba
Merge branch 'main' into add-sqlserver-monitoring
bpkroth May 13, 2024
c3a7770
Merge remote-tracking branch 'anjagruenheid/add-sqlserver-monitoring'…
bpkroth May 13, 2024
3ea5a40
Merge pull request #3 from bpkroth/add-sqlserver-monitoring
anjagruenheid May 13, 2024
beb59de
Merge branch 'main' into add-sqlserver-monitoring
anjagruenheid May 13, 2024
87d4c80
bugfix
anjagruenheid May 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ jobs:
# In this case, we load the tpcc data.
if [[ ${{matrix.benchmark}} == templated ]]; then
java -jar benchbase.jar -b tpcc -c config/postgres/sample_tpcc_config.xml --create=true --load=true --execute=false --json-histograms results/histograms.json
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/postgres/sample_${{matrix.benchmark}}_config.xml --create=false --load=false --execute=true --json-histograms results/histograms.json
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/postgres/sample_${{matrix.benchmark}}_config.xml -im 1000 -mt advanced --create=false --load=false --execute=true --json-histograms results/histograms.json
elif [[ ${{matrix.benchmark}} == tpcc-with-reconnects ]]; then
# See Also: WITH_SERVICE_INTERRUPTIONS=true docker/build-run-benchmark-with-docker.sh
java -jar benchbase.jar -b tpcc -c config/postgres/sample_tpcc_config.xml --create=true --load=true
(sleep 10 && ./scripts/interrupt-docker-db-service.sh postgres) &
java -jar benchbase.jar -b tpcc -c config/postgres/sample_tpcc_config.xml --execute=true --json-histograms results/histograms.json
java -jar benchbase.jar -b tpcc -c config/postgres/sample_tpcc_config.xml -im 1000 -mt advanced --execute=true --json-histograms results/histograms.json
else
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/postgres/sample_${{matrix.benchmark}}_config.xml --create=true --load=true --execute=true --json-histograms results/histograms.json
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/postgres/sample_${{matrix.benchmark}}_config.xml -im 1000 -mt advanced --create=true --load=true --execute=true --json-histograms results/histograms.json
fi

# FIXME: Reduce the error rate so we don't need these overrides.
Expand All @@ -491,6 +491,12 @@ jobs:
./scripts/check_latest_benchmark_results.sh $results_benchmark
./scripts/check_histogram_results.sh results/histograms.json $ERRORS_THRESHOLD

# Running the monitor should create at least three files in the 'monitor' directory.
if ![ $(find "./results/monitor" -maxdepth 1 -mindepth 1 | wc -l) -gt 2]; then
echo "ERROR: Advanced monitoring unsuccessful, file directory and/or appropriate files not created." >&2
exit 1
fi

- name: Stop custom postgres service
run: |
./docker/postgres-latest/down.sh
Expand Down Expand Up @@ -638,14 +644,14 @@ jobs:
# In this case, we load the tpcc data.
if [[ ${{matrix.benchmark}} == templated ]]; then
java -jar benchbase.jar -b tpcc -c config/sqlserver/sample_tpcc_config.xml --create=true --load=true --execute=false --json-histograms results/histograms.json
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/sqlserver/sample_${{matrix.benchmark}}_config.xml --create=false --load=false --execute=true --json-histograms results/histograms.json
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/sqlserver/sample_${{matrix.benchmark}}_config.xml -im 1000 -mt advanced --create=false --load=false --execute=true --json-histograms results/histograms.json
elif [[ ${{matrix.benchmark}} == tpcc-with-reconnects ]]; then
# See Also: WITH_SERVICE_INTERRUPTIONS=true docker/build-run-benchmark-with-docker.sh
java -jar benchbase.jar -b tpcc -c config/sqlserver/sample_tpcc_config.xml --create=true --load=true
(sleep 10 && ./scripts/interrupt-docker-db-service.sh sqlserver) &
java -jar benchbase.jar -b tpcc -c config/sqlserver/sample_tpcc_config.xml --execute=true --json-histograms results/histograms.json
java -jar benchbase.jar -b tpcc -c config/sqlserver/sample_tpcc_config.xml -im 1000 -mt advanced --execute=true --json-histograms results/histograms.json
else
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/sqlserver/sample_${{matrix.benchmark}}_config.xml --create=true --load=true --execute=true --json-histograms results/histograms.json
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/sqlserver/sample_${{matrix.benchmark}}_config.xml -im 1000 -mt advanced --create=true --load=true --execute=true --json-histograms results/histograms.json
fi

# FIXME: Reduce the error rate so we don't need these overrides.
Expand All @@ -659,6 +665,12 @@ jobs:
./scripts/check_latest_benchmark_results.sh $results_benchmark
./scripts/check_histogram_results.sh results/histograms.json $ERRORS_THRESHOLD

# Running the monitor should create at least three files in the 'monitor' directory.
if ![ $(find "./results/monitor" -maxdepth 1 -mindepth 1 | wc -l) -gt 2]; then
echo "ERROR: Advanced monitoring unsuccessful, file directory and/or appropriate files not created." >&2
exit 1
anjagruenheid marked this conversation as resolved.
Show resolved Hide resolved
fi

## ----------------------------------------------------------------------------------
## Docker Build Test Publish
## ----------------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@
<artifactId>janino</artifactId>
<version>3.1.12</version>
</dependency>
<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>2.9.0</version>
<scope>provided</scope>
</dependency>

</dependencies>

<build>
Expand Down
40 changes: 32 additions & 8 deletions src/main/java/com/oltpbenchmark/DBWorkload.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,27 @@ public static void main(String[] args) throws Exception {
return;
}

// Seconds
int intervalMonitor = 0;
// Monitoring setup.
ImmutableMonitorInfo.Builder builder = ImmutableMonitorInfo.builder();
if (argsLine.hasOption("im")) {
intervalMonitor = Integer.parseInt(argsLine.getOptionValue("im"));
builder.monitoringInterval(Integer.parseInt(argsLine.getOptionValue("im")));
}
if (argsLine.hasOption("mt")) {
switch (argsLine.getOptionValue("mt")) {
case "advanced":
builder.monitoringType(MonitorInfo.MonitoringType.ADVANCED);
break;
case "throughput":
builder.monitoringType(MonitorInfo.MonitoringType.THROUGHPUT);
break;
default:
throw new ParseException(
"Monitoring type '"
+ argsLine.getOptionValue("mt")
+ "' is undefined, allowed values are: advanced/throughput");
}
}
MonitorInfo monitorInfo = builder.build();

// -------------------------------------------------------------------
// GET PLUGIN LIST
Expand Down Expand Up @@ -151,6 +167,14 @@ public static void main(String[] args) throws Exception {
// Nothing to do here !
}

// Set monitoring enabled, if all requirements are met.
if (monitorInfo.getMonitoringInterval() > 0
&& monitorInfo.getMonitoringType() == MonitorInfo.MonitoringType.ADVANCED
&& DatabaseType.get(xmlConfig.getString("type")).shouldCreateMonitoringPrefix()) {
LOG.info("Advanced monitoring enabled, prefix will be added to queries.");
wrkld.setAdvancedMonitoringEnabled(true);
}

// ----------------------------------------------------------------
// CREATE BENCHMARK MODULE
// ----------------------------------------------------------------
Expand Down Expand Up @@ -518,7 +542,7 @@ public static void main(String[] args) throws Exception {
if (isBooleanOptionSet(argsLine, "execute")) {
// Bombs away!
try {
Results r = runWorkload(benchList, intervalMonitor);
Results r = runWorkload(benchList, monitorInfo);
writeOutputs(r, activeTXTypes, argsLine, xmlConfig);
writeHistograms(r);

Expand Down Expand Up @@ -558,8 +582,8 @@ private static Options buildOptions(XMLConfiguration pluginConfig) {
options.addOption(null, "execute", true, "Execute the benchmark workload");
options.addOption("h", "help", false, "Print this help");
options.addOption("s", "sample", true, "Sampling window");
options.addOption(
"im", "interval-monitor", true, "Throughput Monitoring Interval in milliseconds");
options.addOption("im", "interval-monitor", true, "Monitoring Interval in milliseconds");
options.addOption("mt", "monitor-type", true, "Type of Monitoring (throughput/advanced)");
options.addOption(
"d",
"directory",
Expand Down Expand Up @@ -733,7 +757,7 @@ private static void runLoader(BenchmarkModule bench)
bench.loadDatabase();
}

private static Results runWorkload(List<BenchmarkModule> benchList, int intervalMonitor)
private static Results runWorkload(List<BenchmarkModule> benchList, MonitorInfo monitorInfo)
throws IOException {
List<Worker<?>> workers = new ArrayList<>();
List<WorkloadConfiguration> workConfs = new ArrayList<>();
Expand All @@ -748,7 +772,7 @@ private static Results runWorkload(List<BenchmarkModule> benchList, int interval
bench.getBenchmarkName().toUpperCase(), num_phases, (num_phases > 1 ? "s" : "")));
workConfs.add(bench.getWorkloadConfiguration());
}
Results r = ThreadBench.runRateLimitedBenchmark(workers, workConfs, intervalMonitor);
Results r = ThreadBench.runRateLimitedBenchmark(workers, workConfs, monitorInfo);
LOG.info(SINGLE_LINE);
LOG.info("Rate limited reqs/s: {}", r);
return r;
Expand Down
112 changes: 47 additions & 65 deletions src/main/java/com/oltpbenchmark/ThreadBench.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/*
* Copyright 2020 by OLTPBenchmark Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
*/

Expand All @@ -21,7 +19,10 @@
import com.oltpbenchmark.api.BenchmarkModule;
import com.oltpbenchmark.api.TransactionType;
import com.oltpbenchmark.api.Worker;
import com.oltpbenchmark.api.collectors.monitoring.Monitor;
import com.oltpbenchmark.api.collectors.monitoring.MonitorGen;
import com.oltpbenchmark.types.State;
import com.oltpbenchmark.util.MonitorInfo;
import com.oltpbenchmark.util.StringUtil;
import java.util.*;
import org.apache.commons.collections4.map.ListOrderedMap;
Expand All @@ -30,30 +31,35 @@

public class ThreadBench implements Thread.UncaughtExceptionHandler {
private static final Logger LOG = LoggerFactory.getLogger(ThreadBench.class);
// Determines how long (in ms) to wait until monitoring thread rejoins the
// main thread.
private static final int MONITOR_REJOIN_TIME = 60000;

private final BenchmarkState testState;
private final List<? extends Worker<? extends BenchmarkModule>> workers;
private final ArrayList<Thread> workerThreads;
private final List<WorkloadConfiguration> workConfs;
private final ArrayList<LatencyRecord.Sample> samples = new ArrayList<>();
private final int intervalMonitor;
private final MonitorInfo monitorInfo;

private Monitor monitor = null;

private ThreadBench(
List<? extends Worker<? extends BenchmarkModule>> workers,
List<WorkloadConfiguration> workConfs,
int intervalMonitoring) {
MonitorInfo monitorInfo) {
this.workers = workers;
this.workConfs = workConfs;
this.workerThreads = new ArrayList<>(workers.size());
this.intervalMonitor = intervalMonitoring;
this.monitorInfo = monitorInfo;
this.testState = new BenchmarkState(workers.size() + 1);
}

public static Results runRateLimitedBenchmark(
List<Worker<? extends BenchmarkModule>> workers,
List<WorkloadConfiguration> workConfs,
int intervalMonitoring) {
ThreadBench bench = new ThreadBench(workers, workConfs, intervalMonitoring);
MonitorInfo monitorInfo) {
ThreadBench bench = new ThreadBench(workers, workConfs, monitorInfo);
return bench.runRateLimitedMultiPhase();
}

Expand Down Expand Up @@ -88,10 +94,9 @@ private int finalizeWorkers(ArrayList<Thread> workerThreads) throws InterruptedE
// to terminate... hands otherwise

/*
* // CARLO: Maybe we might want to do this to kill threads that are
* hanging... if (workerThreads.get(i).isAlive()) {
* workerThreads.get(i).kill(); try { workerThreads.get(i).join(); }
* catch (InterruptedException e) { } }
* // CARLO: Maybe we might want to do this to kill threads that are hanging... if
* (workerThreads.get(i).isAlive()) { workerThreads.get(i).kill(); try {
* workerThreads.get(i).join(); } catch (InterruptedException e) { } }
*/

requests += workers.get(i).getRequests();
Expand All @@ -116,17 +121,11 @@ private Results runRateLimitedMultiPhase() {
this.createWorkerThreads();

// long measureStart = start;
Phase phase = null;

long startTs = System.currentTimeMillis();
long start = System.nanoTime();
long warmupStart = System.nanoTime();
long warmup = warmupStart;
long measureEnd = -1;
// used to determine the longest sleep interval
double lowestRate = Double.MAX_VALUE;

Phase phase = null;

for (WorkloadState workState : workStates) {
workState.switchToNextPhase();
phase = workState.getCurrentPhase();
Expand All @@ -145,6 +144,12 @@ private Results runRateLimitedMultiPhase() {
}
}

long startTs = System.currentTimeMillis();
long start = System.nanoTime();
long warmupStart = System.nanoTime();
long warmup = warmupStart;
long measureEnd = -1;

long intervalNs = getInterval(lowestRate, phase.getArrival());

long nextInterval = start + intervalNs;
Expand All @@ -157,8 +162,11 @@ private Results runRateLimitedMultiPhase() {
boolean lastEntry = false;

// Initialize the Monitor
if (this.intervalMonitor > 0) {
new MonitorThread(this.intervalMonitor).start();
if (this.monitorInfo.getMonitoringInterval() > 0) {
this.monitor =
MonitorGen.getMonitor(
this.monitorInfo, this.testState, this.workers, this.workConfs.get(0));
this.monitor.start();
}

// Allow workers to start work.
Expand Down Expand Up @@ -301,6 +309,18 @@ private Results runRateLimitedMultiPhase() {
}
}

// Stop the monitoring thread separately from cleanup all the workers so we can ignore errors
// from these threads (including possible SQLExceptions), but not the others.
try {
if (this.monitor != null) {
this.monitor.interrupt();
this.monitor.join(MONITOR_REJOIN_TIME);
this.monitor.tearDown();
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}

try {
int requests = finalizeWorkers(this.workerThreads);

Expand Down Expand Up @@ -528,42 +548,4 @@ public void run() {
}
}
}

private class MonitorThread extends Thread {
private final int intervalMonitor;

{
this.setDaemon(true);
}

/**
* @param interval How long to wait between polling in milliseconds
*/
MonitorThread(int interval) {
this.intervalMonitor = interval;
}

@Override
public void run() {
LOG.info("Starting MonitorThread Interval [{}ms]", this.intervalMonitor);
while (true) {
try {
Thread.sleep(this.intervalMonitor);
} catch (InterruptedException ex) {
return;
}

// Compute the last throughput
long measuredRequests = 0;
synchronized (testState) {
for (Worker<?> w : workers) {
measuredRequests += w.getAndResetIntervalRequests();
}
}
double seconds = this.intervalMonitor / 1000d;
double tps = (double) measuredRequests / seconds;
LOG.info("Throughput: {} txn/sec", tps);
}
}
}
}
Loading