[HLRC] Ignore unknown fields in responses of CCR APIs (#36821)
Otherwise hlrc fails if new fields are introduced in ccr api responses in future versions.
This commit is contained in:
parent
61b54196c4
commit
44acb016a6
|
@ -47,7 +47,9 @@ public final class AutoFollowStats {
|
||||||
static final ParseField LAST_SEEN_METADATA_VERSION = new ParseField("last_seen_metadata_version");
|
static final ParseField LAST_SEEN_METADATA_VERSION = new ParseField("last_seen_metadata_version");
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static final ConstructingObjectParser<AutoFollowStats, Void> STATS_PARSER = new ConstructingObjectParser<>("auto_follow_stats",
|
static final ConstructingObjectParser<AutoFollowStats, Void> STATS_PARSER = new ConstructingObjectParser<>(
|
||||||
|
"auto_follow_stats",
|
||||||
|
true,
|
||||||
args -> new AutoFollowStats(
|
args -> new AutoFollowStats(
|
||||||
(Long) args[0],
|
(Long) args[0],
|
||||||
(Long) args[1],
|
(Long) args[1],
|
||||||
|
@ -65,11 +67,13 @@ public final class AutoFollowStats {
|
||||||
static final ConstructingObjectParser<Map.Entry<String, Tuple<Long, ElasticsearchException>>, Void> AUTO_FOLLOW_EXCEPTIONS_PARSER =
|
static final ConstructingObjectParser<Map.Entry<String, Tuple<Long, ElasticsearchException>>, Void> AUTO_FOLLOW_EXCEPTIONS_PARSER =
|
||||||
new ConstructingObjectParser<>(
|
new ConstructingObjectParser<>(
|
||||||
"auto_follow_stats_errors",
|
"auto_follow_stats_errors",
|
||||||
|
true,
|
||||||
args -> new AbstractMap.SimpleEntry<>((String) args[0], Tuple.tuple((Long) args[1], (ElasticsearchException) args[2])));
|
args -> new AbstractMap.SimpleEntry<>((String) args[0], Tuple.tuple((Long) args[1], (ElasticsearchException) args[2])));
|
||||||
|
|
||||||
private static final ConstructingObjectParser<Map.Entry<String, AutoFollowedCluster>, Void> AUTO_FOLLOWED_CLUSTERS_PARSER =
|
private static final ConstructingObjectParser<Map.Entry<String, AutoFollowedCluster>, Void> AUTO_FOLLOWED_CLUSTERS_PARSER =
|
||||||
new ConstructingObjectParser<>(
|
new ConstructingObjectParser<>(
|
||||||
"auto_followed_clusters",
|
"auto_followed_clusters",
|
||||||
|
true,
|
||||||
args -> new AbstractMap.SimpleEntry<>((String) args[0], new AutoFollowedCluster((Long) args[1], (Long) args[2])));
|
args -> new AbstractMap.SimpleEntry<>((String) args[0], new AutoFollowedCluster((Long) args[1], (Long) args[2])));
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -28,7 +28,9 @@ public final class CcrStatsResponse {
|
||||||
static final ParseField AUTO_FOLLOW_STATS_FIELD = new ParseField("auto_follow_stats");
|
static final ParseField AUTO_FOLLOW_STATS_FIELD = new ParseField("auto_follow_stats");
|
||||||
static final ParseField FOLLOW_STATS_FIELD = new ParseField("follow_stats");
|
static final ParseField FOLLOW_STATS_FIELD = new ParseField("follow_stats");
|
||||||
|
|
||||||
private static final ConstructingObjectParser<CcrStatsResponse, Void> PARSER = new ConstructingObjectParser<>("indices",
|
private static final ConstructingObjectParser<CcrStatsResponse, Void> PARSER = new ConstructingObjectParser<>(
|
||||||
|
"indices",
|
||||||
|
true,
|
||||||
args -> {
|
args -> {
|
||||||
AutoFollowStats autoFollowStats = (AutoFollowStats) args[0];
|
AutoFollowStats autoFollowStats = (AutoFollowStats) args[0];
|
||||||
IndicesFollowStats indicesFollowStats = (IndicesFollowStats) args[1];
|
IndicesFollowStats indicesFollowStats = (IndicesFollowStats) args[1];
|
||||||
|
|
|
@ -42,7 +42,7 @@ public final class GetAutoFollowPatternResponse {
|
||||||
static final ParseField PATTERN_FIELD = new ParseField("pattern");
|
static final ParseField PATTERN_FIELD = new ParseField("pattern");
|
||||||
|
|
||||||
private static final ConstructingObjectParser<Map.Entry<String, Pattern>, Void> ENTRY_PARSER = new ConstructingObjectParser<>(
|
private static final ConstructingObjectParser<Map.Entry<String, Pattern>, Void> ENTRY_PARSER = new ConstructingObjectParser<>(
|
||||||
"get_auto_follow_pattern_response", args -> new AbstractMap.SimpleEntry<>((String) args[0], (Pattern) args[1]));
|
"get_auto_follow_pattern_response", true, args -> new AbstractMap.SimpleEntry<>((String) args[0], (Pattern) args[1]));
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ENTRY_PARSER.declareString(ConstructingObjectParser.constructorArg(), NAME_FIELD);
|
ENTRY_PARSER.declareString(ConstructingObjectParser.constructorArg(), NAME_FIELD);
|
||||||
|
@ -50,7 +50,7 @@ public final class GetAutoFollowPatternResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ConstructingObjectParser<GetAutoFollowPatternResponse, Void> PARSER = new ConstructingObjectParser<>(
|
private static final ConstructingObjectParser<GetAutoFollowPatternResponse, Void> PARSER = new ConstructingObjectParser<>(
|
||||||
"get_auto_follow_pattern_response", args -> {
|
"get_auto_follow_pattern_response", true, args -> {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Map.Entry<String, Pattern>> entries = (List<Map.Entry<String, Pattern>>) args[0];
|
List<Map.Entry<String, Pattern>> entries = (List<Map.Entry<String, Pattern>>) args[0];
|
||||||
return new GetAutoFollowPatternResponse(new TreeMap<>(entries.stream()
|
return new GetAutoFollowPatternResponse(new TreeMap<>(entries.stream()
|
||||||
|
@ -92,7 +92,7 @@ public final class GetAutoFollowPatternResponse {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static final ConstructingObjectParser<Pattern, Void> PARSER = new ConstructingObjectParser<>(
|
private static final ConstructingObjectParser<Pattern, Void> PARSER = new ConstructingObjectParser<>(
|
||||||
"pattern", args -> new Pattern((String) args[0], (List<String>) args[1], (String) args[2]));
|
"pattern", true, args -> new Pattern((String) args[0], (List<String>) args[1], (String) args[2]));
|
||||||
|
|
||||||
static {
|
static {
|
||||||
PARSER.declareString(ConstructingObjectParser.constructorArg(), PutFollowRequest.REMOTE_CLUSTER_FIELD);
|
PARSER.declareString(ConstructingObjectParser.constructorArg(), PutFollowRequest.REMOTE_CLUSTER_FIELD);
|
||||||
|
|
|
@ -41,6 +41,7 @@ public final class IndicesFollowStats {
|
||||||
private static final ConstructingObjectParser<Tuple<String, List<ShardFollowStats>>, Void> ENTRY_PARSER =
|
private static final ConstructingObjectParser<Tuple<String, List<ShardFollowStats>>, Void> ENTRY_PARSER =
|
||||||
new ConstructingObjectParser<>(
|
new ConstructingObjectParser<>(
|
||||||
"entry",
|
"entry",
|
||||||
|
true,
|
||||||
args -> {
|
args -> {
|
||||||
String index = (String) args[0];
|
String index = (String) args[0];
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -54,7 +55,9 @@ public final class IndicesFollowStats {
|
||||||
ENTRY_PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), ShardFollowStats.PARSER, SHARDS_FIELD);
|
ENTRY_PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), ShardFollowStats.PARSER, SHARDS_FIELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static final ConstructingObjectParser<IndicesFollowStats, Void> PARSER = new ConstructingObjectParser<>("indices",
|
static final ConstructingObjectParser<IndicesFollowStats, Void> PARSER = new ConstructingObjectParser<>(
|
||||||
|
"indices",
|
||||||
|
true,
|
||||||
args -> {
|
args -> {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Tuple<String, List<ShardFollowStats>>> entries = (List<Tuple<String, List<ShardFollowStats>>>) args[0];
|
List<Tuple<String, List<ShardFollowStats>>> entries = (List<Tuple<String, List<ShardFollowStats>>>) args[0];
|
||||||
|
@ -116,6 +119,7 @@ public final class IndicesFollowStats {
|
||||||
static final ConstructingObjectParser<ShardFollowStats, Void> PARSER =
|
static final ConstructingObjectParser<ShardFollowStats, Void> PARSER =
|
||||||
new ConstructingObjectParser<>(
|
new ConstructingObjectParser<>(
|
||||||
"shard-follow-stats",
|
"shard-follow-stats",
|
||||||
|
true,
|
||||||
args -> new ShardFollowStats(
|
args -> new ShardFollowStats(
|
||||||
(String) args[0],
|
(String) args[0],
|
||||||
(String) args[1],
|
(String) args[1],
|
||||||
|
@ -152,6 +156,7 @@ public final class IndicesFollowStats {
|
||||||
static final ConstructingObjectParser<Map.Entry<Long, Tuple<Integer, ElasticsearchException>>, Void> READ_EXCEPTIONS_ENTRY_PARSER =
|
static final ConstructingObjectParser<Map.Entry<Long, Tuple<Integer, ElasticsearchException>>, Void> READ_EXCEPTIONS_ENTRY_PARSER =
|
||||||
new ConstructingObjectParser<>(
|
new ConstructingObjectParser<>(
|
||||||
"shard-follow-stats-read-exceptions-entry",
|
"shard-follow-stats-read-exceptions-entry",
|
||||||
|
true,
|
||||||
args -> new AbstractMap.SimpleEntry<>((long) args[0], Tuple.tuple((Integer) args[1], (ElasticsearchException)args[2])));
|
args -> new AbstractMap.SimpleEntry<>((long) args[0], Tuple.tuple((Integer) args[1], (ElasticsearchException)args[2])));
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -33,7 +33,7 @@ public final class PutFollowResponse {
|
||||||
static final ParseField INDEX_FOLLOWING_STARTED = new ParseField("index_following_started");
|
static final ParseField INDEX_FOLLOWING_STARTED = new ParseField("index_following_started");
|
||||||
|
|
||||||
private static final ConstructingObjectParser<PutFollowResponse, Void> PARSER = new ConstructingObjectParser<>(
|
private static final ConstructingObjectParser<PutFollowResponse, Void> PARSER = new ConstructingObjectParser<>(
|
||||||
"put_follow_response", args -> new PutFollowResponse((boolean) args[0], (boolean) args[1], (boolean) args[2]));
|
"put_follow_response", true, args -> new PutFollowResponse((boolean) args[0], (boolean) args[1], (boolean) args[2]));
|
||||||
|
|
||||||
static {
|
static {
|
||||||
PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), FOLLOW_INDEX_CREATED);
|
PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), FOLLOW_INDEX_CREATED);
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class CcrStatsResponseTests extends ESTestCase {
|
||||||
CcrStatsResponseTests::createTestInstance,
|
CcrStatsResponseTests::createTestInstance,
|
||||||
CcrStatsResponseTests::toXContent,
|
CcrStatsResponseTests::toXContent,
|
||||||
CcrStatsResponse::fromXContent)
|
CcrStatsResponse::fromXContent)
|
||||||
.supportsUnknownFields(false)
|
.supportsUnknownFields(true)
|
||||||
.assertEqualsConsumer(CcrStatsResponseTests::assertEqualInstances)
|
.assertEqualsConsumer(CcrStatsResponseTests::assertEqualInstances)
|
||||||
.assertToXContentEquivalence(false)
|
.assertToXContentEquivalence(false)
|
||||||
.test();
|
.test();
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class FollowStatsResponseTests extends ESTestCase {
|
||||||
FollowStatsResponseTests::createTestInstance,
|
FollowStatsResponseTests::createTestInstance,
|
||||||
FollowStatsResponseTests::toXContent,
|
FollowStatsResponseTests::toXContent,
|
||||||
FollowStatsResponse::fromXContent)
|
FollowStatsResponse::fromXContent)
|
||||||
.supportsUnknownFields(false)
|
.supportsUnknownFields(true)
|
||||||
.assertEqualsConsumer(FollowStatsResponseTests::assertEqualInstances)
|
.assertEqualsConsumer(FollowStatsResponseTests::assertEqualInstances)
|
||||||
.assertToXContentEquivalence(false)
|
.assertToXContentEquivalence(false)
|
||||||
.test();
|
.test();
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class GetAutoFollowPatternResponseTests extends ESTestCase {
|
||||||
this::createTestInstance,
|
this::createTestInstance,
|
||||||
GetAutoFollowPatternResponseTests::toXContent,
|
GetAutoFollowPatternResponseTests::toXContent,
|
||||||
GetAutoFollowPatternResponse::fromXContent)
|
GetAutoFollowPatternResponse::fromXContent)
|
||||||
.supportsUnknownFields(false)
|
.supportsUnknownFields(true)
|
||||||
.test();
|
.test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ import java.io.IOException;
|
||||||
public class PutFollowRequestTests extends AbstractXContentTestCase<PutFollowRequest> {
|
public class PutFollowRequestTests extends AbstractXContentTestCase<PutFollowRequest> {
|
||||||
|
|
||||||
private static final ConstructingObjectParser<PutFollowRequest, Void> PARSER = new ConstructingObjectParser<>("test_parser",
|
private static final ConstructingObjectParser<PutFollowRequest, Void> PARSER = new ConstructingObjectParser<>("test_parser",
|
||||||
(args) -> new PutFollowRequest((String) args[0], (String) args[1], (String) args[2]));
|
true, (args) -> new PutFollowRequest((String) args[0], (String) args[1], (String) args[2]));
|
||||||
|
|
||||||
static {
|
static {
|
||||||
PARSER.declareString(ConstructingObjectParser.constructorArg(), PutFollowRequest.REMOTE_CLUSTER_FIELD);
|
PARSER.declareString(ConstructingObjectParser.constructorArg(), PutFollowRequest.REMOTE_CLUSTER_FIELD);
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class PutFollowResponseTests extends ESTestCase {
|
||||||
this::createTestInstance,
|
this::createTestInstance,
|
||||||
PutFollowResponseTests::toXContent,
|
PutFollowResponseTests::toXContent,
|
||||||
PutFollowResponse::fromXContent)
|
PutFollowResponse::fromXContent)
|
||||||
.supportsUnknownFields(false)
|
.supportsUnknownFields(true)
|
||||||
.test();
|
.test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue