Skip to content

Commit 472868d

Browse files
authored
Refactor Shared Settings, Introduce Dynamic Forecast Settings, Rename (#912)
* Refactor Shared Settings, Introduce Dynamic Forecast Settings, and Rename Checkpoint mapping File This commit has undertaken three changes: * Refactoring of Shared Settings: I've performed a refactoring to unify the settings that are shared between the AD and forecasting modules. * Introduction of Dynamic Forecast Settings: To increase the adaptability of our system, I've implemented dynamic forecast settings. These settings mirror the existing structure of the AD dynamic settings and will enable us to adjust forecast settings on-the-fly. * Renaming of Checkpoint File: To enhance the consistency across our AD mapping files, I've renamed checkpoint.json to anomaly-checkpoint.java. Testing done: 1. added tests for new settings. Signed-off-by: Kaituo Li <[email protected]> * name change and delete files Signed-off-by: Kaituo Li <[email protected]> --------- Signed-off-by: Kaituo Li <[email protected]>
1 parent 04ab91e commit 472868d

File tree

64 files changed

+950
-305
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+950
-305
lines changed

build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,9 @@ List<String> jacocoExclusions = [
668668
'org.opensearch.ad.constant.*',
669669
'org.opensearch.forecast.constant.*',
670670
'org.opensearch.timeseries.constant.*',
671+
'org.opensearch.timeseries.settings.TimeSeriesSettings',
672+
'org.opensearch.forecast.settings.ForecastSettings',
671673

672-
//'org.opensearch.ad.common.exception.AnomalyDetectionException',
673674
'org.opensearch.ad.util.ClientUtil',
674675

675676
'org.opensearch.ad.transport.CronRequest',

src/main/java/org/opensearch/ad/AnomalyDetectorPlugin.java

+17-17
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@
7575
import org.opensearch.ad.rest.RestSearchTopAnomalyResultAction;
7676
import org.opensearch.ad.rest.RestStatsAnomalyDetectorAction;
7777
import org.opensearch.ad.rest.RestValidateAnomalyDetectorAction;
78+
import org.opensearch.ad.settings.ADEnabledSetting;
79+
import org.opensearch.ad.settings.ADNumericSetting;
7880
import org.opensearch.ad.settings.AnomalyDetectorSettings;
79-
import org.opensearch.ad.settings.EnabledSetting;
8081
import org.opensearch.ad.settings.LegacyOpenDistroAnomalyDetectorSettings;
81-
import org.opensearch.ad.settings.NumericSetting;
8282
import org.opensearch.ad.stats.ADStat;
8383
import org.opensearch.ad.stats.ADStats;
8484
import org.opensearch.ad.stats.suppliers.CounterSupplier;
@@ -323,8 +323,8 @@ public Collection<Object> createComponents(
323323
IndexNameExpressionResolver indexNameExpressionResolver,
324324
Supplier<RepositoriesService> repositoriesServiceSupplier
325325
) {
326-
EnabledSetting.getInstance().init(clusterService);
327-
NumericSetting.getInstance().init(clusterService);
326+
ADEnabledSetting.getInstance().init(clusterService);
327+
ADNumericSetting.getInstance().init(clusterService);
328328
this.client = client;
329329
this.threadPool = threadPool;
330330
Settings settings = environment.settings();
@@ -847,8 +847,8 @@ public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) {
847847

848848
@Override
849849
public List<Setting<?>> getSettings() {
850-
List<Setting<?>> enabledSetting = EnabledSetting.getInstance().getSettings();
851-
List<Setting<?>> numericSetting = NumericSetting.getInstance().getSettings();
850+
List<Setting<?>> enabledSetting = ADEnabledSetting.getInstance().getSettings();
851+
List<Setting<?>> numericSetting = ADNumericSetting.getInstance().getSettings();
852852

853853
List<Setting<?>> systemSetting = ImmutableList
854854
.of(
@@ -873,8 +873,8 @@ public List<Setting<?>> getSettings() {
873873
AnomalyDetectorSettings.MAX_RETRY_FOR_UNRESPONSIVE_NODE,
874874
AnomalyDetectorSettings.COOLDOWN_MINUTES,
875875
AnomalyDetectorSettings.BACKOFF_MINUTES,
876-
AnomalyDetectorSettings.BACKOFF_INITIAL_DELAY,
877-
AnomalyDetectorSettings.MAX_RETRY_FOR_BACKOFF,
876+
AnomalyDetectorSettings.AD_BACKOFF_INITIAL_DELAY,
877+
AnomalyDetectorSettings.AD_MAX_RETRY_FOR_BACKOFF,
878878
// result index rollover
879879
LegacyOpenDistroAnomalyDetectorSettings.AD_RESULT_HISTORY_ROLLOVER_PERIOD,
880880
LegacyOpenDistroAnomalyDetectorSettings.AD_RESULT_HISTORY_MAX_DOCS,
@@ -891,8 +891,8 @@ public List<Setting<?>> getSettings() {
891891
AnomalyDetectorSettings.MODEL_MAX_SIZE_PERCENTAGE,
892892
AnomalyDetectorSettings.MAX_SINGLE_ENTITY_ANOMALY_DETECTORS,
893893
AnomalyDetectorSettings.MAX_MULTI_ENTITY_ANOMALY_DETECTORS,
894-
AnomalyDetectorSettings.INDEX_PRESSURE_SOFT_LIMIT,
895-
AnomalyDetectorSettings.INDEX_PRESSURE_HARD_LIMIT,
894+
AnomalyDetectorSettings.AD_INDEX_PRESSURE_SOFT_LIMIT,
895+
AnomalyDetectorSettings.AD_INDEX_PRESSURE_HARD_LIMIT,
896896
AnomalyDetectorSettings.MAX_PRIMARY_SHARDS,
897897
// Security
898898
LegacyOpenDistroAnomalyDetectorSettings.FILTER_BY_BACKEND_ROLES,
@@ -910,21 +910,21 @@ public List<Setting<?>> getSettings() {
910910
AnomalyDetectorSettings.MAX_RUNNING_ENTITIES_PER_DETECTOR_FOR_HISTORICAL_ANALYSIS,
911911
AnomalyDetectorSettings.MAX_CACHED_DELETED_TASKS,
912912
// rate limiting
913-
AnomalyDetectorSettings.CHECKPOINT_READ_QUEUE_CONCURRENCY,
914-
AnomalyDetectorSettings.CHECKPOINT_WRITE_QUEUE_CONCURRENCY,
913+
AnomalyDetectorSettings.AD_CHECKPOINT_READ_QUEUE_CONCURRENCY,
914+
AnomalyDetectorSettings.AD_CHECKPOINT_WRITE_QUEUE_CONCURRENCY,
915915
AnomalyDetectorSettings.ENTITY_COLD_START_QUEUE_CONCURRENCY,
916-
AnomalyDetectorSettings.RESULT_WRITE_QUEUE_CONCURRENCY,
917-
AnomalyDetectorSettings.CHECKPOINT_READ_QUEUE_BATCH_SIZE,
918-
AnomalyDetectorSettings.CHECKPOINT_WRITE_QUEUE_BATCH_SIZE,
919-
AnomalyDetectorSettings.RESULT_WRITE_QUEUE_BATCH_SIZE,
916+
AnomalyDetectorSettings.AD_RESULT_WRITE_QUEUE_CONCURRENCY,
917+
AnomalyDetectorSettings.AD_CHECKPOINT_READ_QUEUE_BATCH_SIZE,
918+
AnomalyDetectorSettings.AD_CHECKPOINT_WRITE_QUEUE_BATCH_SIZE,
919+
AnomalyDetectorSettings.AD_RESULT_WRITE_QUEUE_BATCH_SIZE,
920920
AnomalyDetectorSettings.COLD_ENTITY_QUEUE_MAX_HEAP_PERCENT,
921921
AnomalyDetectorSettings.CHECKPOINT_READ_QUEUE_MAX_HEAP_PERCENT,
922922
AnomalyDetectorSettings.CHECKPOINT_WRITE_QUEUE_MAX_HEAP_PERCENT,
923923
AnomalyDetectorSettings.RESULT_WRITE_QUEUE_MAX_HEAP_PERCENT,
924924
AnomalyDetectorSettings.CHECKPOINT_MAINTAIN_QUEUE_MAX_HEAP_PERCENT,
925925
AnomalyDetectorSettings.ENTITY_COLD_START_QUEUE_MAX_HEAP_PERCENT,
926926
AnomalyDetectorSettings.EXPECTED_COLD_ENTITY_EXECUTION_TIME_IN_MILLISECS,
927-
AnomalyDetectorSettings.EXPECTED_CHECKPOINT_MAINTAIN_TIME_IN_MILLISECS,
927+
AnomalyDetectorSettings.AD_EXPECTED_CHECKPOINT_MAINTAIN_TIME_IN_MILLISECS,
928928
AnomalyDetectorSettings.CHECKPOINT_SAVING_FREQ,
929929
AnomalyDetectorSettings.CHECKPOINT_TTL,
930930
// query limit

src/main/java/org/opensearch/ad/AnomalyDetectorProfileRunner.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
import org.opensearch.ad.model.DetectorState;
4444
import org.opensearch.ad.model.InitProgressProfile;
4545
import org.opensearch.ad.model.IntervalTimeConfiguration;
46+
import org.opensearch.ad.settings.ADNumericSetting;
4647
import org.opensearch.ad.settings.AnomalyDetectorSettings;
47-
import org.opensearch.ad.settings.NumericSetting;
4848
import org.opensearch.ad.task.ADTaskManager;
4949
import org.opensearch.ad.transport.ProfileAction;
5050
import org.opensearch.ad.transport.ProfileRequest;
@@ -285,7 +285,7 @@ private void prepareProfile(
285285

286286
private void profileEntityStats(MultiResponsesDelegateActionListener<DetectorProfile> listener, AnomalyDetector detector) {
287287
List<String> categoryField = detector.getCategoryField();
288-
if (!detector.isMultientityDetector() || categoryField.size() > NumericSetting.maxCategoricalFields()) {
288+
if (!detector.isMultientityDetector() || categoryField.size() > ADNumericSetting.maxCategoricalFields()) {
289289
listener.onResponse(new DetectorProfile.Builder().build());
290290
} else {
291291
if (categoryField.size() == 1) {

src/main/java/org/opensearch/ad/EntityProfileRunner.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.opensearch.ad.model.EntityState;
3737
import org.opensearch.ad.model.InitProgressProfile;
3838
import org.opensearch.ad.model.IntervalTimeConfiguration;
39-
import org.opensearch.ad.settings.NumericSetting;
39+
import org.opensearch.ad.settings.ADNumericSetting;
4040
import org.opensearch.ad.transport.EntityProfileAction;
4141
import org.opensearch.ad.transport.EntityProfileRequest;
4242
import org.opensearch.ad.transport.EntityProfileResponse;
@@ -106,7 +106,7 @@ public void profile(
106106
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
107107
AnomalyDetector detector = AnomalyDetector.parse(parser, detectorId);
108108
List<String> categoryFields = detector.getCategoryField();
109-
int maxCategoryFields = NumericSetting.maxCategoricalFields();
109+
int maxCategoryFields = ADNumericSetting.maxCategoricalFields();
110110
if (categoryFields == null || categoryFields.size() == 0) {
111111
listener.onFailure(new IllegalArgumentException(NOT_HC_DETECTOR_ERR_MSG));
112112
} else if (categoryFields.size() > maxCategoryFields) {

src/main/java/org/opensearch/ad/breaker/ADCircuitBreakerService.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import org.apache.logging.log4j.LogManager;
1818
import org.apache.logging.log4j.Logger;
19-
import org.opensearch.ad.settings.EnabledSetting;
19+
import org.opensearch.ad.settings.ADEnabledSetting;
2020
import org.opensearch.monitor.jvm.JvmService;
2121

2222
/**
@@ -76,7 +76,7 @@ public ADCircuitBreakerService init() {
7676
}
7777

7878
public Boolean isOpen() {
79-
if (!EnabledSetting.isADBreakerEnabled()) {
79+
if (!ADEnabledSetting.isADBreakerEnabled()) {
8080
return false;
8181
}
8282

src/main/java/org/opensearch/ad/caching/PriorityCache.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@
5353
import org.opensearch.ad.model.ModelProfile;
5454
import org.opensearch.ad.ratelimit.CheckpointMaintainWorker;
5555
import org.opensearch.ad.ratelimit.CheckpointWriteWorker;
56-
import org.opensearch.ad.settings.AnomalyDetectorSettings;
57-
import org.opensearch.ad.settings.EnabledSetting;
56+
import org.opensearch.ad.settings.ADEnabledSetting;
5857
import org.opensearch.ad.util.DateUtils;
5958
import org.opensearch.cluster.service.ClusterService;
6059
import org.opensearch.common.settings.Setting;
@@ -63,6 +62,7 @@
6362
import org.opensearch.core.common.Strings;
6463
import org.opensearch.threadpool.ThreadPool;
6564
import org.opensearch.timeseries.constant.CommonMessages;
65+
import org.opensearch.timeseries.settings.TimeSeriesSettings;
6666

6767
import com.google.common.cache.Cache;
6868
import com.google.common.cache.CacheBuilder;
@@ -162,16 +162,16 @@ public ModelState<EntityModel> get(String modelId, AnomalyDetector detector) {
162162

163163
// during maintenance period, stop putting new entries
164164
if (!maintenanceLock.isLocked() && modelState == null) {
165-
if (EnabledSetting.isDoorKeeperInCacheEnabled()) {
165+
if (ADEnabledSetting.isDoorKeeperInCacheEnabled()) {
166166
DoorKeeper doorKeeper = doorKeepers
167167
.computeIfAbsent(
168168
detectorId,
169169
id -> {
170170
// reset every 60 intervals
171171
return new DoorKeeper(
172-
AnomalyDetectorSettings.DOOR_KEEPER_FOR_CACHE_MAX_INSERTION,
173-
AnomalyDetectorSettings.DOOR_KEEPER_FAULSE_POSITIVE_RATE,
174-
detector.getDetectionIntervalDuration().multipliedBy(AnomalyDetectorSettings.DOOR_KEEPER_MAINTENANCE_FREQ),
172+
TimeSeriesSettings.DOOR_KEEPER_FOR_CACHE_MAX_INSERTION,
173+
TimeSeriesSettings.DOOR_KEEPER_FALSE_POSITIVE_RATE,
174+
detector.getDetectionIntervalDuration().multipliedBy(TimeSeriesSettings.DOOR_KEEPER_MAINTENANCE_FREQ),
175175
clock
176176
);
177177
}
@@ -501,7 +501,7 @@ private long getRequiredMemory(AnomalyDetector detector, int numberOfEntity) {
501501
.estimateTRCFModelSize(
502502
dimension,
503503
numberOfTrees,
504-
AnomalyDetectorSettings.REAL_TIME_BOUNDING_BOX_CACHE_RATIO,
504+
TimeSeriesSettings.REAL_TIME_BOUNDING_BOX_CACHE_RATIO,
505505
detector.getShingleSize().intValue(),
506506
true
507507
);

src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
import static org.opensearch.ad.settings.AnomalyDetectorSettings.AD_RESULT_HISTORY_RETENTION_PERIOD;
1717
import static org.opensearch.ad.settings.AnomalyDetectorSettings.AD_RESULT_HISTORY_ROLLOVER_PERIOD;
1818
import static org.opensearch.ad.settings.AnomalyDetectorSettings.ANOMALY_DETECTION_STATE_INDEX_MAPPING_FILE;
19-
import static org.opensearch.ad.settings.AnomalyDetectorSettings.ANOMALY_DETECTORS_INDEX_MAPPING_FILE;
20-
import static org.opensearch.ad.settings.AnomalyDetectorSettings.ANOMALY_DETECTOR_JOBS_INDEX_MAPPING_FILE;
2119
import static org.opensearch.ad.settings.AnomalyDetectorSettings.ANOMALY_RESULTS_INDEX_MAPPING_FILE;
2220
import static org.opensearch.ad.settings.AnomalyDetectorSettings.CHECKPOINT_INDEX_MAPPING_FILE;
2321
import static org.opensearch.ad.settings.AnomalyDetectorSettings.MAX_PRIMARY_SHARDS;
2422
import static org.opensearch.timeseries.constant.CommonMessages.CAN_NOT_FIND_RESULT_INDEX;
23+
import static org.opensearch.timeseries.settings.TimeSeriesSettings.INDEX_MAPPING_FILE;
24+
import static org.opensearch.timeseries.settings.TimeSeriesSettings.JOBS_INDEX_MAPPING_FILE;
2525

2626
import java.io.IOException;
2727
import java.net.URL;
@@ -238,7 +238,7 @@ private void initResultMapping() throws IOException {
238238
* @throws IOException IOException if mapping file can't be read correctly
239239
*/
240240
public static String getAnomalyDetectorMappings() throws IOException {
241-
URL url = AnomalyDetectionIndices.class.getClassLoader().getResource(ANOMALY_DETECTORS_INDEX_MAPPING_FILE);
241+
URL url = AnomalyDetectionIndices.class.getClassLoader().getResource(INDEX_MAPPING_FILE);
242242
return Resources.toString(url, Charsets.UTF_8);
243243
}
244244

@@ -260,7 +260,7 @@ public static String getAnomalyResultMappings() throws IOException {
260260
* @throws IOException IOException if mapping file can't be read correctly
261261
*/
262262
public static String getAnomalyDetectorJobMappings() throws IOException {
263-
URL url = AnomalyDetectionIndices.class.getClassLoader().getResource(ANOMALY_DETECTOR_JOBS_INDEX_MAPPING_FILE);
263+
URL url = AnomalyDetectionIndices.class.getClassLoader().getResource(JOBS_INDEX_MAPPING_FILE);
264264
return Resources.toString(url, Charsets.UTF_8);
265265
}
266266

src/main/java/org/opensearch/ad/ml/EntityColdStarter.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
import org.opensearch.ad.model.IntervalTimeConfiguration;
5252
import org.opensearch.ad.ratelimit.CheckpointWriteWorker;
5353
import org.opensearch.ad.ratelimit.RequestPriority;
54-
import org.opensearch.ad.settings.AnomalyDetectorSettings;
55-
import org.opensearch.ad.settings.EnabledSetting;
54+
import org.opensearch.ad.settings.ADEnabledSetting;
5655
import org.opensearch.ad.util.ExceptionUtil;
5756
import org.opensearch.common.settings.Settings;
5857
import org.opensearch.threadpool.ThreadPool;
5958
import org.opensearch.timeseries.dataprocessor.Imputer;
59+
import org.opensearch.timeseries.settings.TimeSeriesSettings;
6060

6161
import com.amazon.randomcutforest.config.Precision;
6262
import com.amazon.randomcutforest.parkservices.ThresholdedRandomCutForest;
@@ -251,9 +251,9 @@ private void coldStart(
251251
id -> {
252252
// reset every 60 intervals
253253
return new DoorKeeper(
254-
AnomalyDetectorSettings.DOOR_KEEPER_FOR_COLD_STARTER_MAX_INSERTION,
255-
AnomalyDetectorSettings.DOOR_KEEPER_FAULSE_POSITIVE_RATE,
256-
detector.getDetectionIntervalDuration().multipliedBy(AnomalyDetectorSettings.DOOR_KEEPER_MAINTENANCE_FREQ),
254+
TimeSeriesSettings.DOOR_KEEPER_FOR_COLD_STARTER_MAX_INSERTION,
255+
TimeSeriesSettings.DOOR_KEEPER_FALSE_POSITIVE_RATE,
256+
detector.getDetectionIntervalDuration().multipliedBy(TimeSeriesSettings.DOOR_KEEPER_MAINTENANCE_FREQ),
257257
clock
258258
);
259259
}
@@ -365,7 +365,7 @@ private void trainModelFromDataSegments(
365365
.parallelExecutionEnabled(false)
366366
.compact(true)
367367
.precision(Precision.FLOAT_32)
368-
.boundingBoxCacheFraction(AnomalyDetectorSettings.REAL_TIME_BOUNDING_BOX_CACHE_RATIO)
368+
.boundingBoxCacheFraction(TimeSeriesSettings.REAL_TIME_BOUNDING_BOX_CACHE_RATIO)
369369
// same with dimension for opportunistic memory saving
370370
// Usually, we use it as shingleSize(dimension). When a new point comes in, we will
371371
// look at the point store if there is any overlapping. Say the previously-stored
@@ -596,7 +596,7 @@ private int calculateColdStartDataSize(List<double[][]> coldStartData) {
596596
*/
597597
private Pair<Integer, Integer> selectRangeParam(AnomalyDetector detector) {
598598
int shingleSize = detector.getShingleSize();
599-
if (EnabledSetting.isInterpolationInColdStartEnabled()) {
599+
if (ADEnabledSetting.isInterpolationInColdStartEnabled()) {
600600
long delta = detector.getDetectorIntervalInMinutes();
601601

602602
int strideLength = defaulStrideLength;

src/main/java/org/opensearch/ad/ml/ModelManager.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.opensearch.common.settings.Setting;
4747
import org.opensearch.common.settings.Settings;
4848
import org.opensearch.common.unit.TimeValue;
49+
import org.opensearch.timeseries.settings.TimeSeriesSettings;
4950

5051
import com.amazon.randomcutforest.RandomCutForest;
5152
import com.amazon.randomcutforest.config.Precision;
@@ -527,7 +528,7 @@ private void trainModelForStep(
527528
.parallelExecutionEnabled(false)
528529
.compact(true)
529530
.precision(Precision.FLOAT_32)
530-
.boundingBoxCacheFraction(AnomalyDetectorSettings.REAL_TIME_BOUNDING_BOX_CACHE_RATIO)
531+
.boundingBoxCacheFraction(TimeSeriesSettings.REAL_TIME_BOUNDING_BOX_CACHE_RATIO)
531532
.shingleSize(detector.getShingleSize())
532533
.anomalyRate(1 - thresholdMinPvalue)
533534
.build();

src/main/java/org/opensearch/ad/model/AnomalyDetector.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
import static org.opensearch.ad.constant.ADCommonName.CUSTOM_RESULT_INDEX_PREFIX;
1616
import static org.opensearch.ad.model.AnomalyDetectorType.MULTI_ENTITY;
1717
import static org.opensearch.ad.model.AnomalyDetectorType.SINGLE_ENTITY;
18-
import static org.opensearch.ad.settings.AnomalyDetectorSettings.DEFAULT_SHINGLE_SIZE;
1918
import static org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
2019
import static org.opensearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder;
2120
import static org.opensearch.timeseries.constant.CommonMessages.INVALID_CHAR_IN_RESULT_INDEX_NAME;
21+
import static org.opensearch.timeseries.settings.TimeSeriesSettings.DEFAULT_SHINGLE_SIZE;
2222

2323
import java.io.IOException;
2424
import java.time.Duration;
@@ -33,8 +33,7 @@
3333
import org.opensearch.ad.common.exception.ADValidationException;
3434
import org.opensearch.ad.constant.ADCommonMessages;
3535
import org.opensearch.ad.constant.CommonValue;
36-
import org.opensearch.ad.settings.AnomalyDetectorSettings;
37-
import org.opensearch.ad.settings.NumericSetting;
36+
import org.opensearch.ad.settings.ADNumericSetting;
3837
import org.opensearch.ad.util.ParseUtils;
3938
import org.opensearch.common.ParsingException;
4039
import org.opensearch.common.io.stream.StreamInput;
@@ -54,6 +53,7 @@
5453
import org.opensearch.timeseries.annotation.Generated;
5554
import org.opensearch.timeseries.constant.CommonMessages;
5655
import org.opensearch.timeseries.constant.CommonName;
56+
import org.opensearch.timeseries.settings.TimeSeriesSettings;
5757

5858
import com.google.common.base.Objects;
5959
import com.google.common.collect.ImmutableList;
@@ -191,15 +191,12 @@ public AnomalyDetector(
191191
}
192192
if (invalidShingleSizeRange(shingleSize)) {
193193
throw new ADValidationException(
194-
"Shingle size must be a positive integer no larger than "
195-
+ AnomalyDetectorSettings.MAX_SHINGLE_SIZE
196-
+ ". Got "
197-
+ shingleSize,
194+
"Shingle size must be a positive integer no larger than " + TimeSeriesSettings.MAX_SHINGLE_SIZE + ". Got " + shingleSize,
198195
DetectorValidationIssueType.SHINGLE_SIZE_FIELD,
199196
ValidationAspect.DETECTOR
200197
);
201198
}
202-
int maxCategoryFields = NumericSetting.maxCategoricalFields();
199+
int maxCategoryFields = ADNumericSetting.maxCategoricalFields();
203200
if (categoryFields != null && categoryFields.size() > maxCategoryFields) {
204201
throw new ADValidationException(
205202
CommonMessages.getTooManyCategoricalFieldErr(maxCategoryFields),
@@ -756,6 +753,6 @@ private static boolean isMultientityDetector(List<String> categoryFields) {
756753
}
757754

758755
public boolean invalidShingleSizeRange(Integer shingleSizeToTest) {
759-
return shingleSizeToTest != null && (shingleSizeToTest < 1 || shingleSizeToTest > AnomalyDetectorSettings.MAX_SHINGLE_SIZE);
756+
return shingleSizeToTest != null && (shingleSizeToTest < 1 || shingleSizeToTest > TimeSeriesSettings.MAX_SHINGLE_SIZE);
760757
}
761758
}

0 commit comments

Comments
 (0)