This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade mapping This PR updates the current AD index mapping if a new version is detected. Previously, we didn't do so. This will cause issues when upgrading AD binary version: newly added fields will not be searchable, though we can still send get requests to fetch them. Testing done: 1. manual upgrade testing passes with fgac on and off. 2. will add unit tests later.
- Loading branch information
Showing
27 changed files
with
570 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.ad.constant; | ||
|
||
public class CommonValue { | ||
// unknown or no schema version | ||
public static Integer NO_SCHEMA_VERSION = 0; | ||
} |
82 changes: 82 additions & 0 deletions
82
src/main/java/com/amazon/opendistroforelasticsearch/ad/indices/ADIndex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.ad.indices; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; | ||
import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; | ||
import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; | ||
import com.amazon.opendistroforelasticsearch.ad.model.DetectorInternalState; | ||
import com.amazon.opendistroforelasticsearch.ad.util.ThrowingSupplierWrapper; | ||
|
||
/** | ||
* Represent an AD index | ||
* | ||
*/ | ||
public enum ADIndex { | ||
|
||
// throw RuntimeException since we don't know how to handle the case when the mapping reading throws IOException | ||
RESULT( | ||
CommonName.ANOMALY_RESULT_INDEX_ALIAS, | ||
true, | ||
ThrowingSupplierWrapper.throwingSupplierWrapper(AnomalyDetectionIndices::getAnomalyResultMappings) | ||
), | ||
CONFIG( | ||
AnomalyDetector.ANOMALY_DETECTORS_INDEX, | ||
false, | ||
ThrowingSupplierWrapper.throwingSupplierWrapper(AnomalyDetectionIndices::getAnomalyDetectorMappings) | ||
), | ||
JOB( | ||
AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX, | ||
false, | ||
ThrowingSupplierWrapper.throwingSupplierWrapper(AnomalyDetectionIndices::getAnomalyDetectorJobMappings) | ||
), | ||
CHECKPOINT( | ||
CommonName.CHECKPOINT_INDEX_NAME, | ||
false, | ||
ThrowingSupplierWrapper.throwingSupplierWrapper(AnomalyDetectionIndices::getCheckpointMappings) | ||
), | ||
STATE( | ||
DetectorInternalState.DETECTOR_STATE_INDEX, | ||
false, | ||
ThrowingSupplierWrapper.throwingSupplierWrapper(AnomalyDetectionIndices::getDetectorStateMappings) | ||
); | ||
|
||
private final String indexName; | ||
// whether we use an alias for the index | ||
private final boolean alias; | ||
private final String mapping; | ||
|
||
ADIndex(String name, boolean alias, Supplier<String> mappingSupplier) { | ||
this.indexName = name; | ||
this.alias = alias; | ||
this.mapping = mappingSupplier.get(); | ||
} | ||
|
||
public String getIndexName() { | ||
return indexName; | ||
} | ||
|
||
public boolean isAlias() { | ||
return alias; | ||
} | ||
|
||
public String getMapping() { | ||
return mapping; | ||
} | ||
|
||
} |
Oops, something went wrong.