aboutsummaryrefslogtreecommitdiff
path: root/spark-common
diff options
context:
space:
mode:
Diffstat (limited to 'spark-common')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java1
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/activitylog/ActivityLog.java (renamed from spark-common/src/main/java/me/lucko/spark/common/ActivityLog.java)5
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/Command.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/ActivityLogModule.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/modules/TickMonitoringModule.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/sender/AbstractCommandSender.java42
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/command/sender/CommandSender.java (renamed from spark-common/src/main/java/me/lucko/spark/common/CommandSender.java)2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java9
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/monitor/cpu/CpuMonitor.java8
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/Sampler.java2
14 files changed, 66 insertions, 17 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 db5cb84..dc88306 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
@@ -21,6 +21,7 @@
package me.lucko.spark.common;
import com.google.common.collect.ImmutableList;
+import me.lucko.spark.common.activitylog.ActivityLog;
import me.lucko.spark.common.command.Arguments;
import me.lucko.spark.common.command.Command;
import me.lucko.spark.common.command.CommandModule;
@@ -30,6 +31,7 @@ import me.lucko.spark.common.command.modules.HealthModule;
import me.lucko.spark.common.command.modules.MemoryModule;
import me.lucko.spark.common.command.modules.SamplerModule;
import me.lucko.spark.common.command.modules.TickMonitoringModule;
+import me.lucko.spark.common.command.sender.CommandSender;
import me.lucko.spark.common.command.tabcomplete.CompletionSupplier;
import me.lucko.spark.common.command.tabcomplete.TabCompleter;
import me.lucko.spark.common.monitor.cpu.CpuMonitor;
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 7ccffab..1171b33 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
@@ -20,6 +20,7 @@
package me.lucko.spark.common;
+import me.lucko.spark.common.command.sender.CommandSender;
import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.sampler.TickCounter;
diff --git a/spark-common/src/main/java/me/lucko/spark/common/ActivityLog.java b/spark-common/src/main/java/me/lucko/spark/common/activitylog/ActivityLog.java
index 7327e2b..894593c 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/ActivityLog.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/activitylog/ActivityLog.java
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package me.lucko.spark.common;
+package me.lucko.spark.common.activitylog;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -27,6 +27,7 @@ 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;
@@ -175,7 +176,7 @@ public class ActivityLog {
}
public boolean shouldExpire() {
- if (dataType.equals("url")) {
+ if (this.dataType.equals("url")) {
return (System.currentTimeMillis() - this.time) > TimeUnit.DAYS.toMillis(7);
} else {
return false;
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 ab95cb6..db23454 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,8 +21,8 @@
package me.lucko.spark.common.command;
import com.google.common.collect.ImmutableList;
-import me.lucko.spark.common.CommandSender;
import me.lucko.spark.common.SparkPlatform;
+import me.lucko.spark.common.command.sender.CommandSender;
import java.util.Collections;
import java.util.List;
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 6f02180..635e785 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
@@ -20,8 +20,8 @@
package me.lucko.spark.common.command;
-import me.lucko.spark.common.CommandSender;
import me.lucko.spark.common.SparkPlatform;
+import me.lucko.spark.common.command.sender.CommandSender;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
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 e09dc9d..c78e567 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,7 +20,7 @@
package me.lucko.spark.common.command.modules;
-import me.lucko.spark.common.ActivityLog.Activity;
+import me.lucko.spark.common.activitylog.ActivityLog.Activity;
import me.lucko.spark.common.command.Command;
import me.lucko.spark.common.command.CommandModule;
import me.lucko.spark.common.command.tabcomplete.TabCompleter;
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 dcfb0c4..0516f5b 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
@@ -20,8 +20,8 @@
package me.lucko.spark.common.command.modules;
-import me.lucko.spark.common.ActivityLog.Activity;
import me.lucko.spark.common.SparkPlatform;
+import me.lucko.spark.common.activitylog.ActivityLog.Activity;
import me.lucko.spark.common.command.Command;
import me.lucko.spark.common.command.CommandModule;
import me.lucko.spark.common.command.tabcomplete.CompletionSupplier;
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 9f14e6e..f63d7ba 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
@@ -20,8 +20,8 @@
package me.lucko.spark.common.command.modules;
-import me.lucko.spark.common.ActivityLog.Activity;
import me.lucko.spark.common.SparkPlatform;
+import me.lucko.spark.common.activitylog.ActivityLog.Activity;
import me.lucko.spark.common.command.Command;
import me.lucko.spark.common.command.CommandModule;
import me.lucko.spark.common.command.CommandResponseHandler;
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 da26dea..0ebb252 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
@@ -81,7 +81,7 @@ public class TickMonitoringModule implements CommandModule {
);
}
- private class ReportingTickMonitor extends TickMonitor {
+ private static class ReportingTickMonitor extends TickMonitor {
private final CommandResponseHandler resp;
ReportingTickMonitor(SparkPlatform platform, CommandResponseHandler resp, TickCounter tickCounter, int percentageChangeThreshold, boolean monitorGc) {
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/sender/AbstractCommandSender.java b/spark-common/src/main/java/me/lucko/spark/common/command/sender/AbstractCommandSender.java
new file mode 100644
index 0000000..ce48889
--- /dev/null
+++ b/spark-common/src/main/java/me/lucko/spark/common/command/sender/AbstractCommandSender.java
@@ -0,0 +1,42 @@
+/*
+ * 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.sender;
+
+public abstract class AbstractCommandSender<S> implements CommandSender {
+ protected final S delegate;
+
+ public AbstractCommandSender(S delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ AbstractCommandSender<?> that = (AbstractCommandSender<?>) o;
+ return this.delegate.equals(that.delegate);
+ }
+
+ @Override
+ public int hashCode() {
+ return this.delegate.hashCode();
+ }
+}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/CommandSender.java b/spark-common/src/main/java/me/lucko/spark/common/command/sender/CommandSender.java
index 198bd79..ef56185 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/CommandSender.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/command/sender/CommandSender.java
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package me.lucko.spark.common;
+package me.lucko.spark.common.command.sender;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
diff --git a/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java b/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java
index 53de4e8..137a4fe 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java
@@ -20,15 +20,12 @@
package me.lucko.spark.common.heapdump;
-import me.lucko.spark.common.CommandSender;
+import me.lucko.spark.common.command.sender.CommandSender;
import me.lucko.spark.common.util.TypeDescriptors;
import me.lucko.spark.proto.SparkProtos;
import me.lucko.spark.proto.SparkProtos.HeapData;
import me.lucko.spark.proto.SparkProtos.HeapEntry;
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -41,6 +38,10 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.GZIPOutputStream;
+import javax.management.JMX;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
/**
* Represents a "heap dump summary" from the VM.
*
diff --git a/spark-common/src/main/java/me/lucko/spark/common/monitor/cpu/CpuMonitor.java b/spark-common/src/main/java/me/lucko/spark/common/monitor/cpu/CpuMonitor.java
index aa653b7..47e3fac 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/monitor/cpu/CpuMonitor.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/monitor/cpu/CpuMonitor.java
@@ -22,15 +22,16 @@ package me.lucko.spark.common.monitor.cpu;
import me.lucko.spark.common.util.RollingAverage;
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
import java.lang.management.ManagementFactory;
import java.math.BigDecimal;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import javax.management.JMX;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
/**
* Exposes and monitors the system/process CPU usage.
*/
@@ -73,6 +74,7 @@ public enum CpuMonitor {
/**
* Ensures that the static initializer has been called.
*/
+ @SuppressWarnings("EmptyMethod")
public static void ensureMonitoring() {
// intentionally empty
}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/Sampler.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/Sampler.java
index 7418776..033a2d2 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/Sampler.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/Sampler.java
@@ -22,7 +22,7 @@
package me.lucko.spark.common.sampler;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import me.lucko.spark.common.CommandSender;
+import me.lucko.spark.common.command.sender.CommandSender;
import me.lucko.spark.common.sampler.aggregator.DataAggregator;
import me.lucko.spark.common.sampler.aggregator.SimpleDataAggregator;
import me.lucko.spark.common.sampler.aggregator.TickedDataAggregator;