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
1 change: 1 addition & 0 deletions x-pack/plugin/deprecation/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
requires org.apache.logging.log4j;
requires org.apache.logging.log4j.core;
requires log4j2.ecs.layout;
requires org.apache.lucene.core;

exports org.elasticsearch.xpack.deprecation to org.elasticsearch.server;
exports org.elasticsearch.xpack.deprecation.logging to org.elasticsearch.server;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.deprecation;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.common.TriConsumer;
import org.elasticsearch.xcontent.NamedXContentRegistry;
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
import org.elasticsearch.xpack.core.transform.transforms.TransformConfig;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
* Cluster-specific deprecation checks, this is used to populate the {@code cluster_settings} field
*/
public class ClusterDeprecationChecker {

private static final Logger logger = LogManager.getLogger(ClusterDeprecationChecker.class);
private final List<TriConsumer<ClusterState, List<TransformConfig>, List<DeprecationIssue>>> CHECKS = List.of(
this::checkTransformSettings
);
private final NamedXContentRegistry xContentRegistry;

ClusterDeprecationChecker(NamedXContentRegistry xContentRegistry) {
this.xContentRegistry = xContentRegistry;
}

public List<DeprecationIssue> check(ClusterState clusterState, List<TransformConfig> transformConfigs) {
List<DeprecationIssue> allIssues = new ArrayList<>();
CHECKS.forEach(check -> check.apply(clusterState, transformConfigs, allIssues));
return allIssues;
}

private void checkTransformSettings(
ClusterState clusterState,
List<TransformConfig> transformConfigs,
List<DeprecationIssue> allIssues
) {
for (var config : transformConfigs) {
try {
allIssues.addAll(config.checkForDeprecations(xContentRegistry));
} catch (IOException e) {
logger.warn("failed to check transformation settings for '" + config.getId() + "'", e);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.stream.Collectors;

import static java.util.Map.entry;
import static java.util.Map.ofEntries;
import static org.elasticsearch.xpack.deprecation.DeprecationInfoAction.filterChecks;

/**
* Checks the data streams for deprecation warnings.
Expand All @@ -44,10 +44,24 @@ public DataStreamDeprecationChecker(IndexNameExpressionResolver indexNameExpress

/**
* @param clusterState The cluster state provided for the checker
* @param request not used yet in these checks
* @param precomputedData not used yet in these checks
* @return the name of the data streams that have violated the checks with their respective warnings.
*/
@Override
public Map<String, List<DeprecationIssue>> check(ClusterState clusterState, DeprecationInfoAction.Request request) {
public Map<String, List<DeprecationIssue>> check(
ClusterState clusterState,
DeprecationInfoAction.Request request,
TransportDeprecationInfoAction.PrecomputedData precomputedData
) {
return check(clusterState);
}

/**
* @param clusterState The cluster state provided for the checker
* @return the name of the data streams that have violated the checks with their respective warnings.
*/
public Map<String, List<DeprecationIssue>> check(ClusterState clusterState) {
List<String> dataStreamNames = indexNameExpressionResolver.dataStreamNames(
clusterState,
IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN
Expand All @@ -58,7 +72,10 @@ public Map<String, List<DeprecationIssue>> check(ClusterState clusterState, Depr
Map<String, List<DeprecationIssue>> dataStreamIssues = new HashMap<>();
for (String dataStreamName : dataStreamNames) {
DataStream dataStream = clusterState.metadata().dataStreams().get(dataStreamName);
List<DeprecationIssue> issuesForSingleDataStream = filterChecks(DATA_STREAM_CHECKS, c -> c.apply(dataStream, clusterState));
List<DeprecationIssue> issuesForSingleDataStream = DATA_STREAM_CHECKS.stream()
.map(c -> c.apply(dataStream, clusterState))
.filter(Objects::nonNull)
.toList();
if (issuesForSingleDataStream.isEmpty() == false) {
dataStreamIssues.put(dataStreamName, issuesForSingleDataStream);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.function.Predicate;
import java.util.function.Supplier;

import static org.elasticsearch.xpack.deprecation.DeprecationChecks.SKIP_DEPRECATIONS_SETTING;
import static org.elasticsearch.xpack.deprecation.TransportDeprecationInfoAction.SKIP_DEPRECATIONS_SETTING;
import static org.elasticsearch.xpack.deprecation.logging.DeprecationIndexingComponent.DEPRECATION_INDEXING_FLUSH_INTERVAL;

/**
Expand Down

This file was deleted.

Loading