|
11 | 11 |
|
12 | 12 | package org.opensearch.ad.caching;
|
13 | 13 |
|
14 |
| -import static org.opensearch.ad.settings.AnomalyDetectorSettings.DEDICATED_CACHE_SIZE; |
15 |
| -import static org.opensearch.ad.settings.AnomalyDetectorSettings.MODEL_MAX_SIZE_PERCENTAGE; |
| 14 | +import static org.opensearch.ad.settings.AnomalyDetectorSettings.AD_DEDICATED_CACHE_SIZE; |
| 15 | +import static org.opensearch.ad.settings.AnomalyDetectorSettings.AD_MODEL_MAX_SIZE_PERCENTAGE; |
16 | 16 |
|
17 | 17 | import java.time.Clock;
|
18 | 18 | import java.time.Duration;
|
|
38 | 38 | import org.apache.logging.log4j.LogManager;
|
39 | 39 | import org.apache.logging.log4j.Logger;
|
40 | 40 | import org.apache.logging.log4j.message.ParameterizedMessage;
|
41 |
| -import org.opensearch.ad.MemoryTracker; |
42 |
| -import org.opensearch.ad.MemoryTracker.Origin; |
43 | 41 | import org.opensearch.ad.ml.CheckpointDao;
|
44 | 42 | import org.opensearch.ad.ml.EntityModel;
|
45 | 43 | import org.opensearch.ad.ml.ModelManager.ModelType;
|
|
57 | 55 | import org.opensearch.core.action.ActionListener;
|
58 | 56 | import org.opensearch.core.common.Strings;
|
59 | 57 | import org.opensearch.threadpool.ThreadPool;
|
| 58 | +import org.opensearch.timeseries.MemoryTracker; |
| 59 | +import org.opensearch.timeseries.MemoryTracker.Origin; |
60 | 60 | import org.opensearch.timeseries.TimeSeriesAnalyticsPlugin;
|
61 | 61 | import org.opensearch.timeseries.common.exception.LimitExceededException;
|
62 | 62 | import org.opensearch.timeseries.common.exception.TimeSeriesException;
|
@@ -116,12 +116,12 @@ public PriorityCache(
|
116 | 116 |
|
117 | 117 | this.activeEnities = new ConcurrentHashMap<>();
|
118 | 118 | this.dedicatedCacheSize = dedicatedCacheSize;
|
119 |
| - clusterService.getClusterSettings().addSettingsUpdateConsumer(DEDICATED_CACHE_SIZE, (it) -> { |
| 119 | + clusterService.getClusterSettings().addSettingsUpdateConsumer(AD_DEDICATED_CACHE_SIZE, (it) -> { |
120 | 120 | this.dedicatedCacheSize = it;
|
121 | 121 | this.setDedicatedCacheSizeListener();
|
122 | 122 | this.tryClearUpMemory();
|
123 | 123 | }, this::validateDedicatedCacheSize);
|
124 |
| - clusterService.getClusterSettings().addSettingsUpdateConsumer(MODEL_MAX_SIZE_PERCENTAGE, it -> this.tryClearUpMemory()); |
| 124 | + clusterService.getClusterSettings().addSettingsUpdateConsumer(AD_MODEL_MAX_SIZE_PERCENTAGE, it -> this.tryClearUpMemory()); |
125 | 125 |
|
126 | 126 | this.memoryTracker = memoryTracker;
|
127 | 127 | this.maintenanceLock = new ReentrantLock();
|
@@ -461,7 +461,7 @@ private CacheBuffer computeBufferIfAbsent(AnomalyDetector detector, String detec
|
461 | 461 | if (buffer == null) {
|
462 | 462 | long requiredBytes = getRequiredMemory(detector, dedicatedCacheSize);
|
463 | 463 | if (memoryTracker.canAllocateReserved(requiredBytes)) {
|
464 |
| - memoryTracker.consumeMemory(requiredBytes, true, Origin.HC_DETECTOR); |
| 464 | + memoryTracker.consumeMemory(requiredBytes, true, Origin.REAL_TIME_DETECTOR); |
465 | 465 | long intervalSecs = detector.getIntervalInSeconds();
|
466 | 466 |
|
467 | 467 | buffer = new CacheBuffer(
|
@@ -621,7 +621,7 @@ private void recalculateUsedMemory() {
|
621 | 621 | reserved += buffer.getReservedBytes();
|
622 | 622 | shared += buffer.getBytesInSharedCache();
|
623 | 623 | }
|
624 |
| - memoryTracker.syncMemoryState(Origin.HC_DETECTOR, reserved + shared, reserved); |
| 624 | + memoryTracker.syncMemoryState(Origin.REAL_TIME_DETECTOR, reserved + shared, reserved); |
625 | 625 | }
|
626 | 626 |
|
627 | 627 | /**
|
|
0 commit comments