mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 07:37:19 -04:00
[7.16] Add replicated field to get data stream api response. (#81140)
* [7.16] Add replicated field to get data stream api response. Backporting #80988 to 7.16 branch. Internally we already kept track of whether a data stream is replicated by CCR. It is part of the `DataStream` class. This just adds it to the xcontent serialization of the get data stream api response class. Relates to elastic/kibana#118899 * adjust to 7.16 reality
This commit is contained in:
parent
af5fa3f649
commit
deb0d4c8c7
5 changed files with 34 additions and 9 deletions
|
@ -34,6 +34,7 @@ public final class DataStream {
|
|||
String ilmPolicyName;
|
||||
@Nullable
|
||||
private final Map<String, Object> metadata;
|
||||
private final boolean replicated;
|
||||
|
||||
public DataStream(
|
||||
String name,
|
||||
|
@ -45,7 +46,8 @@ public final class DataStream {
|
|||
@Nullable String ilmPolicyName,
|
||||
@Nullable Map<String, Object> metadata,
|
||||
boolean hidden,
|
||||
boolean system
|
||||
boolean system,
|
||||
boolean replicated
|
||||
) {
|
||||
this.name = name;
|
||||
this.timeStampField = timeStampField;
|
||||
|
@ -57,6 +59,7 @@ public final class DataStream {
|
|||
this.metadata = metadata;
|
||||
this.hidden = hidden;
|
||||
this.system = system;
|
||||
this.replicated = replicated;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -99,6 +102,10 @@ public final class DataStream {
|
|||
return system;
|
||||
}
|
||||
|
||||
public boolean isReplicated() {
|
||||
return replicated;
|
||||
}
|
||||
|
||||
public static final ParseField NAME_FIELD = new ParseField("name");
|
||||
public static final ParseField TIMESTAMP_FIELD_FIELD = new ParseField("timestamp_field");
|
||||
public static final ParseField INDICES_FIELD = new ParseField("indices");
|
||||
|
@ -109,6 +116,7 @@ public final class DataStream {
|
|||
public static final ParseField METADATA_FIELD = new ParseField("_meta");
|
||||
public static final ParseField HIDDEN_FIELD = new ParseField("hidden");
|
||||
public static final ParseField SYSTEM_FIELD = new ParseField("system");
|
||||
public static final ParseField REPLICATED = new ParseField("replicated");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final ConstructingObjectParser<DataStream, Void> PARSER = new ConstructingObjectParser<>("data_stream", args -> {
|
||||
|
@ -123,6 +131,7 @@ public final class DataStream {
|
|||
Map<String, Object> metadata = (Map<String, Object>) args[7];
|
||||
boolean hidden = args[8] != null && (boolean) args[8];
|
||||
boolean system = args[9] != null && (boolean) args[9];
|
||||
boolean replicated = args[10] != null && (boolean) args[10];
|
||||
return new DataStream(
|
||||
dataStreamName,
|
||||
timeStampField,
|
||||
|
@ -133,7 +142,8 @@ public final class DataStream {
|
|||
ilmPolicy,
|
||||
metadata,
|
||||
hidden,
|
||||
system
|
||||
system,
|
||||
replicated
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -148,6 +158,7 @@ public final class DataStream {
|
|||
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), (p, c) -> p.map(), METADATA_FIELD);
|
||||
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), HIDDEN_FIELD);
|
||||
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), SYSTEM_FIELD);
|
||||
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), REPLICATED);
|
||||
}
|
||||
|
||||
public static DataStream fromXContent(XContentParser parser) throws IOException {
|
||||
|
@ -168,7 +179,8 @@ public final class DataStream {
|
|||
&& system == that.system
|
||||
&& Objects.equals(indexTemplate, that.indexTemplate)
|
||||
&& Objects.equals(ilmPolicyName, that.ilmPolicyName)
|
||||
&& Objects.equals(metadata, that.metadata);
|
||||
&& Objects.equals(metadata, that.metadata)
|
||||
&& replicated == that.replicated;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,7 +195,8 @@ public final class DataStream {
|
|||
ilmPolicyName,
|
||||
metadata,
|
||||
hidden,
|
||||
system
|
||||
system,
|
||||
replicated
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -577,7 +577,8 @@ stream's oldest backing index.
|
|||
"status": "GREEN",
|
||||
"template": "my-data-stream-template",
|
||||
"hidden": false,
|
||||
"system": false
|
||||
"system": false,
|
||||
"replicated": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -207,6 +207,11 @@ use the <<indices-get-settings,get index settings API>>.
|
|||
(Boolean)
|
||||
If `true`, the data stream is created and managed by an Elastic stack component
|
||||
and cannot be modified through normal user interaction.
|
||||
|
||||
`replicated`::
|
||||
(Boolean)
|
||||
If `true`, the data stream is created and managed by {ccr} and the local
|
||||
cluster can not write into this data stream or change its mappings.
|
||||
====
|
||||
|
||||
[[get-data-stream-api-example]]
|
||||
|
@ -246,7 +251,8 @@ The API returns the following response:
|
|||
"template": "my-index-template",
|
||||
"ilm_policy": "my-lifecycle-policy",
|
||||
"hidden": false,
|
||||
"system": false
|
||||
"system": false,
|
||||
"replicated": false
|
||||
},
|
||||
{
|
||||
"name": "my-data-stream-two",
|
||||
|
@ -267,7 +273,8 @@ The API returns the following response:
|
|||
"template": "my-index-template",
|
||||
"ilm_policy": "my-lifecycle-policy",
|
||||
"hidden": false,
|
||||
"system": false
|
||||
"system": false,
|
||||
"replicated": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|||
public static final ParseField ILM_POLICY_FIELD = new ParseField("ilm_policy");
|
||||
public static final ParseField HIDDEN_FIELD = new ParseField("hidden");
|
||||
public static final ParseField SYSTEM_FIELD = new ParseField("system");
|
||||
public static final ParseField REPLICATED = new ParseField("replicated");
|
||||
|
||||
DataStream dataStream;
|
||||
ClusterHealthStatus dataStreamStatus;
|
||||
|
@ -192,6 +193,7 @@ public class GetDataStreamAction extends ActionType<GetDataStreamAction.Response
|
|||
}
|
||||
builder.field(HIDDEN_FIELD.getPreferredName(), dataStream.isHidden());
|
||||
builder.field(SYSTEM_FIELD.getPreferredName(), dataStream.isSystem());
|
||||
builder.field(REPLICATED.getPreferredName(), dataStream.isReplicated());
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
|
|
@ -54,13 +54,15 @@ setup:
|
|||
- match: { data_streams.0.status: 'GREEN' }
|
||||
- match: { data_streams.0.template: 'my-template1' }
|
||||
- match: { data_streams.0.hidden: false }
|
||||
- match: { data_streams.0.replicated: false }
|
||||
- match: { data_streams.1.name: simple-data-stream2 }
|
||||
- match: { data_streams.1.timestamp_field.name: '@timestamp' }
|
||||
- match: { data_streams.0.generation: 1 }
|
||||
- match: { data_streams.1.generation: 1 }
|
||||
- length: { data_streams.1.indices: 1 }
|
||||
- match: { data_streams.1.indices.0.index_name: '/\.ds-simple-data-stream2-(\d{4}\.\d{2}\.\d{2}-)?000001/' }
|
||||
- match: { data_streams.1.template: 'my-template2' }
|
||||
- match: { data_streams.0.hidden: false }
|
||||
- match: { data_streams.1.hidden: false }
|
||||
- match: { data_streams.1.replicated: false }
|
||||
|
||||
# save the backing index names for later use
|
||||
- set: { data_streams.0.indices.0.index_name: idx0name }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue