diff options
author | Luck <git@lucko.me> | 2019-04-16 21:37:59 +0100 |
---|---|---|
committer | Luck <git@lucko.me> | 2019-04-16 21:37:59 +0100 |
commit | ecd4cec8545460a4fc4ca65b911c2503a00cd8e7 (patch) | |
tree | 62067383a1044abc3a09724e89c6e7c619e87ec0 /spark-common/src/main/java/me/lucko/spark/common/command | |
parent | 8a61b404848ed8e3c27f06eb73239d37d4273240 (diff) | |
download | spark-ecd4cec8545460a4fc4ca65b911c2503a00cd8e7.tar.gz spark-ecd4cec8545460a4fc4ca65b911c2503a00cd8e7.tar.bz2 spark-ecd4cec8545460a4fc4ca65b911c2503a00cd8e7.zip |
Lots of refactoring, add tps command
Diffstat (limited to 'spark-common/src/main/java/me/lucko/spark/common/command')
6 files changed, 245 insertions, 119 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/Command.java b/spark-common/src/main/java/me/lucko/spark/common/command/Command.java index fb440b1..c9f6551 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/Command.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/Command.java @@ -21,7 +21,6 @@ package me.lucko.spark.common.command; import com.google.common.collect.ImmutableList; - import me.lucko.spark.common.SparkPlatform; import java.util.Collections; @@ -109,7 +108,7 @@ public class Command<S> { @FunctionalInterface public interface Executor<S> { - void execute(SparkPlatform<S> platform, S sender, Arguments arguments); + void execute(SparkPlatform<S> platform, S sender, CommandResponseHandler resp, Arguments arguments); } @FunctionalInterface diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java b/spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java new file mode 100644 index 0000000..a5a7391 --- /dev/null +++ b/spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java @@ -0,0 +1,75 @@ +/* + * This file is part of spark. + * + * Copyright (c) lucko (Luck) <luck@lucko.me> + * Copyright (c) contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package me.lucko.spark.common.command; + +import me.lucko.spark.common.SparkPlatform; + +import java.util.Set; +import java.util.function.Consumer; + +public class CommandResponseHandler<S> { + + /** The prefix used in all messages */ + private static final String PREFIX = "&8[&fspark&8] &7"; + + private final SparkPlatform<S> platform; + private final S sender; + + public CommandResponseHandler(SparkPlatform<S> platform, S sender) { + this.platform = platform; + this.sender = sender; + } + + public S sender() { + return this.sender; + } + + public void allSenders(Consumer<? super S> action) { + Set<S> senders = this.platform.getPlugin().getSenders(); + senders.add(this.sender); + senders.forEach(action); + } + + public void reply(String message) { + this.platform.getPlugin().sendMessage(this.sender, message); + } + + public void broadcast(String message) { + allSenders(sender -> this.platform.getPlugin().sendMessage(sender, message)); + } + + public void replyPrefixed(String message) { + this.platform.getPlugin().sendMessage(this.sender, PREFIX + message); + } + + public void broadcastPrefixed(String message) { + allSenders(sender -> this.platform.getPlugin().sendMessage(sender, PREFIX + message)); + } + + public void replyLink(String link) { + this.platform.getPlugin().sendLink(this.sender, link); + } + + public void broadcastLink(String link) { + allSenders(sender -> this.platform.getPlugin().sendLink(sender, link)); + } + +} diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java index 5f17d54..2cb2e07 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java @@ -24,9 +24,8 @@ import me.lucko.spark.common.SparkPlatform; import me.lucko.spark.common.command.Command; import me.lucko.spark.common.command.CommandModule; import me.lucko.spark.common.command.tabcomplete.TabCompleter; -import me.lucko.spark.memory.HeapDump; -import me.lucko.spark.memory.HeapDumpSummary; - +import me.lucko.spark.common.memory.HeapDump; +import me.lucko.spark.common.memory.HeapDumpSummary; import okhttp3.MediaType; import java.io.IOException; @@ -44,34 +43,34 @@ public class MemoryModule<S> implements CommandModule<S> { consumer.accept(Command.<S>builder() .aliases("heapsummary") .argumentUsage("run-gc-before", null) - .executor((platform, sender, arguments) -> { - platform.runAsync(() -> { - if (arguments.boolFlag("run-gc-before")) { - platform.sendPrefixedMessage("&7Running garbage collector..."); - System.gc(); - } - - platform.sendPrefixedMessage("&7Creating a new heap dump summary, please wait..."); - - HeapDumpSummary heapDump; - try { - heapDump = HeapDumpSummary.createNew(); - } catch (Exception e) { - platform.sendPrefixedMessage("&cAn error occurred whilst inspecting the heap."); - e.printStackTrace(); - return; - } - - byte[] output = heapDump.formCompressedDataPayload(); - try { - String key = SparkPlatform.BYTEBIN_CLIENT.postGzippedContent(output, JSON_TYPE); - platform.sendPrefixedMessage("&bHeap dump summmary output:"); - platform.sendLink(SparkPlatform.VIEWER_URL + key); - } catch (IOException e) { - platform.sendPrefixedMessage("&cAn error occurred whilst uploading the data."); - e.printStackTrace(); - } - }); + .executor((platform, sender, resp, arguments) -> { + platform.getPlugin().runAsync(() -> { + if (arguments.boolFlag("run-gc-before")) { + resp.broadcastPrefixed("&7Running garbage collector..."); + System.gc(); + } + + resp.broadcastPrefixed("&7Creating a new heap dump summary, please wait..."); + + HeapDumpSummary heapDump; + try { + heapDump = HeapDumpSummary.createNew(); + } catch (Exception e) { + resp.broadcastPrefixed("&cAn error occurred whilst inspecting the heap."); + e.printStackTrace(); + return; + } + + byte[] output = heapDump.formCompressedDataPayload(); + try { + String key = SparkPlatform.BYTEBIN_CLIENT.postContent(output, JSON_TYPE, false).key(); + resp.broadcastPrefixed("&bHeap dump summmary output:"); + resp.broadcastLink(SparkPlatform.VIEWER_URL + key); + } catch (IOException e) { + resp.broadcastPrefixed("&cAn error occurred whilst uploading the data."); + e.printStackTrace(); + } + }); }) .tabCompleter((platform, sender, arguments) -> TabCompleter.completeForOpts(arguments, "--run-gc-before")) .build() @@ -81,35 +80,36 @@ public class MemoryModule<S> implements CommandModule<S> { .aliases("heapdump") .argumentUsage("run-gc-before", null) .argumentUsage("include-non-live", null) - .executor((platform, sender, arguments) -> { - platform.runAsync(() -> { - Path pluginFolder = platform.getPluginFolder(); - try { - Files.createDirectories(pluginFolder); - } catch (IOException e) { - // ignore - } - - Path file = pluginFolder.resolve("heap-" + DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss").format(LocalDateTime.now()) + (HeapDump.isOpenJ9() ? ".phd" : ".hprof")); - boolean liveOnly = !arguments.boolFlag("include-non-live"); - - if (arguments.boolFlag("run-gc-before")) { - platform.sendPrefixedMessage("&7Running garbage collector..."); - System.gc(); - } - - platform.sendPrefixedMessage("&7Creating a new heap dump, please wait..."); - - try { - HeapDump.dumpHeap(file, liveOnly); - } catch (Exception e) { - platform.sendPrefixedMessage("&cAn error occurred whilst creating a heap dump."); - e.printStackTrace(); - return; - } - - platform.sendPrefixedMessage("&bHeap dump written to: " + file.toString()); - }); + .executor((platform, sender, resp, arguments) -> { + // ignore + platform.getPlugin().runAsync(() -> { + Path pluginFolder = platform.getPlugin().getPluginFolder(); + try { + Files.createDirectories(pluginFolder); + } catch (IOException e) { + // ignore + } + + Path file = pluginFolder.resolve("heap-" + DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss").format(LocalDateTime.now()) + (HeapDump.isOpenJ9() ? ".phd" : ".hprof")); + boolean liveOnly = !arguments.boolFlag("include-non-live"); + + if (arguments.boolFlag("run-gc-before")) { + resp.broadcastPrefixed("&7Running garbage collector..."); + System.gc(); + } + + resp.broadcastPrefixed("&7Creating a new heap dump, please wait..."); + + try { + HeapDump.dumpHeap(file, liveOnly); + } catch (Exception e) { + resp.broadcastPrefixed("&cAn error occurred whilst creating a heap dump."); + e.printStackTrace(); + return; + } + + resp.broadcastPrefixed("&bHeap dump written to: " + file.toString()); + }); }) .tabCompleter((platform, sender, arguments) -> TabCompleter.completeForOpts(arguments, "--run-gc-before", "--include-non-live")) .build() diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java new file mode 100644 index 0000000..b543e1d --- /dev/null +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java @@ -0,0 +1,51 @@ +/* + * This file is part of spark. + * + * Copyright (c) lucko (Luck) <luck@lucko.me> + * Copyright (c) contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package me.lucko.spark.common.command.modules; + +import me.lucko.spark.common.command.Command; +import me.lucko.spark.common.command.CommandModule; +import me.lucko.spark.common.monitor.tick.TpsCalculator; + +import java.util.function.Consumer; + +public class MonitoringModule<S> implements CommandModule<S> { + + @Override + public void registerCommands(Consumer<Command<S>> consumer) { + consumer.accept(Command.<S>builder() + .aliases("tps") + .executor((platform, sender, resp, arguments) -> { + TpsCalculator tpsCalculator = platform.getTpsCalculator(); + if (tpsCalculator == null) { + resp.replyPrefixed("TPS data is not available."); + return; + } + + String formattedTpsString = tpsCalculator.toFormattedString(); + resp.replyPrefixed("TPS from last 5s, 10s, 1m, 5m, 15m"); + resp.replyPrefixed(formattedTpsString); + }) + .tabCompleter(Command.TabCompleter.empty()) + .build() + ); + } + +} diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java index 9d00a96..a0f171c 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java @@ -23,14 +23,14 @@ package me.lucko.spark.common.command.modules; import me.lucko.spark.common.SparkPlatform; import me.lucko.spark.common.command.Command; import me.lucko.spark.common.command.CommandModule; +import me.lucko.spark.common.command.CommandResponseHandler; import me.lucko.spark.common.command.tabcomplete.CompletionSupplier; import me.lucko.spark.common.command.tabcomplete.TabCompleter; -import me.lucko.spark.sampler.Sampler; -import me.lucko.spark.sampler.SamplerBuilder; -import me.lucko.spark.sampler.ThreadDumper; -import me.lucko.spark.sampler.ThreadGrouper; -import me.lucko.spark.sampler.TickCounter; - +import me.lucko.spark.common.sampler.Sampler; +import me.lucko.spark.common.sampler.SamplerBuilder; +import me.lucko.spark.common.sampler.ThreadDumper; +import me.lucko.spark.common.sampler.ThreadGrouper; +import me.lucko.spark.common.sampler.TickCounter; import okhttp3.MediaType; import java.io.IOException; @@ -62,15 +62,15 @@ public class SamplerModule<S> implements CommandModule<S> { .argumentUsage("interval", "interval millis") .argumentUsage("only-ticks-over", "tick length millis") .argumentUsage("include-line-numbers", null) - .executor((platform, sender, arguments) -> { + .executor((platform, sender, resp, arguments) -> { int timeoutSeconds = arguments.intFlag("timeout"); if (timeoutSeconds != -1 && timeoutSeconds <= 10) { - platform.sendPrefixedMessage(sender, "&cThe specified timeout is not long enough for accurate results to be formed. Please choose a value greater than 10."); + resp.replyPrefixed("&cThe specified timeout is not long enough for accurate results to be formed. Please choose a value greater than 10."); return; } if (timeoutSeconds != -1 && timeoutSeconds < 30) { - platform.sendPrefixedMessage(sender, "&7The accuracy of the output will significantly improve when sampling is able to run for longer periods. Consider setting a timeout value over 30 seconds."); + resp.replyPrefixed("&7The accuracy of the output will significantly improve when sampling is able to run for longer periods. Consider setting a timeout value over 30 seconds."); } double intervalMillis = arguments.doubleFlag("interval"); @@ -84,7 +84,7 @@ public class SamplerModule<S> implements CommandModule<S> { ThreadDumper threadDumper; if (threads.isEmpty()) { // use the server thread - threadDumper = platform.getDefaultThreadDumper(); + threadDumper = platform.getPlugin().getDefaultThreadDumper(); } else if (threads.contains("*")) { threadDumper = ThreadDumper.ALL; } else { @@ -108,10 +108,9 @@ public class SamplerModule<S> implements CommandModule<S> { int ticksOver = arguments.intFlag("only-ticks-over"); TickCounter tickCounter = null; if (ticksOver != -1) { - try { - tickCounter = platform.newTickCounter(); - } catch (UnsupportedOperationException e) { - platform.sendPrefixedMessage(sender, "&cTick counting is not supported!"); + tickCounter = platform.getTickCounter(); + if (tickCounter == null) { + resp.replyPrefixed("&cTick counting is not supported!"); return; } } @@ -119,11 +118,11 @@ public class SamplerModule<S> implements CommandModule<S> { Sampler sampler; synchronized (this.activeSamplerMutex) { if (this.activeSampler != null) { - platform.sendPrefixedMessage(sender, "&7An active sampler is already running."); + resp.replyPrefixed("&7An active sampler is already running."); return; } - platform.sendPrefixedMessage("&7Initializing a new profiler, please wait..."); + resp.broadcastPrefixed("&7Initializing a new profiler, please wait..."); SamplerBuilder builder = new SamplerBuilder(); builder.threadDumper(threadDumper); @@ -138,11 +137,11 @@ public class SamplerModule<S> implements CommandModule<S> { } sampler = this.activeSampler = builder.start(); - platform.sendPrefixedMessage("&bProfiler now active!"); + resp.broadcastPrefixed("&bProfiler now active!"); if (timeoutSeconds == -1) { - platform.sendPrefixedMessage("&7Use '/" + platform.getLabel() + " stop' to stop profiling and upload the results."); + resp.broadcastPrefixed("&7Use '/" + platform.getPlugin().getLabel() + " stop' to stop profiling and upload the results."); } else { - platform.sendPrefixedMessage("&7The results will be automatically returned after the profiler has been running for " + timeoutSeconds + " seconds."); + resp.broadcastPrefixed("&7The results will be automatically returned after the profiler has been running for " + timeoutSeconds + " seconds."); } } @@ -151,7 +150,7 @@ public class SamplerModule<S> implements CommandModule<S> { // send message if profiling fails future.whenCompleteAsync((s, throwable) -> { if (throwable != null) { - platform.sendPrefixedMessage("&cSampling operation failed unexpectedly. Error: " + throwable.toString()); + resp.broadcastPrefixed("&cSampling operation failed unexpectedly. Error: " + throwable.toString()); throwable.printStackTrace(); } }); @@ -168,8 +167,8 @@ public class SamplerModule<S> implements CommandModule<S> { // await the result if (timeoutSeconds != -1) { future.thenAcceptAsync(s -> { - platform.sendPrefixedMessage("&7The active sampling operation has completed! Uploading results..."); - handleUpload(platform, s); + resp.broadcastPrefixed("&7The active sampling operation has completed! Uploading results..."); + handleUpload(platform, resp, s); }); } }) @@ -188,21 +187,21 @@ public class SamplerModule<S> implements CommandModule<S> { consumer.accept(Command.<S>builder() .aliases("info") - .executor((platform, sender, arguments) -> { + .executor((platform, sender, resp, arguments) -> { synchronized (this.activeSamplerMutex) { if (this.activeSampler == null) { - platform.sendPrefixedMessage(sender, "&7There isn't an active sampling task running."); + resp.replyPrefixed("&7There isn't an active sampling task running."); } else { long timeout = this.activeSampler.getEndTime(); if (timeout == -1) { - platform.sendPrefixedMessage(sender, "&7There is an active sampler currently running, with no defined timeout."); + resp.replyPrefixed("&7There is an active sampler currently running, with no defined timeout."); } else { long timeoutDiff = (timeout - System.currentTimeMillis()) / 1000L; - platform.sendPrefixedMessage(sender, "&7There is an active sampler currently running, due to timeout in " + timeoutDiff + " seconds."); + resp.replyPrefixed("&7There is an active sampler currently running, due to timeout in " + timeoutDiff + " seconds."); } long runningTime = (System.currentTimeMillis() - this.activeSampler.getStartTime()) / 1000L; - platform.sendPrefixedMessage(sender, "&7It has been sampling for " + runningTime + " seconds so far."); + resp.replyPrefixed("&7It has been sampling for " + runningTime + " seconds so far."); } } }) @@ -211,14 +210,14 @@ public class SamplerModule<S> implements CommandModule<S> { consumer.accept(Command.<S>builder() .aliases("stop", "upload", "paste") - .executor((platform, sender, arguments) -> { + .executor((platform, sender, resp, arguments) -> { synchronized (this.activeSamplerMutex) { if (this.activeSampler == null) { - platform.sendPrefixedMessage(sender, "&7There isn't an active sampling task running."); + resp.replyPrefixed("&7There isn't an active sampling task running."); } else { this.activeSampler.cancel(); - platform.sendPrefixedMessage("&7The active sampling operation has been stopped! Uploading results..."); - handleUpload(platform, this.activeSampler); + resp.broadcastPrefixed("&7The active sampling operation has been stopped! Uploading results..."); + handleUpload(platform, resp, this.activeSampler); this.activeSampler = null; } } @@ -228,14 +227,14 @@ public class SamplerModule<S> implements CommandModule<S> { consumer.accept(Command.<S>builder() .aliases("cancel") - .executor((platform, sender, arguments) -> { + .executor((platform, sender, resp, arguments) -> { synchronized (this.activeSamplerMutex) { if (this.activeSampler == null) { - platform.sendPrefixedMessage(sender, "&7There isn't an active sampling task running."); + resp.replyPrefixed("&7There isn't an active sampling task running."); } else { this.activeSampler.cancel(); this.activeSampler = null; - platform.sendPrefixedMessage("&bThe active sampling task has been cancelled."); + resp.broadcastPrefixed("&bThe active sampling task has been cancelled."); } } }) @@ -243,15 +242,15 @@ public class SamplerModule<S> implements CommandModule<S> { ); } - private void handleUpload(SparkPlatform<S> platform, Sampler sampler) { - platform.runAsync(() -> { + private void handleUpload(SparkPlatform<S> platform, CommandResponseHandler<S> resp, Sampler sampler) { + platform.getPlugin().runAsync(() -> { byte[] output = sampler.formCompressedDataPayload(); try { - String key = SparkPlatform.BYTEBIN_CLIENT.postGzippedContent(output, JSON_TYPE); - platform.sendPrefixedMessage("&bSampling results:"); - platform.sendLink(SparkPlatform.VIEWER_URL + key); + String key = SparkPlatform.BYTEBIN_CLIENT.postContent(output, JSON_TYPE, false).key(); + resp.broadcastPrefixed("&bSampling results:"); + resp.broadcastLink(SparkPlatform.VIEWER_URL + key); } catch (IOException e) { - platform.sendPrefixedMessage("&cAn error occurred whilst uploading the results."); + resp.broadcastPrefixed("&cAn error occurred whilst uploading the results."); e.printStackTrace(); } }); diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/TickMonitoringModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/TickMonitoringModule.java index 3ad8909..bea7a07 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/TickMonitoringModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/TickMonitoringModule.java @@ -20,12 +20,12 @@ package me.lucko.spark.common.command.modules; -import me.lucko.spark.common.SparkPlatform; import me.lucko.spark.common.command.Command; import me.lucko.spark.common.command.CommandModule; +import me.lucko.spark.common.command.CommandResponseHandler; import me.lucko.spark.common.command.tabcomplete.TabCompleter; -import me.lucko.spark.monitor.TickMonitor; -import me.lucko.spark.sampler.TickCounter; +import me.lucko.spark.common.monitor.tick.TickMonitor; +import me.lucko.spark.common.sampler.TickCounter; import java.util.function.Consumer; @@ -37,27 +37,29 @@ public class TickMonitoringModule<S> implements CommandModule<S> { @Override public void registerCommands(Consumer<Command<S>> consumer) { consumer.accept(Command.<S>builder() - .aliases("monitoring") + .aliases("tickmonitoring") .argumentUsage("threshold", "percentage increase") .argumentUsage("without-gc", null) - .executor((platform, sender, arguments) -> { - if (this.activeTickMonitor == null) { + .executor((platform, sender, resp, arguments) -> { + TickCounter tickCounter = platform.getTickCounter(); + if (tickCounter == null) { + resp.replyPrefixed("&cNot supported!"); + return; + } + if (this.activeTickMonitor == null) { int threshold = arguments.intFlag("threshold"); if (threshold == -1) { threshold = 100; } - try { - TickCounter tickCounter = platform.newTickCounter(); - this.activeTickMonitor = new ReportingTickMonitor(platform, tickCounter, threshold, !arguments.boolFlag("without-gc")); - } catch (UnsupportedOperationException e) { - platform.sendPrefixedMessage(sender, "&cNot supported!"); - } + this.activeTickMonitor = new ReportingTickMonitor(resp, tickCounter, threshold, !arguments.boolFlag("without-gc")); + tickCounter.addTickTask(this.activeTickMonitor); } else { + tickCounter.removeTickTask(this.activeTickMonitor); this.activeTickMonitor.close(); this.activeTickMonitor = null; - platform.sendPrefixedMessage("&7Tick monitor disabled."); + resp.broadcastPrefixed("&7Tick monitor disabled."); } }) .tabCompleter((platform, sender, arguments) -> TabCompleter.completeForOpts(arguments, "--threshold", "--without-gc")) @@ -66,16 +68,16 @@ public class TickMonitoringModule<S> implements CommandModule<S> { } private class ReportingTickMonitor extends TickMonitor { - private final SparkPlatform<S> platform; + private final CommandResponseHandler<S> resp; - ReportingTickMonitor(SparkPlatform<S> platform, TickCounter tickCounter, int percentageChangeThreshold, boolean monitorGc) { + ReportingTickMonitor(CommandResponseHandler<S> resp, TickCounter tickCounter, int percentageChangeThreshold, boolean monitorGc) { super(tickCounter, percentageChangeThreshold, monitorGc); - this.platform = platform; + this.resp = resp; } @Override protected void sendMessage(String message) { - this.platform.sendPrefixedMessage(message); + this.resp.broadcastPrefixed(message); } } } |