|
21 | 21 | import java.util.Collections; |
22 | 22 | import java.util.List; |
23 | 23 | import java.util.Optional; |
| 24 | +import java.util.concurrent.atomic.AtomicBoolean; |
24 | 25 | import org.apache.ignite.DataRegionMetrics; |
25 | 26 | import org.apache.ignite.DataRegionMetricsProvider; |
26 | 27 | import org.apache.ignite.configuration.DataRegionConfiguration; |
|
30 | 31 | import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetricsImpl; |
31 | 32 | import org.apache.ignite.internal.processors.metric.MetricRegistryImpl; |
32 | 33 | import org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric; |
33 | | -import org.apache.ignite.internal.processors.metric.impl.BooleanMetricImpl; |
34 | 34 | import org.apache.ignite.internal.processors.metric.impl.HitRateMetric; |
35 | 35 | import org.apache.ignite.internal.processors.metric.impl.LongAdderMetric; |
36 | 36 | import org.apache.ignite.internal.processors.metric.impl.LongAdderWithDelegateMetric; |
@@ -180,7 +180,7 @@ private static LongAdderMetricDelegate delegate(LongAdderMetric delegate) { |
180 | 180 | private final PeriodicHistogramMetricImpl pageTsHistogram; |
181 | 181 |
|
182 | 182 | /** Metric indicating whether page eviction has started. */ |
183 | | - private final BooleanMetricImpl evictionsStarted; |
| 183 | + private final AtomicBoolean evictionsStarted = new AtomicBoolean(); |
184 | 184 |
|
185 | 185 | /** |
186 | 186 | * Same as {@link #DataRegionMetricsImpl(DataRegionConfiguration, GridKernalContext, DataRegionMetricsProvider)} |
@@ -285,7 +285,7 @@ public DataRegionMetricsImpl( |
285 | 285 | mreg.longMetric("MaxSize", "Maximum memory region size in bytes defined by its data region.") |
286 | 286 | .value(dataRegionCfg.getMaxSize()); |
287 | 287 |
|
288 | | - evictionsStarted = mreg.booleanMetric("EvictionsStarted", |
| 288 | + mreg.register("EvictionsStarted", evictionsStarted::get, |
289 | 289 | "True if page eviction was triggered due to data region memory pressure."); |
290 | 290 |
|
291 | 291 | if (persistenceEnabled) { |
@@ -885,12 +885,11 @@ public Collection<PagesTimestampHistogramView> pagesTimestampHistogramView() { |
885 | 885 |
|
886 | 886 | /** {@inheritDoc} */ |
887 | 887 | @Override public boolean isEvictionsStarted() { |
888 | | - return evictionsStarted.value(); |
| 888 | + return evictionsStarted.get(); |
889 | 889 | } |
890 | 890 |
|
891 | | - /** */ |
892 | | - public void onPageEvictionsStarted() { |
893 | | - if (!evictionsStarted.value()) |
894 | | - evictionsStarted.value(true); |
| 891 | + /** @return {@code True} if eviction has started for the first time. */ |
| 892 | + public boolean onPageEvictionsStarted() { |
| 893 | + return evictionsStarted.compareAndSet(false, true); |
895 | 894 | } |
896 | 895 | } |
0 commit comments