forked from opensearch-project/anomaly-detection
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathADIndex.java
More file actions
78 lines (67 loc) · 2.52 KB
/
ADIndex.java
File metadata and controls
78 lines (67 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
package org.opensearch.ad.indices;
import java.util.function.Supplier;
import org.opensearch.ad.constant.ADCommonName;
import org.opensearch.timeseries.constant.CommonName;
import org.opensearch.timeseries.function.ThrowingSupplierWrapper;
import org.opensearch.timeseries.indices.TimeSeriesIndex;
/**
* Represent an AD index
*
*/
public enum ADIndex implements TimeSeriesIndex {
// throw RuntimeException since we don't know how to handle the case when the mapping reading throws IOException
RESULT(
ADCommonName.ANOMALY_RESULT_INDEX_ALIAS,
true,
ThrowingSupplierWrapper.throwingSupplierWrapper(ADIndexManagement::getResultMappings)
),
CONFIG(ADCommonName.CONFIG_INDEX, false, ThrowingSupplierWrapper.throwingSupplierWrapper(ADIndexManagement::getConfigMappings)),
JOB(CommonName.JOB_INDEX, false, ThrowingSupplierWrapper.throwingSupplierWrapper(ADIndexManagement::getJobMappings)),
CHECKPOINT(
ADCommonName.CHECKPOINT_INDEX_NAME,
false,
ThrowingSupplierWrapper.throwingSupplierWrapper(ADIndexManagement::getCheckpointMappings)
),
STATE(ADCommonName.DETECTION_STATE_INDEX, false, ThrowingSupplierWrapper.throwingSupplierWrapper(ADIndexManagement::getStateMappings)),
CUSTOM_RESULT(CUSTOM_RESULT_INDEX, true, ThrowingSupplierWrapper.throwingSupplierWrapper(ADIndexManagement::getResultMappings)),
CUSTOM_INSIGHTS_RESULT(
ADCommonName.INSIGHTS_RESULT_INDEX_ALIAS,
true,
ThrowingSupplierWrapper.throwingSupplierWrapper(ADIndexManagement::getInsightsResultMappings)
);
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();
}
@Override
public String getIndexName() {
return indexName;
}
@Override
public boolean isAlias() {
return alias;
}
@Override
public String getMapping() {
return mapping;
}
@Override
public boolean isConfigIndex() {
return ADCommonName.CONFIG_INDEX.equals(getIndexName());
}
}