Skip to content

Commit

Permalink
name change and delete files
Browse files Browse the repository at this point in the history
Signed-off-by: Kaituo Li <[email protected]>
  • Loading branch information
kaituo committed Jun 1, 2023
1 parent f71af09 commit f60d9cf
Show file tree
Hide file tree
Showing 33 changed files with 98 additions and 385 deletions.
12 changes: 6 additions & 6 deletions src/main/java/org/opensearch/ad/AnomalyDetectorPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@
import org.opensearch.ad.rest.RestSearchTopAnomalyResultAction;
import org.opensearch.ad.rest.RestStatsAnomalyDetectorAction;
import org.opensearch.ad.rest.RestValidateAnomalyDetectorAction;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.settings.ADNumericSetting;
import org.opensearch.ad.settings.AnomalyDetectorSettings;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.LegacyOpenDistroAnomalyDetectorSettings;
import org.opensearch.ad.settings.NumericSetting;
import org.opensearch.ad.stats.ADStat;
import org.opensearch.ad.stats.ADStats;
import org.opensearch.ad.stats.suppliers.CounterSupplier;
Expand Down Expand Up @@ -323,8 +323,8 @@ public Collection<Object> createComponents(
IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<RepositoriesService> repositoriesServiceSupplier
) {
EnabledSetting.getInstance().init(clusterService);
NumericSetting.getInstance().init(clusterService);
ADEnabledSetting.getInstance().init(clusterService);
ADNumericSetting.getInstance().init(clusterService);
this.client = client;
this.threadPool = threadPool;
Settings settings = environment.settings();
Expand Down Expand Up @@ -847,8 +847,8 @@ public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) {

@Override
public List<Setting<?>> getSettings() {
List<Setting<?>> enabledSetting = EnabledSetting.getInstance().getSettings();
List<Setting<?>> numericSetting = NumericSetting.getInstance().getSettings();
List<Setting<?>> enabledSetting = ADEnabledSetting.getInstance().getSettings();
List<Setting<?>> numericSetting = ADNumericSetting.getInstance().getSettings();

List<Setting<?>> systemSetting = ImmutableList
.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
import org.opensearch.ad.model.DetectorState;
import org.opensearch.ad.model.InitProgressProfile;
import org.opensearch.ad.model.IntervalTimeConfiguration;
import org.opensearch.ad.settings.ADNumericSetting;
import org.opensearch.ad.settings.AnomalyDetectorSettings;
import org.opensearch.ad.settings.NumericSetting;
import org.opensearch.ad.task.ADTaskManager;
import org.opensearch.ad.transport.ProfileAction;
import org.opensearch.ad.transport.ProfileRequest;
Expand Down Expand Up @@ -285,7 +285,7 @@ private void prepareProfile(

private void profileEntityStats(MultiResponsesDelegateActionListener<DetectorProfile> listener, AnomalyDetector detector) {
List<String> categoryField = detector.getCategoryField();
if (!detector.isMultientityDetector() || categoryField.size() > NumericSetting.maxCategoricalFields()) {
if (!detector.isMultientityDetector() || categoryField.size() > ADNumericSetting.maxCategoricalFields()) {
listener.onResponse(new DetectorProfile.Builder().build());
} else {
if (categoryField.size() == 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/opensearch/ad/EntityProfileRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.opensearch.ad.model.EntityState;
import org.opensearch.ad.model.InitProgressProfile;
import org.opensearch.ad.model.IntervalTimeConfiguration;
import org.opensearch.ad.settings.NumericSetting;
import org.opensearch.ad.settings.ADNumericSetting;
import org.opensearch.ad.transport.EntityProfileAction;
import org.opensearch.ad.transport.EntityProfileRequest;
import org.opensearch.ad.transport.EntityProfileResponse;
Expand Down Expand Up @@ -106,7 +106,7 @@ public void profile(
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
AnomalyDetector detector = AnomalyDetector.parse(parser, detectorId);
List<String> categoryFields = detector.getCategoryField();
int maxCategoryFields = NumericSetting.maxCategoricalFields();
int maxCategoryFields = ADNumericSetting.maxCategoricalFields();
if (categoryFields == null || categoryFields.size() == 0) {
listener.onFailure(new IllegalArgumentException(NOT_HC_DETECTOR_ERR_MSG));
} else if (categoryFields.size() > maxCategoryFields) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.monitor.jvm.JvmService;

/**
Expand Down Expand Up @@ -76,7 +76,7 @@ public ADCircuitBreakerService init() {
}

public Boolean isOpen() {
if (!EnabledSetting.isADBreakerEnabled()) {
if (!ADEnabledSetting.isADBreakerEnabled()) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/opensearch/ad/caching/PriorityCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import org.opensearch.ad.model.ModelProfile;
import org.opensearch.ad.ratelimit.CheckpointMaintainWorker;
import org.opensearch.ad.ratelimit.CheckpointWriteWorker;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.util.DateUtils;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.settings.Setting;
Expand Down Expand Up @@ -162,15 +162,15 @@ public ModelState<EntityModel> get(String modelId, AnomalyDetector detector) {

// during maintenance period, stop putting new entries
if (!maintenanceLock.isLocked() && modelState == null) {
if (EnabledSetting.isDoorKeeperInCacheEnabled()) {
if (ADEnabledSetting.isDoorKeeperInCacheEnabled()) {
DoorKeeper doorKeeper = doorKeepers
.computeIfAbsent(
detectorId,
id -> {
// reset every 60 intervals
return new DoorKeeper(
TimeSeriesSettings.DOOR_KEEPER_FOR_CACHE_MAX_INSERTION,
TimeSeriesSettings.DOOR_KEEPER_FAULSE_POSITIVE_RATE,
TimeSeriesSettings.DOOR_KEEPER_FALSE_POSITIVE_RATE,
detector.getDetectionIntervalDuration().multipliedBy(TimeSeriesSettings.DOOR_KEEPER_MAINTENANCE_FREQ),
clock
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import static org.opensearch.ad.settings.AnomalyDetectorSettings.CHECKPOINT_INDEX_MAPPING_FILE;
import static org.opensearch.ad.settings.AnomalyDetectorSettings.MAX_PRIMARY_SHARDS;
import static org.opensearch.timeseries.constant.CommonMessages.CAN_NOT_FIND_RESULT_INDEX;
import static org.opensearch.timeseries.settings.TimeSeriesSettings.ANOMALY_DETECTORS_INDEX_MAPPING_FILE;
import static org.opensearch.timeseries.settings.TimeSeriesSettings.ANOMALY_DETECTOR_JOBS_INDEX_MAPPING_FILE;
import static org.opensearch.timeseries.settings.TimeSeriesSettings.INDEX_MAPPING_FILE;
import static org.opensearch.timeseries.settings.TimeSeriesSettings.JOBS_INDEX_MAPPING_FILE;

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

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

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/opensearch/ad/ml/EntityColdStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import org.opensearch.ad.model.IntervalTimeConfiguration;
import org.opensearch.ad.ratelimit.CheckpointWriteWorker;
import org.opensearch.ad.ratelimit.RequestPriority;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.util.ExceptionUtil;
import org.opensearch.common.settings.Settings;
import org.opensearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -252,7 +252,7 @@ private void coldStart(
// reset every 60 intervals
return new DoorKeeper(
TimeSeriesSettings.DOOR_KEEPER_FOR_COLD_STARTER_MAX_INSERTION,
TimeSeriesSettings.DOOR_KEEPER_FAULSE_POSITIVE_RATE,
TimeSeriesSettings.DOOR_KEEPER_FALSE_POSITIVE_RATE,
detector.getDetectionIntervalDuration().multipliedBy(TimeSeriesSettings.DOOR_KEEPER_MAINTENANCE_FREQ),
clock
);
Expand Down Expand Up @@ -596,7 +596,7 @@ private int calculateColdStartDataSize(List<double[][]> coldStartData) {
*/
private Pair<Integer, Integer> selectRangeParam(AnomalyDetector detector) {
int shingleSize = detector.getShingleSize();
if (EnabledSetting.isInterpolationInColdStartEnabled()) {
if (ADEnabledSetting.isInterpolationInColdStartEnabled()) {
long delta = detector.getDetectorIntervalInMinutes();

int strideLength = defaulStrideLength;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/opensearch/ad/model/AnomalyDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.opensearch.ad.common.exception.ADValidationException;
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.constant.CommonValue;
import org.opensearch.ad.settings.NumericSetting;
import org.opensearch.ad.settings.ADNumericSetting;
import org.opensearch.ad.util.ParseUtils;
import org.opensearch.common.ParsingException;
import org.opensearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -196,7 +196,7 @@ public AnomalyDetector(
ValidationAspect.DETECTOR
);
}
int maxCategoryFields = NumericSetting.maxCategoricalFields();
int maxCategoryFields = ADNumericSetting.maxCategoricalFields();
if (categoryFields != null && categoryFields.size() > maxCategoryFields) {
throw new ADValidationException(
CommonMessages.getTooManyCategoricalFieldErr(maxCategoryFields),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.opensearch.action.search.SearchRequest;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.client.node.NodeClient;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.rest.BaseRestHandler;
Expand Down Expand Up @@ -66,7 +66,7 @@ public AbstractSearchAction(

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
if (!EnabledSetting.isADPluginEnabled()) {
if (!ADEnabledSetting.isADEnabled()) {
throw new IllegalStateException(ADCommonMessages.DISABLED_ERR_MSG);
}
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.opensearch.ad.AnomalyDetectorPlugin;
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.model.DetectionDateRange;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.transport.AnomalyDetectorJobAction;
import org.opensearch.ad.transport.AnomalyDetectorJobRequest;
import org.opensearch.client.node.NodeClient;
Expand Down Expand Up @@ -61,7 +61,7 @@ public String getName() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
if (!EnabledSetting.isADPluginEnabled()) {
if (!ADEnabledSetting.isADEnabled()) {
throw new IllegalStateException(ADCommonMessages.DISABLED_ERR_MSG);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.opensearch.ad.AnomalyDetectorPlugin;
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.rest.handler.AnomalyDetectorActionHandler;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.transport.DeleteAnomalyDetectorAction;
import org.opensearch.ad.transport.DeleteAnomalyDetectorRequest;
import org.opensearch.client.node.NodeClient;
Expand Down Expand Up @@ -51,7 +51,7 @@ public String getName() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
if (!EnabledSetting.isADPluginEnabled()) {
if (!ADEnabledSetting.isADEnabled()) {
throw new IllegalStateException(ADCommonMessages.DISABLED_ERR_MSG);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.opensearch.action.support.IndicesOptions;
import org.opensearch.ad.AnomalyDetectorPlugin;
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.transport.DeleteAnomalyResultsAction;
import org.opensearch.client.node.NodeClient;
import org.opensearch.core.xcontent.ToXContent;
Expand Down Expand Up @@ -62,7 +62,7 @@ public String getName() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
if (!EnabledSetting.isADPluginEnabled()) {
if (!ADEnabledSetting.isADEnabled()) {
throw new IllegalStateException(ADCommonMessages.DISABLED_ERR_MSG);
}
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.opensearch.ad.AnomalyDetectorPlugin;
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.model.AnomalyDetectorExecutionInput;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.transport.AnomalyResultAction;
import org.opensearch.ad.transport.AnomalyResultRequest;
import org.opensearch.client.node.NodeClient;
Expand Down Expand Up @@ -65,7 +65,7 @@ public String getName() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
if (!EnabledSetting.isADPluginEnabled()) {
if (!ADEnabledSetting.isADEnabled()) {
throw new IllegalStateException(ADCommonMessages.DISABLED_ERR_MSG);
}
AnomalyDetectorExecutionInput input = getAnomalyDetectorExecutionInput(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.constant.ADCommonName;
import org.opensearch.ad.model.Entity;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.transport.GetAnomalyDetectorAction;
import org.opensearch.ad.transport.GetAnomalyDetectorRequest;
import org.opensearch.client.node.NodeClient;
Expand Down Expand Up @@ -56,7 +56,7 @@ public String getName() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
if (!EnabledSetting.isADPluginEnabled()) {
if (!ADEnabledSetting.isADEnabled()) {
throw new IllegalStateException(ADCommonMessages.DISABLED_ERR_MSG);
}
String detectorId = request.param(DETECTOR_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.opensearch.ad.AnomalyDetectorPlugin;
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.model.AnomalyDetector;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.transport.IndexAnomalyDetectorAction;
import org.opensearch.ad.transport.IndexAnomalyDetectorRequest;
import org.opensearch.ad.transport.IndexAnomalyDetectorResponse;
Expand Down Expand Up @@ -65,7 +65,7 @@ public String getName() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
if (!EnabledSetting.isADPluginEnabled()) {
if (!ADEnabledSetting.isADEnabled()) {
throw new IllegalStateException(ADCommonMessages.DISABLED_ERR_MSG);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.opensearch.ad.AnomalyDetectorPlugin;
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.model.AnomalyDetectorExecutionInput;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.transport.PreviewAnomalyDetectorAction;
import org.opensearch.ad.transport.PreviewAnomalyDetectorRequest;
import org.opensearch.ad.util.RestHandlerUtils;
Expand Down Expand Up @@ -54,7 +54,7 @@ public String getName() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, org.opensearch.client.node.NodeClient client) throws IOException {
if (!EnabledSetting.isADPluginEnabled()) {
if (!ADEnabledSetting.isADEnabled()) {
throw new IllegalStateException(ADCommonMessages.DISABLED_ERR_MSG);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.logging.log4j.Logger;
import org.opensearch.ad.AnomalyDetectorPlugin;
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.transport.SearchAnomalyDetectorInfoAction;
import org.opensearch.ad.transport.SearchAnomalyDetectorInfoRequest;
import org.opensearch.rest.BaseRestHandler;
Expand All @@ -47,7 +47,7 @@ public String getName() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, org.opensearch.client.node.NodeClient client) throws IOException {
if (!EnabledSetting.isADPluginEnabled()) {
if (!ADEnabledSetting.isADEnabled()) {
throw new IllegalStateException(ADCommonMessages.DISABLED_ERR_MSG);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.opensearch.ad.AnomalyDetectorPlugin;
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.model.AnomalyResult;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.transport.SearchAnomalyResultAction;
import org.opensearch.client.node.NodeClient;
import org.opensearch.rest.RestRequest;
Expand Down Expand Up @@ -57,7 +57,7 @@ public String getName() {

@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
if (!EnabledSetting.isADPluginEnabled()) {
if (!ADEnabledSetting.isADEnabled()) {
throw new IllegalStateException(ADCommonMessages.DISABLED_ERR_MSG);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.opensearch.ad.AnomalyDetectorPlugin;
import org.opensearch.ad.constant.ADCommonMessages;
import org.opensearch.ad.settings.EnabledSetting;
import org.opensearch.ad.settings.ADEnabledSetting;
import org.opensearch.ad.transport.SearchTopAnomalyResultAction;
import org.opensearch.ad.transport.SearchTopAnomalyResultRequest;
import org.opensearch.ad.util.RestHandlerUtils;
Expand Down Expand Up @@ -58,7 +58,7 @@ public String getName() {
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {

// Throw error if disabled
if (!EnabledSetting.isADPluginEnabled()) {
if (!ADEnabledSetting.isADEnabled()) {
throw new IllegalStateException(ADCommonMessages.DISABLED_ERR_MSG);
}

Expand Down
Loading

0 comments on commit f60d9cf

Please sign in to comment.