diff options
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/common/sampler/java/JavaSampler.java | 2 | ||||
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/common/sampler/node/AbstractNode.java | 3 |
2 files changed, 2 insertions, 3 deletions
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 95c3508..42a457d 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 @@ -144,7 +144,7 @@ public class JavaSampler extends AbstractSampler implements Runnable { } // if we have just stepped over into a new window... - int previousWindow = JavaSampler.this.lastWindow.getAndSet(this.window); + int previousWindow = JavaSampler.this.lastWindow.getAndUpdate(previous -> Math.max(this.window, previous)); if (previousWindow != 0 && previousWindow != this.window) { // collect statistics for the previous window diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/node/AbstractNode.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/node/AbstractNode.java index 2e4b055..163365c 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/sampler/node/AbstractNode.java +++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/node/AbstractNode.java @@ -25,7 +25,6 @@ import me.lucko.spark.common.sampler.window.ProtoTimeEncoder; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -46,7 +45,7 @@ public abstract class AbstractNode { /** The accumulated sample time for this node, measured in microseconds */ // Integer key = the window (effectively System.currentTimeMillis() / 60_000) // LongAdder value = accumulated time in microseconds - private final Map<Integer, LongAdder> times = new HashMap<>(); + private final Map<Integer, LongAdder> times = new ConcurrentHashMap<>(); /** * Gets the time accumulator for a given window |