Adding ml_settings entry to HLRC and Docs for deprecation_info (#38118)
This commit is contained in:
parent
f64b20383e
commit
a70f54fc77
|
@ -37,16 +37,19 @@ public class DeprecationInfoResponse {
|
|||
private static final ParseField CLUSTER_SETTINGS = new ParseField("cluster_settings");
|
||||
private static final ParseField NODE_SETTINGS = new ParseField("node_settings");
|
||||
private static final ParseField INDEX_SETTINGS = new ParseField("index_settings");
|
||||
private static final ParseField ML_SETTINGS = new ParseField("ml_settings");
|
||||
|
||||
private final List<DeprecationIssue> clusterSettingsIssues;
|
||||
private final List<DeprecationIssue> nodeSettingsIssues;
|
||||
private final Map<String, List<DeprecationIssue>> indexSettingsIssues;
|
||||
private final List<DeprecationIssue> mlSettingsIssues;
|
||||
|
||||
public DeprecationInfoResponse(List<DeprecationIssue> clusterSettingsIssues, List<DeprecationIssue> nodeSettingsIssues,
|
||||
Map<String, List<DeprecationIssue>> indexSettingsIssues) {
|
||||
Map<String, List<DeprecationIssue>> indexSettingsIssues, List<DeprecationIssue> mlSettingsIssues) {
|
||||
this.clusterSettingsIssues = Objects.requireNonNull(clusterSettingsIssues, "cluster settings issues cannot be null");
|
||||
this.nodeSettingsIssues = Objects.requireNonNull(nodeSettingsIssues, "node settings issues cannot be null");
|
||||
this.indexSettingsIssues = Objects.requireNonNull(indexSettingsIssues, "index settings issues cannot be null");
|
||||
this.mlSettingsIssues = Objects.requireNonNull(mlSettingsIssues, "ml settings issues cannot be null");
|
||||
}
|
||||
|
||||
public List<DeprecationIssue> getClusterSettingsIssues() {
|
||||
|
@ -61,6 +64,10 @@ public class DeprecationInfoResponse {
|
|||
return indexSettingsIssues;
|
||||
}
|
||||
|
||||
public List<DeprecationIssue> getMlSettingsIssues() {
|
||||
return mlSettingsIssues;
|
||||
}
|
||||
|
||||
private static List<DeprecationIssue> parseDeprecationIssues(XContentParser parser) throws IOException {
|
||||
List<DeprecationIssue> issues = new ArrayList<>();
|
||||
XContentParser.Token token = null;
|
||||
|
@ -76,6 +83,7 @@ public class DeprecationInfoResponse {
|
|||
Map<String, List<DeprecationIssue>> indexSettings = new HashMap<>();
|
||||
List<DeprecationIssue> clusterSettings = new ArrayList<>();
|
||||
List<DeprecationIssue> nodeSettings = new ArrayList<>();
|
||||
List<DeprecationIssue> mlSettings = new ArrayList<>();
|
||||
String fieldName = null;
|
||||
XContentParser.Token token;
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
|
@ -85,6 +93,8 @@ public class DeprecationInfoResponse {
|
|||
clusterSettings.addAll(parseDeprecationIssues(parser));
|
||||
} else if (NODE_SETTINGS.getPreferredName().equals(fieldName)) {
|
||||
nodeSettings.addAll(parseDeprecationIssues(parser));
|
||||
} else if (ML_SETTINGS.getPreferredName().equals(fieldName)) {
|
||||
mlSettings.addAll(parseDeprecationIssues(parser));
|
||||
} else if (INDEX_SETTINGS.getPreferredName().equals(fieldName)) {
|
||||
// parse out the key/value pairs
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
|
@ -96,7 +106,7 @@ public class DeprecationInfoResponse {
|
|||
}
|
||||
}
|
||||
}
|
||||
return new DeprecationInfoResponse(clusterSettings, nodeSettings, indexSettings);
|
||||
return new DeprecationInfoResponse(clusterSettings, nodeSettings, indexSettings, mlSettings);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,17 +116,19 @@ public class DeprecationInfoResponse {
|
|||
DeprecationInfoResponse that = (DeprecationInfoResponse) o;
|
||||
return Objects.equals(clusterSettingsIssues, that.clusterSettingsIssues) &&
|
||||
Objects.equals(nodeSettingsIssues, that.nodeSettingsIssues) &&
|
||||
Objects.equals(mlSettingsIssues, that.mlSettingsIssues) &&
|
||||
Objects.equals(indexSettingsIssues, that.indexSettingsIssues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(clusterSettingsIssues, nodeSettingsIssues, indexSettingsIssues);
|
||||
return Objects.hash(clusterSettingsIssues, nodeSettingsIssues, indexSettingsIssues, mlSettingsIssues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return clusterSettingsIssues.toString() + ":" + nodeSettingsIssues.toString() + ":" + indexSettingsIssues.toString();
|
||||
return clusterSettingsIssues.toString() + ":" + nodeSettingsIssues.toString() + ":" + indexSettingsIssues.toString() +
|
||||
":" + mlSettingsIssues.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -85,6 +85,7 @@ public class MigrationIT extends ESRestHighLevelClientTestCase {
|
|||
assertThat(response.getClusterSettingsIssues().size(), equalTo(0));
|
||||
assertThat(response.getIndexSettingsIssues().size(), equalTo(0));
|
||||
assertThat(response.getNodeSettingsIssues().size(), equalTo(0));
|
||||
assertThat(response.getMlSettingsIssues().size(), equalTo(0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -182,6 +182,8 @@ public class MigrationClientDocumentationIT extends ESRestHighLevelClientTestCas
|
|||
deprecationInfoResponse.getNodeSettingsIssues(); // <2>
|
||||
Map<String, List<DeprecationInfoResponse.DeprecationIssue>> indexIssues =
|
||||
deprecationInfoResponse.getIndexSettingsIssues(); // <3>
|
||||
List<DeprecationInfoResponse.DeprecationIssue> mlIssues =
|
||||
deprecationInfoResponse.getMlSettingsIssues(); // <4>
|
||||
// end::get-deprecation-info-response
|
||||
|
||||
// tag::get-deprecation-info-execute-listener
|
||||
|
@ -195,6 +197,8 @@ public class MigrationClientDocumentationIT extends ESRestHighLevelClientTestCas
|
|||
deprecationInfoResponse.getNodeSettingsIssues();
|
||||
Map<String, List<DeprecationInfoResponse.DeprecationIssue>> indexIssues =
|
||||
deprecationInfoResponse.getIndexSettingsIssues();
|
||||
List<DeprecationInfoResponse.DeprecationIssue> mlIssues =
|
||||
deprecationInfoResponse.getMlSettingsIssues();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -65,6 +65,12 @@ public class DeprecationInfoResponseTests extends ESTestCase {
|
|||
}
|
||||
}
|
||||
builder.endObject();
|
||||
|
||||
builder.startArray("ml_settings");
|
||||
for (DeprecationInfoResponse.DeprecationIssue issue : response.getMlSettingsIssues()) {
|
||||
toXContent(issue, builder);
|
||||
}
|
||||
builder.endArray();
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
|
@ -105,12 +111,14 @@ public class DeprecationInfoResponseTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private DeprecationInfoResponse createInstance() {
|
||||
return new DeprecationInfoResponse(createRandomIssues(true), createRandomIssues(true), createIndexSettingsIssues());
|
||||
return new DeprecationInfoResponse(createRandomIssues(true), createRandomIssues(true), createIndexSettingsIssues(),
|
||||
createRandomIssues(true));
|
||||
}
|
||||
|
||||
private DeprecationInfoResponse copyInstance(DeprecationInfoResponse req) {
|
||||
return new DeprecationInfoResponse(new ArrayList<>(req.getClusterSettingsIssues()),
|
||||
new ArrayList<>(req.getNodeSettingsIssues()), new HashMap<>(req.getIndexSettingsIssues()));
|
||||
new ArrayList<>(req.getNodeSettingsIssues()), new HashMap<>(req.getIndexSettingsIssues()),
|
||||
new ArrayList<>(req.getMlSettingsIssues()));
|
||||
}
|
||||
|
||||
private DeprecationInfoResponse mutateInstance(DeprecationInfoResponse req) {
|
||||
|
@ -128,16 +136,21 @@ public class DeprecationInfoResponseTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testNullFailedIndices() {
|
||||
NullPointerException exception =
|
||||
expectThrows(NullPointerException.class, () -> new DeprecationInfoResponse(null, null, null));
|
||||
NullPointerException exception = expectThrows(NullPointerException.class,
|
||||
() -> new DeprecationInfoResponse(null, null, null, null));
|
||||
assertEquals("cluster settings issues cannot be null", exception.getMessage());
|
||||
|
||||
exception = expectThrows(NullPointerException.class, () -> new DeprecationInfoResponse(Collections.emptyList(), null, null));
|
||||
exception = expectThrows(NullPointerException.class,
|
||||
() -> new DeprecationInfoResponse(Collections.emptyList(), null, null, null));
|
||||
assertEquals("node settings issues cannot be null", exception.getMessage());
|
||||
|
||||
exception = expectThrows(NullPointerException.class,
|
||||
() -> new DeprecationInfoResponse(Collections.emptyList(), Collections.emptyList(), null));
|
||||
() -> new DeprecationInfoResponse(Collections.emptyList(), Collections.emptyList(), null, null));
|
||||
assertEquals("index settings issues cannot be null", exception.getMessage());
|
||||
|
||||
exception = expectThrows(NullPointerException.class,
|
||||
() -> new DeprecationInfoResponse(Collections.emptyList(), Collections.emptyList(), Collections.emptyMap(), null));
|
||||
assertEquals("ml settings issues cannot be null", exception.getMessage());
|
||||
}
|
||||
|
||||
public void testEqualsAndHashCode() {
|
||||
|
|
|
@ -33,3 +33,4 @@ include-tagged::{doc-tests-file}[{api}-response]
|
|||
<1> a List of Cluster deprecations
|
||||
<2> a List of Node deprecations
|
||||
<3> a Map of key IndexName, value List of deprecations for the index
|
||||
<4> a list of Machine Learning related deprecations
|
||||
|
|
|
@ -68,7 +68,8 @@ Example response:
|
|||
"details" : "This index is named [logs:apache], which contains the illegal character ':'."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"ml_settings" : [ ]
|
||||
}
|
||||
--------------------------------------------------
|
||||
// NOTCONSOLE
|
||||
|
@ -109,7 +110,8 @@ key. Similarly, any node-level warnings are found under `node_settings`. Since
|
|||
only a select subset of your nodes might incorporate these settings, it is
|
||||
important to read the `details` section for more information about which nodes
|
||||
are affected. Index warnings are sectioned off per index and can be filtered
|
||||
using an index-pattern in the query.
|
||||
using an index-pattern in the query. Machine Learning related deprecation
|
||||
warnings can be found under the `ml_settings` key.
|
||||
|
||||
The following example request shows only index-level deprecations of all
|
||||
`logstash-*` indices:
|
||||
|
|
Loading…
Reference in New Issue