Skip to content

Commit e20fe6d

Browse files
authored
Add replicated field to get data stream api response. (#80988)
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
1 parent 2629c32 commit e20fe6d

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/indices/DataStream.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public final class DataStream {
3535
@Nullable
3636
private final Map<String, Object> metadata;
3737
private final boolean allowCustomRouting;
38+
private final boolean replicated;
3839

3940
public DataStream(
4041
String name,
@@ -47,7 +48,8 @@ public DataStream(
4748
@Nullable Map<String, Object> metadata,
4849
boolean hidden,
4950
boolean system,
50-
boolean allowCustomRouting
51+
boolean allowCustomRouting,
52+
boolean replicated
5153
) {
5254
this.name = name;
5355
this.timeStampField = timeStampField;
@@ -60,6 +62,7 @@ public DataStream(
6062
this.hidden = hidden;
6163
this.system = system;
6264
this.allowCustomRouting = allowCustomRouting;
65+
this.replicated = replicated;
6366
}
6467

6568
public String getName() {
@@ -106,6 +109,10 @@ public boolean allowsCustomRouting() {
106109
return allowCustomRouting;
107110
}
108111

112+
public boolean isReplicated() {
113+
return replicated;
114+
}
115+
109116
public static final ParseField NAME_FIELD = new ParseField("name");
110117
public static final ParseField TIMESTAMP_FIELD_FIELD = new ParseField("timestamp_field");
111118
public static final ParseField INDICES_FIELD = new ParseField("indices");
@@ -117,6 +124,7 @@ public boolean allowsCustomRouting() {
117124
public static final ParseField HIDDEN_FIELD = new ParseField("hidden");
118125
public static final ParseField SYSTEM_FIELD = new ParseField("system");
119126
public static final ParseField ALLOW_CUSTOM_ROUTING = new ParseField("allow_custom_routing");
127+
public static final ParseField REPLICATED = new ParseField("replicated");
120128

121129
@SuppressWarnings("unchecked")
122130
private static final ConstructingObjectParser<DataStream, Void> PARSER = new ConstructingObjectParser<>("data_stream", args -> {
@@ -132,6 +140,7 @@ public boolean allowsCustomRouting() {
132140
boolean hidden = args[8] != null && (boolean) args[8];
133141
boolean system = args[9] != null && (boolean) args[9];
134142
boolean allowCustomRouting = args[10] != null && (boolean) args[10];
143+
boolean replicated = args[11] != null && (boolean) args[11];
135144
return new DataStream(
136145
dataStreamName,
137146
timeStampField,
@@ -143,7 +152,8 @@ public boolean allowsCustomRouting() {
143152
metadata,
144153
hidden,
145154
system,
146-
allowCustomRouting
155+
allowCustomRouting,
156+
replicated
147157
);
148158
});
149159

@@ -159,6 +169,7 @@ public boolean allowsCustomRouting() {
159169
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), HIDDEN_FIELD);
160170
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), SYSTEM_FIELD);
161171
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), ALLOW_CUSTOM_ROUTING);
172+
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), REPLICATED);
162173
}
163174

164175
public static DataStream fromXContent(XContentParser parser) throws IOException {
@@ -180,7 +191,8 @@ public boolean equals(Object o) {
180191
&& Objects.equals(indexTemplate, that.indexTemplate)
181192
&& Objects.equals(ilmPolicyName, that.ilmPolicyName)
182193
&& Objects.equals(metadata, that.metadata)
183-
&& allowCustomRouting == that.allowCustomRouting;
194+
&& allowCustomRouting == that.allowCustomRouting
195+
&& replicated == that.replicated;
184196
}
185197

186198
@Override
@@ -196,7 +208,8 @@ public int hashCode() {
196208
metadata,
197209
hidden,
198210
system,
199-
allowCustomRouting
211+
allowCustomRouting,
212+
replicated
200213
);
201214
}
202215
}

docs/reference/data-streams/change-mappings-and-settings.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,8 @@ stream's oldest backing index.
578578
"template": "my-data-stream-template",
579579
"hidden": false,
580580
"system": false,
581-
"allow_custom_routing": false
581+
"allow_custom_routing": false,
582+
"replicated": false
582583
}
583584
]
584585
}

docs/reference/indices/get-data-stream.asciidoc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,15 @@ use the <<indices-get-settings,get index settings API>>.
207207
(Boolean)
208208
If `true`, the data stream is created and managed by an Elastic stack component
209209
and cannot be modified through normal user interaction.
210+
211+
`allow_custom_routing`::
212+
(Boolean)
213+
If `true`, the data stream this data stream allows custom routing on write request.
214+
215+
`replicated`::
216+
(Boolean)
217+
If `true`, the data stream is created and managed by {ccr} and the local
218+
cluster can not write into this data stream or change its mappings.
210219
====
211220

212221
[[get-data-stream-api-example]]
@@ -247,7 +256,8 @@ The API returns the following response:
247256
"ilm_policy": "my-lifecycle-policy",
248257
"hidden": false,
249258
"system": false,
250-
"allow_custom_routing": false
259+
"allow_custom_routing": false,
260+
"replicated": false
251261
},
252262
{
253263
"name": "my-data-stream-two",
@@ -269,7 +279,8 @@ The API returns the following response:
269279
"ilm_policy": "my-lifecycle-policy",
270280
"hidden": false,
271281
"system": false,
272-
"allow_custom_routing": false
282+
"allow_custom_routing": false,
283+
"replicated": false
273284
}
274285
]
275286
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/GetDataStreamAction.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public static class DataStreamInfo extends AbstractDiffable<DataStreamInfo> impl
120120
public static final ParseField HIDDEN_FIELD = new ParseField("hidden");
121121
public static final ParseField SYSTEM_FIELD = new ParseField("system");
122122
public static final ParseField ALLOW_CUSTOM_ROUTING = new ParseField("allow_custom_routing");
123+
public static final ParseField REPLICATED = new ParseField("replicated");
123124

124125
DataStream dataStream;
125126
ClusterHealthStatus dataStreamStatus;
@@ -190,6 +191,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
190191
builder.field(HIDDEN_FIELD.getPreferredName(), dataStream.isHidden());
191192
builder.field(SYSTEM_FIELD.getPreferredName(), dataStream.isSystem());
192193
builder.field(ALLOW_CUSTOM_ROUTING.getPreferredName(), dataStream.isAllowCustomRouting());
194+
builder.field(REPLICATED.getPreferredName(), dataStream.isReplicated());
193195
builder.endObject();
194196
return builder;
195197
}

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/data_stream/10_basic.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ setup:
5454
- match: { data_streams.0.status: 'GREEN' }
5555
- match: { data_streams.0.template: 'my-template1' }
5656
- match: { data_streams.0.hidden: false }
57+
- match: { data_streams.0.replicated: false }
5758
- match: { data_streams.1.name: simple-data-stream2 }
5859
- match: { data_streams.1.timestamp_field.name: '@timestamp' }
59-
- match: { data_streams.0.generation: 1 }
60+
- match: { data_streams.1.generation: 1 }
6061
- length: { data_streams.1.indices: 1 }
6162
- match: { data_streams.1.indices.0.index_name: '/\.ds-simple-data-stream2-(\d{4}\.\d{2}\.\d{2}-)?000001/' }
6263
- match: { data_streams.1.template: 'my-template2' }
63-
- match: { data_streams.0.hidden: false }
64+
- match: { data_streams.1.hidden: false }
65+
- match: { data_streams.1.replicated: false }
6466

6567
# save the backing index names for later use
6668
- set: { data_streams.0.indices.0.index_name: idx0name }

0 commit comments

Comments
 (0)