Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,10 @@ public static boolean checkTemplateExistsAndVersionIsGTECurrentVersion(String te
* @param templateName Name of the index template
* @param state Cluster state
* @param logger Logger
* @param versionComposableTemplateExpected In which version of Elasticsearch did this template switch to being a composable template?
* <code>null</code> means the template hasn't been switched yet.
*/
public static boolean checkTemplateExistsAndIsUpToDate(
String templateName,
String versionKey,
ClusterState state,
Logger logger,
Version versionComposableTemplateExpected
) {
public static boolean checkTemplateExistsAndIsUpToDate(String templateName, String versionKey, ClusterState state, Logger logger) {

return checkTemplateExistsAndVersionMatches(
templateName,
versionKey,
state,
logger,
Version.CURRENT::equals,
versionComposableTemplateExpected
);
return checkTemplateExistsAndVersionMatches(templateName, versionKey, state, logger, Version.CURRENT::equals);
}

/**
Expand All @@ -162,32 +147,20 @@ public static boolean checkTemplateExistsAndIsUpToDate(
* @param state Cluster state
* @param logger Logger
* @param predicate Predicate to execute on version check
* @param versionComposableTemplateExpected In which version of Elasticsearch did this template switch to being a composable template?
* <code>null</code> means the template hasn't been switched yet.
*/
public static boolean checkTemplateExistsAndVersionMatches(
String templateName,
String versionKey,
ClusterState state,
Logger logger,
Predicate<Version> predicate,
Version versionComposableTemplateExpected
Predicate<Version> predicate
) {

CompressedXContent mappings;
if (versionComposableTemplateExpected != null && state.nodes().getMinNodeVersion().onOrAfter(versionComposableTemplateExpected)) {
ComposableIndexTemplate templateMeta = state.metadata().templatesV2().get(templateName);
if (templateMeta == null) {
return false;
}
mappings = templateMeta.template().mappings();
} else {
IndexTemplateMetadata templateMeta = state.metadata().templates().get(templateName);
if (templateMeta == null) {
return false;
}
mappings = templateMeta.getMappings();
IndexTemplateMetadata templateMeta = state.metadata().templates().get(templateName);
if (templateMeta == null) {
return false;
}
CompressedXContent mappings = templateMeta.getMappings();

// check all mappings contain correct version in _meta
// we have to parse the source here which is annoying
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void installIndexTemplate(ActionListener<Boolean> listener) {
}

private boolean isTemplateUpToDate(ClusterState state) {
return TemplateUtils.checkTemplateExistsAndIsUpToDate(TEMPLATE_NAME, TEMPLATE_META_VERSION_KEY, state, logger, null);
return TemplateUtils.checkTemplateExistsAndIsUpToDate(TEMPLATE_NAME, TEMPLATE_META_VERSION_KEY, state, logger);
}

public void deleteDocument(DocumentVersion version, WriteRequest.RefreshPolicy refreshPolicy, ActionListener<DeleteResponse> listener) {
Expand Down