aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'spark-common/src')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java19
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java4
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/activitylog/Activity.java111
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/activitylog/ActivityLog.java86
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/Arguments.java14
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/Command.java1
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java10
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/ActivityLogModule.java16
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/GcMonitoringModule.java36
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java510
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapAnalysisModule.java292
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java365
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/TickMonitoringModule.java21
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/sender/CommandSender.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDump.java24
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java1
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/monitor/memory/GarbageCollectionMonitor.java43
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/monitor/memory/GarbageCollectorStatistics.java14
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/monitor/tick/ReportPredicate.java90
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickMonitor.java236
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickStatistics.java4
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/SamplerBuilder.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/aggregator/DataAggregator.java1
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java16
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/ClassRef.java25
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/Element.java23
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrClass.java49
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrField.java31
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrReader.java97
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/MethodRef.java29
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/Sample.java36
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/StackTrace.java28
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/java/JavaSampler.java3
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/java/TickedDataAggregator.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/node/StackTraceNode.java1
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickHook.java (renamed from spark-common/src/main/java/me/lucko/spark/common/sampler/tick/AbstractTickHook.java)2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/tick/AbstractTickReporter.java (renamed from spark-common/src/main/java/me/lucko/spark/common/sampler/tick/AbstractTickReporter.java)2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/tick/TickHook.java (renamed from spark-common/src/main/java/me/lucko/spark/common/sampler/tick/TickHook.java)2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/tick/TickReporter.java (renamed from spark-common/src/main/java/me/lucko/spark/common/sampler/tick/TickReporter.java)2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/AbstractHttpClient.java1
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java59
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/MethodDisambiguator.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/RollingAverage.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/ThreadFinder.java3
44 files changed, 1171 insertions, 1146 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
index 0cc2144..a5dadba 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java
@@ -22,6 +22,7 @@ package me.lucko.spark.common;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+
import me.lucko.spark.common.activitylog.ActivityLog;
import me.lucko.spark.common.command.Arguments;
import me.lucko.spark.common.command.Command;
@@ -39,10 +40,12 @@ import me.lucko.spark.common.command.tabcomplete.TabCompleter;
import me.lucko.spark.common.monitor.cpu.CpuMonitor;
import me.lucko.spark.common.monitor.memory.GarbageCollectorStatistics;
import me.lucko.spark.common.monitor.tick.TickStatistics;
-import me.lucko.spark.common.sampler.tick.TickHook;
-import me.lucko.spark.common.sampler.tick.TickReporter;
+import me.lucko.spark.common.tick.TickHook;
+import me.lucko.spark.common.tick.TickReporter;
import me.lucko.spark.common.util.BytebinClient;
+
import net.kyori.adventure.text.event.ClickEvent;
+
import okhttp3.OkHttpClient;
import java.util.ArrayList;
@@ -52,9 +55,15 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-import static net.kyori.adventure.text.Component.*;
-import static net.kyori.adventure.text.format.NamedTextColor.*;
-import static net.kyori.adventure.text.format.TextDecoration.*;
+import static net.kyori.adventure.text.Component.space;
+import static net.kyori.adventure.text.Component.text;
+import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY;
+import static net.kyori.adventure.text.format.NamedTextColor.GOLD;
+import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
+import static net.kyori.adventure.text.format.NamedTextColor.RED;
+import static net.kyori.adventure.text.format.NamedTextColor.WHITE;
+import static net.kyori.adventure.text.format.TextDecoration.BOLD;
+import static net.kyori.adventure.text.format.TextDecoration.UNDERLINED;
/**
* Abstract spark implementation used by all platforms.
diff --git a/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java b/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java
index 8d18b54..171367e 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java
@@ -23,8 +23,8 @@ package me.lucko.spark.common;
import me.lucko.spark.common.command.sender.CommandSender;
import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.common.sampler.ThreadDumper;
-import me.lucko.spark.common.sampler.tick.TickHook;
-import me.lucko.spark.common.sampler.tick.TickReporter;
+import me.lucko.spark.common.tick.TickHook;
+import me.lucko.spark.common.tick.TickReporter;
import java.nio.file.Path;
import java.util.stream.Stream;
diff --git a/spark-common/src/main/java/me/lucko/spark/common/activitylog/Activity.java b/spark-common/src/main/java/me/lucko/spark/common/activitylog/Activity.java
new file mode 100644
index 0000000..561515a
--- /dev/null
+++ b/spark-common/src/main/java/me/lucko/spark/common/activitylog/Activity.java
@@ -0,0 +1,111 @@
+/*
+ * 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.activitylog;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+import me.lucko.spark.common.command.sender.CommandSender;
+
+import java.util.concurrent.TimeUnit;
+
+public final class Activity {
+ private final CommandSender.Data user;
+ private final long time;
+ private final String type;
+
+ private final String dataType;
+ private final String dataValue;
+
+ public static Activity urlActivity(CommandSender user, long time, String type, String url) {
+ return new Activity(user.toData(), time, type, "url", url);
+ }
+
+ public static Activity fileActivity(CommandSender user, long time, String type, String filePath) {
+ return new Activity(user.toData(), time, type, "file", filePath);
+ }
+
+ private Activity(CommandSender.Data user, long time, String type, String dataType, String dataValue) {
+ this.user = user;
+ this.time = time;
+ this.type = type;
+ this.dataType = dataType;
+ this.dataValue = dataValue;
+ }
+
+ public CommandSender.Data getUser() {
+ return this.user;
+ }
+
+ public long getTime() {
+ return this.time;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public String getDataType() {
+ return this.dataType;
+ }
+
+ public String getDataValue() {
+ return this.dataValue;
+ }
+
+ public boolean shouldExpire() {
+ if (this.dataType.equals("url")) {
+ return (System.currentTimeMillis() - this.time) > TimeUnit.DAYS.toMillis(60);
+ } else {
+ return false;
+ }
+ }
+
+ public JsonObject serialize() {
+ JsonObject object = new JsonObject();
+
+ object.add("user", this.user.serialize());
+ object.add("time", new JsonPrimitive(this.time));
+ object.add("type", new JsonPrimitive(this.type));
+
+ JsonObject data = new JsonObject();
+ data.add("type", new JsonPrimitive(this.dataType));
+ data.add("value", new JsonPrimitive(this.dataValue));
+ object.add("data", data);
+
+ return object;
+ }
+
+ public static Activity deserialize(JsonElement element) {
+ JsonObject object = element.getAsJsonObject();
+
+ CommandSender.Data user = CommandSender.Data.deserialize(object.get("user"));
+ long time = object.get("time").getAsJsonPrimitive().getAsLong();
+ String type = object.get("type").getAsJsonPrimitive().getAsString();
+
+ JsonObject dataObject = object.get("data").getAsJsonObject();
+ String dataType = dataObject.get("type").getAsJsonPrimitive().getAsString();
+ String dataValue = dataObject.get("value").getAsJsonPrimitive().getAsString();
+
+ return new Activity(user, time, type, dataType, dataValue);
+ }
+}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/activitylog/ActivityLog.java b/spark-common/src/main/java/me/lucko/spark/common/activitylog/ActivityLog.java
index b344ded..2693962 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/activitylog/ActivityLog.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/activitylog/ActivityLog.java
@@ -24,10 +24,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import com.google.gson.JsonPrimitive;
-import me.lucko.spark.common.command.sender.CommandSender;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -37,7 +34,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.LinkedList;
import java.util.List;
-import java.util.concurrent.TimeUnit;
public class ActivityLog {
@@ -132,86 +128,4 @@ public class ActivityLog {
}
}
- public static final class Activity {
- private final CommandSender.Data user;
- private final long time;
- private final String type;
-
- private final String dataType;
- private final String dataValue;
-
- public static Activity urlActivity(CommandSender user, long time, String type, String url) {
- return new Activity(user.toData(), time, type, "url", url);
- }
-
- public static Activity fileActivity(CommandSender user, long time, String type, String filePath) {
- return new Activity(user.toData(), time, type, "file", filePath);
- }
-
- private Activity(CommandSender.Data user, long time, String type, String dataType, String dataValue) {
- this.user = user;
- this.time = time;
- this.type = type;
- this.dataType = dataType;
- this.dataValue = dataValue;
- }
-
- public CommandSender.Data getUser() {
- return this.user;
- }
-
- public long getTime() {
- return this.time;
- }
-
- public String getType() {
- return this.type;
- }
-
- public String getDataType() {
- return this.dataType;
- }
-
- public String getDataValue() {
- return this.dataValue;
- }
-
- public boolean shouldExpire() {
- if (this.dataType.equals("url")) {
- return (System.currentTimeMillis() - this.time) > TimeUnit.DAYS.toMillis(60);
- } else {
- return false;
- }
- }
-
- public JsonObject serialize() {
- JsonObject object = new JsonObject();
-
- object.add("user", this.user.serialize());
- object.add("time", new JsonPrimitive(this.time));
- object.add("type", new JsonPrimitive(this.type));
-
- JsonObject data = new JsonObject();
- data.add("type", new JsonPrimitive(this.dataType));
- data.add("value", new JsonPrimitive(this.dataValue));
- object.add("data", data);
-
- return object;
- }
-
- public static Activity deserialize(JsonElement element) {
- JsonObject object = element.getAsJsonObject();
-
- CommandSender.Data user = CommandSender.Data.deserialize(object.get("user"));
- long time = object.get("time").getAsJsonPrimitive().getAsLong();
- String type = object.get("type").getAsJsonPrimitive().getAsString();
-
- JsonObject dataObject = object.get("data").getAsJsonObject();
- String dataType = dataObject.get("type").getAsJsonPrimitive().getAsString();
- String dataValue = dataObject.get("value").getAsJsonPrimitive().getAsString();
-
- return new Activity(user, time, type, dataType, dataValue);
- }
- }
-
}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/Arguments.java b/spark-common/src/main/java/me/lucko/spark/common/command/Arguments.java
index 3cd0365..17c49e2 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/command/Arguments.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/command/Arguments.java
@@ -30,6 +30,9 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * Utility for parsing command-flag like arguments from raw space split strings.
+ */
public class Arguments {
private static final Pattern FLAG_REGEX = Pattern.compile("^--(.+)$");
@@ -110,19 +113,8 @@ public class Arguments {
}
public static final class ParseException extends IllegalArgumentException {
- public ParseException() {
- }
-
public ParseException(String s) {
super(s);
}
-
- public ParseException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ParseException(Throwable cause) {
- super(cause);
- }
}
}
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 e1a5146..dad15e6 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,6 +21,7 @@
package me.lucko.spark.common.command;
import com.google.common.collect.ImmutableList;
+
import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.common.command.sender.CommandSender;
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
index 874939e..1acb3dc 100644
--- 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
@@ -22,6 +22,7 @@ package me.lucko.spark.common.command;
import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.common.command.sender.CommandSender;
+
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
@@ -29,9 +30,11 @@ import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;
-import static net.kyori.adventure.text.Component.*;
-import static net.kyori.adventure.text.format.NamedTextColor.*;
-import static net.kyori.adventure.text.format.TextDecoration.*;
+import static net.kyori.adventure.text.Component.text;
+import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY;
+import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
+import static net.kyori.adventure.text.format.NamedTextColor.YELLOW;
+import static net.kyori.adventure.text.format.TextDecoration.BOLD;
public class CommandResponseHandler {
@@ -94,5 +97,4 @@ public class CommandResponseHandler {
return PREFIX.append(message);
}
-
}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/ActivityLogModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/ActivityLogModule.java
index ae4613a..2bdb5d6 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/ActivityLogModule.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/ActivityLogModule.java
@@ -20,10 +20,11 @@
package me.lucko.spark.common.command.modules;
-import me.lucko.spark.common.activitylog.ActivityLog.Activity;
+import me.lucko.spark.common.activitylog.Activity;
import me.lucko.spark.common.command.Command;
import me.lucko.spark.common.command.CommandModule;
import me.lucko.spark.common.command.tabcomplete.TabCompleter;
+
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
@@ -36,10 +37,15 @@ import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
-import static me.lucko.spark.common.command.CommandResponseHandler.*;
-import static net.kyori.adventure.text.Component.*;
-import static net.kyori.adventure.text.format.NamedTextColor.*;
-import static net.kyori.adventure.text.format.TextDecoration.*;
+import static me.lucko.spark.common.command.CommandResponseHandler.applyPrefix;
+import static net.kyori.adventure.text.Component.space;
+import static net.kyori.adventure.text.Component.text;
+import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY;
+import static net.kyori.adventure.text.format.NamedTextColor.GOLD;
+import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
+import static net.kyori.adventure.text.format.NamedTextColor.WHITE;
+import static net.kyori.adventure.text.format.NamedTextColor.YELLOW;
+import static net.kyori.adventure.text.format.TextDecoration.BOLD;
public class ActivityLogModule implements CommandModule, RowRenderer<Activity> {
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/GcMonitoringModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/GcMonitoringModule.java
index d66a181..8e2d199 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/GcMonitoringModule.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/GcMonitoringModule.java
@@ -21,6 +21,7 @@
package me.lucko.spark.common.command.modules;
import com.sun.management.GarbageCollectionNotificationInfo;
+
import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.common.command.Command;
import me.lucko.spark.common.command.CommandModule;
@@ -28,6 +29,7 @@ import me.lucko.spark.common.command.CommandResponseHandler;
import me.lucko.spark.common.monitor.memory.GarbageCollectionMonitor;
import me.lucko.spark.common.monitor.memory.GarbageCollectorStatistics;
import me.lucko.spark.common.util.FormatUtil;
+
import net.kyori.adventure.text.Component;
import java.lang.management.MemoryUsage;
@@ -37,12 +39,18 @@ import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
-import static net.kyori.adventure.text.Component.*;
-import static net.kyori.adventure.text.format.NamedTextColor.*;
-import static net.kyori.adventure.text.format.TextDecoration.*;
+import static net.kyori.adventure.text.Component.empty;
+import static net.kyori.adventure.text.Component.space;
+import static net.kyori.adventure.text.Component.text;
+import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY;
+import static net.kyori.adventure.text.format.NamedTextColor.GOLD;
+import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
+import static net.kyori.adventure.text.format.NamedTextColor.RED;
+import static net.kyori.adventure.text.format.NamedTextColor.WHITE;
+import static net.kyori.adventure.text.format.TextDecoration.BOLD;
public class GcMonitoringModule implements CommandModule {
- private static final DecimalFormat df = new DecimalFormat("#.##");
+ private static final DecimalFormat DF = new DecimalFormat("#.##");
/** The gc monitoring instance currently running, if any */
private ReportingGcMonitor activeGcMonitor = null;
@@ -106,7 +114,7 @@ public class GcMonitoringModule implements CommandModule {
);
report.add(text()
.content(" ")
- .append(text(df.format(averageCollectionTime), GOLD))
+ .append(text(DF.format(averageCollectionTime), GOLD))
.append(text(" ms avg", GRAY))
.append(text(", ", DARK_GRAY))
.append(text(collectionCount, WHITE))
@@ -147,11 +155,10 @@ public class GcMonitoringModule implements CommandModule {
private static String formatTime(long millis) {
if (millis <= 0) {
- return "0ms";
+ return "0s";
}
long second = millis / 1000;
- //millis = millis % 1000;
long minute = second / 60;
second = second % 60;
@@ -162,9 +169,6 @@ public class GcMonitoringModule implements CommandModule {
if (second != 0) {
sb.append(second).append("s ");
}
- //if (millis != 0) {
- // sb.append(millis).append("ms");
- //}
return sb.toString().trim();
}
@@ -185,15 +189,7 @@ public class GcMonitoringModule implements CommandModule {
@Override
public void onGc(GarbageCollectionNotificationInfo data) {
- String gcType;
- if (data.getGcAction().equals("end of minor GC")) {
- gcType = "Young Gen";
- } else if (data.getGcAction().equals("end of major GC")) {
- gcType = "Old Gen";
- } else {
- gcType = data.getGcAction();
- }
-
+ String gcType = GarbageCollectionMonitor.getGcType(data);
String gcCause = data.getGcCause() != null ? " (cause = " + data.getGcCause() + ")" : "";
Map<String, MemoryUsage> beforeUsages = data.getGcInfo().getMemoryUsageBeforeGc();
@@ -207,7 +203,7 @@ public class GcMonitoringModule implements CommandModule {
.append(text(gcType + " "))
.append(text("GC", RED))
.append(text(" lasting "))
- .append(text(df.format(data.getGcInfo().getDuration()), GOLD))
+ .append(text(DF.format(data.getGcInfo().getDuration()), GOLD))
.append(text(" ms." + gcCause))
.build()
));
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java
index 409eb38..c8f25c7 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java
@@ -21,13 +21,19 @@
package me.lucko.spark.common.command.modules;
import com.google.common.base.Strings;
+
+import me.lucko.spark.common.SparkPlatform;
+import me.lucko.spark.common.command.Arguments;
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.sender.CommandSender;
import me.lucko.spark.common.command.tabcomplete.TabCompleter;
import me.lucko.spark.common.monitor.cpu.CpuMonitor;
import me.lucko.spark.common.monitor.tick.TickStatistics;
import me.lucko.spark.common.util.FormatUtil;
import me.lucko.spark.common.util.RollingAverage;
+
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.TextColor;