aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src/main/java/me/lucko/spark/monitor
diff options
context:
space:
mode:
Diffstat (limited to 'spark-common/src/main/java/me/lucko/spark/monitor')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java b/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java
index a7dd4a8..f3eb441 100644
--- a/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java
+++ b/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java
@@ -40,14 +40,14 @@ public abstract class TickMonitor implements Runnable, AutoCloseable {
private DoubleSummaryStatistics averageTickTime = new DoubleSummaryStatistics();
private double avg;
- public TickMonitor(TickCounter tickCounter, int percentageChangeThreshold) {
+ public TickMonitor(TickCounter tickCounter, int percentageChangeThreshold, boolean monitorGc) {
this.tickCounter = tickCounter;
this.percentageChangeThreshold = percentageChangeThreshold;
this.tickCounter.start();
this.tickCounter.addTickTask(this);
- this.garbageCollectionMonitor = new GarbageCollectionMonitor(this);
+ this.garbageCollectionMonitor = monitorGc ? new GarbageCollectionMonitor(this) : null;
}
protected abstract void sendMessage(String message);
@@ -55,7 +55,9 @@ public abstract class TickMonitor implements Runnable, AutoCloseable {
@Override
public void close() {
this.tickCounter.close();
- this.garbageCollectionMonitor.close();
+ if (this.garbageCollectionMonitor != null) {
+ this.garbageCollectionMonitor.close();
+ }
}
@Override