aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src/main/java/me/lucko/spark/common/sampler
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2021-03-23 00:52:44 +0000
committerLuck <git@lucko.me>2021-03-23 00:52:44 +0000
commit0fd7d30f2a9027c2bd9df3215759c6d91d110acc (patch)
treebdf02fa8b7c6dfc7dc6db5eaaabeb1e17189d420 /spark-common/src/main/java/me/lucko/spark/common/sampler
parent9766754d28fcbca1ccbeefc11ef7a88a4e3d7946 (diff)
downloadspark-0fd7d30f2a9027c2bd9df3215759c6d91d110acc.tar.gz
spark-0fd7d30f2a9027c2bd9df3215759c6d91d110acc.tar.bz2
spark-0fd7d30f2a9027c2bd9df3215759c6d91d110acc.zip
Refactor and tidy up, more consistent code style
Diffstat (limited to 'spark-common/src/main/java/me/lucko/spark/common/sampler')
-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/sampler/tick/AbstractTickHook.java53
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/tick/AbstractTickReporter.java45
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/tick/TickHook.java64
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/tick/TickReporter.java57
18 files changed, 106 insertions, 456 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/SamplerBuilder.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/SamplerBuilder.java
index 7abe1a7..7dff29e 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/SamplerBuilder.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/SamplerBuilder.java
@@ -23,7 +23,7 @@ package me.lucko.spark.common.sampler;
import me.lucko.spark.common.sampler.async.AsyncProfilerAccess;
import me.lucko.spark.common.sampler.async.AsyncSampler;
import me.lucko.spark.common.sampler.java.JavaSampler;
-import me.lucko.spark.common.sampler.tick.TickHook;
+import me.lucko.spark.common.tick.TickHook;
import java.util.concurrent.TimeUnit;
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/aggregator/DataAggregator.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/aggregator/DataAggregator.java
index a91a998..8b90639 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/aggregator/DataAggregator.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/aggregator/DataAggregator.java
@@ -23,7 +23,6 @@ package me.lucko.spark.common.sampler.aggregator;
import me.lucko.spark.common.sampler.node.ThreadNode;
import me.lucko.spark.proto.SparkProtos.SamplerMetadata;
-import java.lang.management.ThreadInfo;
import java.util.Map;
/**
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java
index a109be7..1e23124 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java
@@ -25,11 +25,7 @@ import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.common.sampler.Sampler;
import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.sampler.ThreadGrouper;
-import me.lucko.spark.common.sampler.async.jfr.ClassRef;
import me.lucko.spark.common.sampler.async.jfr.JfrReader;
-import me.lucko.spark.common.sampler.async.jfr.MethodRef;
-import me.lucko.spark.common.sampler.async.jfr.Sample;
-import me.lucko.spark.common.sampler.async.jfr.StackTrace;
import me.lucko.spark.common.sampler.node.MergeMode;
import me.lucko.spark.common.sampler.node.ThreadNode;
import me.lucko.spark.proto.SparkProtos;
@@ -206,9 +202,9 @@ public class AsyncSampler implements Sampler {
}
private void readSegments(JfrReader reader, Predicate<String> threadFilter) {
- List<Sample> samples = reader.samples;
+ List<JfrReader.Sample> samples = reader.samples;
for (int i = 0; i < samples.size(); i++) {
- Sample sample = samples.get(i);
+ JfrReader.Sample sample = samples.get(i);
long duration;
if (i == 0) {
@@ -232,8 +228,8 @@ public class AsyncSampler implements Sampler {
}
}
- private static ProfileSegment parseSegment(JfrReader reader, Sample sample, String threadName, long duration) {
- StackTrace stackTrace = reader.stackTraces.get(sample.stackTraceId);
+ private static ProfileSegment parseSegment(JfrReader reader, JfrReader.Sample sample, String threadName, long duration) {
+ JfrReader.StackTrace stackTrace = reader.stackTraces.get(sample.stackTraceId);
int len = stackTrace.methods.length;
AsyncStackTraceElement[] stack = new AsyncStackTraceElement[len];
@@ -250,8 +246,8 @@ public class AsyncSampler implements Sampler {
return result;
}
- MethodRef methodRef = reader.methods.get(methodId);
- ClassRef classRef = reader.classes.get(methodRef.cls);
+ JfrReader.MethodRef methodRef = reader.methods.get(methodId);
+ JfrReader.ClassRef classRef = reader.classes.get(methodRef.cls);
byte[] className = reader.symbols.get(classRef.name);
byte[] methodName = reader.symbols.get(methodRef.name);
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/ClassRef.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/ClassRef.java
deleted file mode 100644
index 2366fa6..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/ClassRef.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2020 Andrei Pangin
- *
- * 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
- *
- * 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.
- */
-
-package me.lucko.spark.common.sampler.async.jfr;
-
-public class ClassRef {
- public final long name;
-
- public ClassRef(long name) {
- this.name = name;
- }
-}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/Element.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/Element.java
deleted file mode 100644
index 9d6b6c7..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/Element.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2020 Andrei Pangin
- *
- * 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
- *
- * 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.
- */
-
-package me.lucko.spark.common.sampler.async.jfr;
-
-class Element {
-
- void addChild(Element e) {
- }
-}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrClass.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrClass.java
deleted file mode 100644
index a171552..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrClass.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2020 Andrei Pangin
- *
- * 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
- *
- * 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.
- */
-
-package me.lucko.spark.common.sampler.async.jfr;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-class JfrClass extends Element {
- final int id;
- final String name;
- final List<JfrField> fields;
-
- JfrClass(Map<String, String> attributes) {
- this.id = Integer.parseInt(attributes.get("id"));
- this.name = attributes.get("name");
- this.fields = new ArrayList<>(2);
- }
-
- @Override
- void addChild(Element e) {
- if (e instanceof JfrField) {
- fields.add((JfrField) e);
- }
- }
-
- JfrField field(String name) {
- for (JfrField field : fields) {
- if (field.name.equals(name)) {
- return field;
- }
- }
- return null;
- }
-}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrField.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrField.java
deleted file mode 100644
index 7a78f2c..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrField.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2020 Andrei Pangin
- *
- * 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
- *
- * 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.
- */
-
-package me.lucko.spark.common.sampler.async.jfr;
-
-import java.util.Map;
-
-class JfrField extends Element {
- final String name;
- final int type;
- final boolean constantPool;
-
- JfrField(Map<String, String> attributes) {
- this.name = attributes.get("name");
- this.type = Integer.parseInt(attributes.get("class"));
- this.constantPool = "true".equals(attributes.get("constantPool"));
- }
-}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrReader.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrReader.java
index 49a3474..95c9bad 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrReader.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/JfrReader.java
@@ -24,7 +24,6 @@ import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Collections;
@@ -386,4 +385,100 @@ public class JfrReader implements Closeable {
buf.get(bytes);
return bytes;
}
+
+ public static class ClassRef {
+ public final long name;
+
+ public ClassRef(long name) {
+ this.name = name;
+ }
+ }
+
+ static class Element {
+
+ void addChild(Element e) {
+ }
+ }
+
+ static class JfrClass extends Element {
+ final int id;
+ final String name;
+ final List<JfrField> fields;
+
+ JfrClass(Map<String, String> attributes) {
+ this.id = Integer.parseInt(attributes.get("id"));
+ this.name = attributes.get("name");
+ this.fields = new ArrayList<>(2);
+ }
+
+ @Override
+ void addChild(Element e) {
+ if (e instanceof JfrField) {
+ fields.add((JfrField) e);
+ }
+ }
+
+ JfrField field(String name) {
+ for (JfrField field : fields) {
+ if (field.name.equals(name)) {
+ return field;
+ }
+ }
+ return null;
+ }
+ }
+
+ static class JfrField extends Element {
+ final String name;
+ final int type;
+ final boolean constantPool;
+
+ JfrField(Map<String, String> attributes) {
+ this.name = attributes.get("name");
+ this.type = Integer.parseInt(attributes.get("class"));
+ this.constantPool = "true".equals(attributes.get("constantPool"));
+ }
+ }
+
+ public static class MethodRef {
+ public final long cls;
+ public final long name;
+ public final long sig;
+
+ public MethodRef(long cls, long name, long sig) {
+ this.cls = cls;
+ this.name = name;
+ this.sig = sig;
+ }
+ }
+
+ public static class Sample implements Comparable<Sample> {
+ public final long time;
+ public final int tid;
+ public final int stackTraceId;
+ public final int threadState;
+
+ public Sample(long time, int tid, int stackTraceId, int threadState) {
+ this.time = time;
+ this.tid = tid;
+ this.stackTraceId = stackTraceId;
+ this.threadState = threadState;
+ }
+
+ @Override
+ public int compareTo(Sample o) {
+ return Long.compare(time, o.time);
+ }
+ }
+
+ public static class StackTrace {
+ public final long[] methods;
+ public final byte[] types;
+ public long samples;
+
+ public StackTrace(long[] methods, byte[] types) {
+ this.methods = methods;
+ this.types = types;
+ }
+ }
}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/MethodRef.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/MethodRef.java
deleted file mode 100644
index 2f9071e..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/MethodRef.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2020 Andrei Pangin
- *
- * 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
- *
- * 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.
- */
-
-package me.lucko.spark.common.sampler.async.jfr;
-
-public class MethodRef {
- public final long cls;
- public final long name;
- public final long sig;
-
- public MethodRef(long cls, long name, long sig) {
- this.cls = cls;
- this.name = name;
- this.sig = sig;
- }
-}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/Sample.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/Sample.java
deleted file mode 100644
index 095e261..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/Sample.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2020 Andrei Pangin
- *
- * 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
- *
- * 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.
- */
-
-package me.lucko.spark.common.sampler.async.jfr;
-
-public class Sample implements Comparable<Sample> {
- public final long time;
- public final int tid;
- public final int stackTraceId;
- public final int threadState;
-
- public Sample(long time, int tid, int stackTraceId, int threadState) {
- this.time = time;
- this.tid = tid;
- this.stackTraceId = stackTraceId;
- this.threadState = threadState;
- }
-
- @Override
- public int compareTo(Sample o) {
- return Long.compare(time, o.time);
- }
-}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/StackTrace.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/StackTrace.java
deleted file mode 100644
index 4c12c5e..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/jfr/StackTrace.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2020 Andrei Pangin
- *
- * 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
- *
- * 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.
- */
-
-package me.lucko.spark.common.sampler.async.jfr;
-
-public class StackTrace {
- public final long[] methods;
- public final byte[] types;
- public long samples;
-
- public StackTrace(long[] methods, byte[] types) {
- this.methods = methods;
- this.types = types;
- }
-}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/java/JavaSampler.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/java/JavaSampler.java
index 568609e..0ee5f86 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/java/JavaSampler.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/java/JavaSampler.java
@@ -22,6 +22,7 @@
package me.lucko.spark.common.sampler.java;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
import me.lucko.spark.common.command.sender.CommandSender;
import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.common.sampler.Sampler;
@@ -29,7 +30,7 @@ import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.sampler.ThreadGrouper;
import me.lucko.spark.common.sampler.node.MergeMode;
import me.lucko.spark.common.sampler.node.ThreadNode;
-import me.lucko.spark.common.sampler.tick.TickHook;
+import me.lucko.spark.common.tick.TickHook;
import me.lucko.spark.proto.SparkProtos.SamplerData;
import me.lucko.spark.proto.SparkProtos.SamplerMetadata;
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/java/TickedDataAggregator.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/java/TickedDataAggregator.java
index 1a0bcdd..018a3b8 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/java/TickedDataAggregator.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/java/TickedDataAggregator.java
@@ -23,7 +23,7 @@ package me.lucko.spark.common.sampler.java;
import me.lucko.spark.common.sampler.ThreadGrouper;
import me.lucko.spark.common.sampler.aggregator.DataAggregator;
import me.lucko.spark.common.sampler.node.ThreadNode;
-import me.lucko.spark.common.sampler.tick.TickHook;
+import me.lucko.spark.common.tick.TickHook;
import me.lucko.spark.proto.SparkProtos.SamplerMetadata;
import java.lang.management.ThreadInfo;
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/node/StackTraceNode.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/node/StackTraceNode.java
index bd731c1..4179464 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/node/StackTraceNode.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/node/StackTraceNode.java
@@ -24,7 +24,6 @@ package me.lucko.spark.common.sampler.node;
import me.lucko.spark.common.util.MethodDisambiguator;
import me.lucko.spark.proto.SparkProtos;
-import java.util.Comparator;
import java.util.Objects;
/**
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/AbstractTickHook.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/AbstractTickHook.java
deleted file mode 100644
index 72e927f..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/AbstractTickHook.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.sampler.tick;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public abstract class AbstractTickHook implements TickHook {
-
- private final Set<Callback> tasks = new HashSet<>();
- private int tick = 0;
-
- protected void onTick() {
- for (Callback r : this.tasks) {
- r.onTick(this.tick);
- }
- this.tick++;
- }
-
- @Override
- public int getCurrentTick() {
- return this.tick;
- }
-
- @Override
- public void addCallback(Callback runnable) {
- this.tasks.add(runnable);
- }
-
- @Override
- public void removeCallback(Callback runnable) {
- this.tasks.remove(runnable);
- }
-
-}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/AbstractTickReporter.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/AbstractTickReporter.java
deleted file mode 100644
index 4005f87..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/AbstractTickReporter.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.sampler.tick;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public abstract class AbstractTickReporter implements TickReporter {
- private final Set<Callback> tasks = new HashSet<>();
-
- protected void onTick(double duration) {
- for (Callback r : this.tasks) {
- r.onTick(duration);
- }
- }
-
- @Override
- public void addCallback(Callback runnable) {
- this.tasks.add(runnable);
- }
-
- @Override
- public void removeCallback(Callback runnable) {
- this.tasks.remove(runnable);
- }
-
-}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/TickHook.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/TickHook.java
deleted file mode 100644
index 8731216..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/TickHook.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.sampler.tick;
-
-/**
- * A hook with the game's "tick loop".
- */
-public interface TickHook extends AutoCloseable {
-
- /**
- * Starts the hook
- */
- void start();
-
- /**
- * Stops the hook
- */
- @Override
- void close();
-
- /**
- * Gets the current tick number
- *
- * @return the current tick
- */
- int getCurrentTick();
-
- /**
- * Adds a callback to be called each time the tick increments
- *
- * @param runnable the task
- */
- void addCallback(Callback runnable);
-
- /**
- * Removes a callback
- *
- * @param runnable the callback
- */
- void removeCallback(Callback runnable);
-
- interface Callback {
- void onTick(int currentTick);
- }
-
-}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/TickReporter.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/TickReporter.java
deleted file mode 100644
index e922e72..0000000
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/tick/TickReporter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.sampler.tick;
-
-/**
- * A reporting callback for the game's "tick loop".
- */
-public interface TickReporter extends AutoCloseable {
-
- /**
- * Starts the reporter
- */
- void start();
-
- /**
- * Stops the reporter
- */
- @Override
- void close();
-
- /**
- * Adds a callback to be called each time the tick increments
- *
- * @param runnable the callback
- */
- void addCallback(Callback runnable);
-
- /**
- * Removes a callback
- *
- * @param runnable callback
- */
- void removeCallback(Callback runnable);
-
- interface Callback {
- void onTick(double duration);
- }
-
-}