java.lang.Object
org.elasticsearch.xpack.core.ml.utils.MlIndexAndAlias
Utils to create an ML index with alias ready for rollover with a 6-digit suffix
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateIndexAndAliasIfNecessary(Client client, ClusterState clusterState, IndexNameExpressionResolver resolver, String indexPatternPrefix, String indexNumber, String alias, org.elasticsearch.core.TimeValue masterNodeTimeout, ActiveShardCount waitForShardCount, ActionListener<Boolean> finalListener) Same as createIndexAndAliasIfNecessary but with the first concrete index number specified.static voidcreateIndexAndAliasIfNecessary(Client client, ClusterState clusterState, IndexNameExpressionResolver resolver, String indexPatternPrefix, String alias, org.elasticsearch.core.TimeValue masterNodeTimeout, ActiveShardCount waitForShardCount, ActionListener<Boolean> finalListener) Creates the first index with a name of the givenindexPatternPrefixfollowed by "-000001", if the index is missing.static voidcreateSystemIndexIfNecessary(Client client, ClusterState clusterState, SystemIndexDescriptor descriptor, org.elasticsearch.core.TimeValue masterNodeTimeout, ActionListener<Boolean> finalListener) static booleanhas6DigitSuffix(String indexName) static booleanhasIndexTemplate(ClusterState state, String templateName, long version) static booleanTrue if the version is read *and* write compatible not just read only compatiblestatic voidinstallIndexTemplateIfRequired(ClusterState clusterState, Client client, int templateVersion, TransportPutComposableIndexTemplateAction.Request templateRequest, ActionListener<Boolean> listener) static voidinstallIndexTemplateIfRequired(ClusterState clusterState, Client client, IndexTemplateConfig templateConfig, org.elasticsearch.core.TimeValue masterTimeout, ActionListener<Boolean> listener) Installs the index template specified bytemplateConfigif it is not in already installed inclusterState.static StringlatestIndex(String[] concreteIndices) Returns the latest index.static voidupdateWriteAlias(Client client, String alias, String currentIndex, String newIndex, org.elasticsearch.core.TimeValue masterNodeTimeout, ActionListener<Boolean> listener)
-
Field Details
-
BWC_MAPPINGS_VERSION
ML managed index mappings used to be updated based on the product version. They are now updated based on per-index mappings versions. However, older nodes will still look for a product version in the mappings metadata, so we have to put something in that field that will allow the older node to realise that the mappings are ahead of what it knows about. The easiest solution is to hardcode 8.11.0 in this field, because any node from 8.10.0 onwards should be using per-index mappings versions to determine whether mappings are up-to-date.- See Also:
-
FIRST_INDEX_SIX_DIGIT_SUFFIX
- See Also:
-
-
Method Details
-
createIndexAndAliasIfNecessary
public static void createIndexAndAliasIfNecessary(Client client, ClusterState clusterState, IndexNameExpressionResolver resolver, String indexPatternPrefix, String alias, org.elasticsearch.core.TimeValue masterNodeTimeout, ActiveShardCount waitForShardCount, ActionListener<Boolean> finalListener) Creates the first index with a name of the givenindexPatternPrefixfollowed by "-000001", if the index is missing. Adds analiasto that index if it was created, or to the index with the highest suffix if the index did not have to be created. The listener is notified with abooleanthat informs whether the index or the alias were created. If the index is created, the listener is not called until the index is ready to use via the supplied alias, so that a method that receives a success response from this method can safely use the index immediately. -
createIndexAndAliasIfNecessary
public static void createIndexAndAliasIfNecessary(Client client, ClusterState clusterState, IndexNameExpressionResolver resolver, String indexPatternPrefix, String indexNumber, String alias, org.elasticsearch.core.TimeValue masterNodeTimeout, ActiveShardCount waitForShardCount, ActionListener<Boolean> finalListener) Same as createIndexAndAliasIfNecessary but with the first concrete index number specified. -
createSystemIndexIfNecessary
public static void createSystemIndexIfNecessary(Client client, ClusterState clusterState, SystemIndexDescriptor descriptor, org.elasticsearch.core.TimeValue masterNodeTimeout, ActionListener<Boolean> finalListener) -
updateWriteAlias
-
installIndexTemplateIfRequired
public static void installIndexTemplateIfRequired(ClusterState clusterState, Client client, IndexTemplateConfig templateConfig, org.elasticsearch.core.TimeValue masterTimeout, ActionListener<Boolean> listener) Installs the index template specified bytemplateConfigif it is not in already installed inclusterState. The check for presence is simple and will return the listener on the calling thread if successful. If the template has to be installed an async call will be made.- Parameters:
clusterState- The cluster stateclient- For putting the templatetemplateConfig- The configlistener- Async listener
-
installIndexTemplateIfRequired
public static void installIndexTemplateIfRequired(ClusterState clusterState, Client client, int templateVersion, TransportPutComposableIndexTemplateAction.Request templateRequest, ActionListener<Boolean> listener) SeeinstallIndexTemplateIfRequired(ClusterState, Client, IndexTemplateConfig, TimeValue, ActionListener). Overload takes aPutIndexTemplateRequestinstead ofIndexTemplateConfig- Parameters:
clusterState- The cluster stateclient- For putting the templatetemplateRequest- The Put template requestlistener- Async listener
-
hasIndexTemplate
-
has6DigitSuffix
-
latestIndex
Returns the latest index. Latest is the index with the highest 6 digit suffix.- Parameters:
concreteIndices- List of index names- Returns:
- The latest index by index name version suffix
-
indexIsReadWriteCompatibleInV9
True if the version is read *and* write compatible not just read only compatible
-