@@ -112,7 +112,7 @@ public static boolean isFailureStoreFeatureFlagEnabled() {
112112 private final IndexMode indexMode ;
113113 @ Nullable
114114 private final DataStreamLifecycle lifecycle ;
115- private final boolean failureStoreEnabled ;
115+ private final DataStreamOptions dataStreamOptions ;
116116
117117 private final DataStreamIndices backingIndices ;
118118 private final DataStreamIndices failureIndices ;
@@ -128,7 +128,7 @@ public DataStream(
128128 boolean allowCustomRouting ,
129129 IndexMode indexMode ,
130130 DataStreamLifecycle lifecycle ,
131- boolean failureStoreEnabled ,
131+ @ Nullable DataStreamOptions dataStreamOptions ,
132132 List <Index > failureIndices ,
133133 boolean rolloverOnWrite ,
134134 @ Nullable DataStreamAutoShardingEvent autoShardingEvent
@@ -144,7 +144,7 @@ public DataStream(
144144 allowCustomRouting ,
145145 indexMode ,
146146 lifecycle ,
147- failureStoreEnabled ,
147+ dataStreamOptions ,
148148 new DataStreamIndices (BACKING_INDEX_PREFIX , List .copyOf (indices ), rolloverOnWrite , autoShardingEvent ),
149149 new DataStreamIndices (FAILURE_STORE_PREFIX , List .copyOf (failureIndices ), false , null )
150150 );
@@ -162,7 +162,7 @@ public DataStream(
162162 boolean allowCustomRouting ,
163163 IndexMode indexMode ,
164164 DataStreamLifecycle lifecycle ,
165- boolean failureStoreEnabled ,
165+ DataStreamOptions dataStreamOptions ,
166166 DataStreamIndices backingIndices ,
167167 DataStreamIndices failureIndices
168168 ) {
@@ -177,7 +177,7 @@ public DataStream(
177177 this .allowCustomRouting = allowCustomRouting ;
178178 this .indexMode = indexMode ;
179179 this .lifecycle = lifecycle ;
180- this .failureStoreEnabled = failureStoreEnabled ;
180+ this .dataStreamOptions = dataStreamOptions == null ? DataStreamOptions . EMPTY : dataStreamOptions ;
181181 assert backingIndices .indices .isEmpty () == false ;
182182 assert replicated == false || (backingIndices .rolloverOnWrite == false && failureIndices .rolloverOnWrite == false )
183183 : "replicated data streams cannot be marked for lazy rollover" ;
@@ -198,9 +198,11 @@ public static DataStream read(StreamInput in) throws IOException {
198198 var lifecycle = in .getTransportVersion ().onOrAfter (TransportVersions .V_8_9_X )
199199 ? in .readOptionalWriteable (DataStreamLifecycle ::new )
200200 : null ;
201- var failureStoreEnabled = in .getTransportVersion ().onOrAfter (DataStream .ADDED_FAILURE_STORE_TRANSPORT_VERSION )
202- ? in .readBoolean ()
203- : false ;
201+ // This boolean flag has been moved in data stream options
202+ var failureStoreEnabled = in .getTransportVersion ()
203+ .between (DataStream .ADDED_FAILURE_STORE_TRANSPORT_VERSION , TransportVersions .ADD_DATA_STREAM_OPTIONS )
204+ ? in .readBoolean ()
205+ : false ;
204206 var failureIndices = in .getTransportVersion ().onOrAfter (DataStream .ADDED_FAILURE_STORE_TRANSPORT_VERSION )
205207 ? readIndices (in )
206208 : List .<Index >of ();
@@ -213,6 +215,14 @@ public static DataStream read(StreamInput in) throws IOException {
213215 failureIndicesBuilder .setRolloverOnWrite (in .readBoolean ())
214216 .setAutoShardingEvent (in .readOptionalWriteable (DataStreamAutoShardingEvent ::new ));
215217 }
218+ DataStreamOptions dataStreamOptions ;
219+ if (in .getTransportVersion ().onOrAfter (TransportVersions .ADD_DATA_STREAM_OPTIONS )) {
220+ dataStreamOptions = in .readOptionalWriteable (DataStreamOptions ::read );
221+ } else {
222+ // We cannot distinguish if failure store was explicitly disabled or not. Given that failure store
223+ // is still behind a feature flag in previous version we use the default value instead of explicitly disabling it.
224+ dataStreamOptions = failureStoreEnabled ? DataStreamOptions .FAILURE_STORE_ENABLED : null ;
225+ }
216226 return new DataStream (
217227 name ,
218228 generation ,
@@ -224,7 +234,7 @@ public static DataStream read(StreamInput in) throws IOException {
224234 allowCustomRouting ,
225235 indexMode ,
226236 lifecycle ,
227- failureStoreEnabled ,
237+ dataStreamOptions ,
228238 backingIndicesBuilder .build (),
229239 failureIndicesBuilder .build ()
230240 );
@@ -274,6 +284,10 @@ public boolean isFailureStoreIndex(String indexName) {
274284 return failureIndices .containsIndex (indexName );
275285 }
276286
287+ public DataStreamOptions getDataStreamOptions () {
288+ return dataStreamOptions ;
289+ }
290+
277291 public boolean rolloverOnWrite () {
278292 return backingIndices .rolloverOnWrite ;
279293 }
@@ -406,13 +420,12 @@ public boolean isAllowCustomRouting() {
406420 }
407421
408422 /**
409- * Determines if this data stream should persist ingest pipeline and mapping failures from bulk requests to a locally
410- * configured failure store.
411- *
412- * @return Whether this data stream should store ingestion failures.
423+ * Determines if this data stream has its failure store enabled or not. Currently, the failure store
424+ * is enabled only when a user has explicitly requested it.
425+ * @return true, if the user has explicitly enabled the failure store.
413426 */
414427 public boolean isFailureStoreEnabled () {
415- return failureStoreEnabled ;
428+ return dataStreamOptions . failureStore () != null && dataStreamOptions . failureStore (). isExplicitlyEnabled () ;
416429 }
417430
418431 @ Nullable
@@ -1063,8 +1076,11 @@ public void writeTo(StreamOutput out) throws IOException {
10631076 if (out .getTransportVersion ().onOrAfter (TransportVersions .V_8_9_X )) {
10641077 out .writeOptionalWriteable (lifecycle );
10651078 }
1079+ if (out .getTransportVersion ()
1080+ .between (DataStream .ADDED_FAILURE_STORE_TRANSPORT_VERSION , TransportVersions .ADD_DATA_STREAM_OPTIONS )) {
1081+ out .writeBoolean (isFailureStoreEnabled ());
1082+ }
10661083 if (out .getTransportVersion ().onOrAfter (DataStream .ADDED_FAILURE_STORE_TRANSPORT_VERSION )) {
1067- out .writeBoolean (failureStoreEnabled );
10681084 out .writeCollection (failureIndices .indices );
10691085 }
10701086 if (out .getTransportVersion ().onOrAfter (TransportVersions .V_8_13_0 )) {
@@ -1077,6 +1093,9 @@ public void writeTo(StreamOutput out) throws IOException {
10771093 out .writeBoolean (failureIndices .rolloverOnWrite );
10781094 out .writeOptionalWriteable (failureIndices .autoShardingEvent );
10791095 }
1096+ if (out .getTransportVersion ().onOrAfter (TransportVersions .ADD_DATA_STREAM_OPTIONS )) {
1097+ out .writeOptionalWriteable (dataStreamOptions .isEmpty () ? null : dataStreamOptions );
1098+ }
10801099 }
10811100
10821101 public static final ParseField NAME_FIELD = new ParseField ("name" );
@@ -1096,6 +1115,7 @@ public void writeTo(StreamOutput out) throws IOException {
10961115 public static final ParseField AUTO_SHARDING_FIELD = new ParseField ("auto_sharding" );
10971116 public static final ParseField FAILURE_ROLLOVER_ON_WRITE_FIELD = new ParseField ("failure_rollover_on_write" );
10981117 public static final ParseField FAILURE_AUTO_SHARDING_FIELD = new ParseField ("failure_auto_sharding" );
1118+ public static final ParseField DATA_STREAM_OPTIONS_FIELD = new ParseField ("options" );
10991119
11001120 @ SuppressWarnings ("unchecked" )
11011121 private static final ConstructingObjectParser <DataStream , Void > PARSER = new ConstructingObjectParser <>("data_stream" , args -> {
@@ -1110,6 +1130,16 @@ public void writeTo(StreamOutput out) throws IOException {
11101130 (DataStreamAutoShardingEvent ) args [15 ]
11111131 )
11121132 : new DataStreamIndices (FAILURE_STORE_PREFIX , List .of (), false , null );
1133+ // We cannot distinguish if failure store was explicitly disabled or not. Given that failure store
1134+ // is still behind a feature flag in previous version we use the default value instead of explicitly disabling it.
1135+ DataStreamOptions dataStreamOptions = DataStreamOptions .EMPTY ;
1136+ if (DataStream .isFailureStoreFeatureFlagEnabled ()) {
1137+ if (args [16 ] != null ) {
1138+ dataStreamOptions = (DataStreamOptions ) args [16 ];
1139+ } else if (failureStoreEnabled ) {
1140+ dataStreamOptions = DataStreamOptions .FAILURE_STORE_ENABLED ;
1141+ }
1142+ }
11131143 return new DataStream (
11141144 (String ) args [0 ],
11151145 (Long ) args [2 ],
@@ -1121,7 +1151,7 @@ public void writeTo(StreamOutput out) throws IOException {
11211151 args [7 ] != null && (boolean ) args [7 ],
11221152 args [8 ] != null ? IndexMode .fromString ((String ) args [8 ]) : null ,
11231153 (DataStreamLifecycle ) args [9 ],
1124- failureStoreEnabled ,
1154+ dataStreamOptions ,
11251155 new DataStreamIndices (
11261156 BACKING_INDEX_PREFIX ,
11271157 (List <Index >) args [1 ],
@@ -1171,6 +1201,11 @@ public void writeTo(StreamOutput out) throws IOException {
11711201 (p , c ) -> DataStreamAutoShardingEvent .fromXContent (p ),
11721202 FAILURE_AUTO_SHARDING_FIELD
11731203 );
1204+ PARSER .declareObject (
1205+ ConstructingObjectParser .optionalConstructorArg (),
1206+ (p , c ) -> DataStreamOptions .fromXContent (p ),
1207+ DATA_STREAM_OPTIONS_FIELD
1208+ );
11741209 }
11751210 }
11761211
@@ -1208,7 +1243,6 @@ public XContentBuilder toXContent(
12081243 builder .field (SYSTEM_FIELD .getPreferredName (), system );
12091244 builder .field (ALLOW_CUSTOM_ROUTING .getPreferredName (), allowCustomRouting );
12101245 if (DataStream .isFailureStoreFeatureFlagEnabled ()) {
1211- builder .field (FAILURE_STORE_FIELD .getPreferredName (), failureStoreEnabled );
12121246 if (failureIndices .indices .isEmpty () == false ) {
12131247 builder .xContentList (FAILURE_INDICES_FIELD .getPreferredName (), failureIndices .indices );
12141248 }
@@ -1218,6 +1252,10 @@ public XContentBuilder toXContent(
12181252 failureIndices .autoShardingEvent .toXContent (builder , params );
12191253 builder .endObject ();
12201254 }
1255+ if (dataStreamOptions .isEmpty () == false ) {
1256+ builder .field (DATA_STREAM_OPTIONS_FIELD .getPreferredName ());
1257+ dataStreamOptions .toXContent (builder , params );
1258+ }
12211259 }
12221260 if (indexMode != null ) {
12231261 builder .field (INDEX_MODE .getPreferredName (), indexMode );
@@ -1250,7 +1288,7 @@ public boolean equals(Object o) {
12501288 && allowCustomRouting == that .allowCustomRouting
12511289 && indexMode == that .indexMode
12521290 && Objects .equals (lifecycle , that .lifecycle )
1253- && failureStoreEnabled == that .failureStoreEnabled
1291+ && Objects . equals ( dataStreamOptions , that .dataStreamOptions )
12541292 && Objects .equals (backingIndices , that .backingIndices )
12551293 && Objects .equals (failureIndices , that .failureIndices );
12561294 }
@@ -1267,7 +1305,7 @@ public int hashCode() {
12671305 allowCustomRouting ,
12681306 indexMode ,
12691307 lifecycle ,
1270- failureStoreEnabled ,
1308+ dataStreamOptions ,
12711309 backingIndices ,
12721310 failureIndices
12731311 );
@@ -1580,7 +1618,7 @@ public static class Builder {
15801618 private IndexMode indexMode = null ;
15811619 @ Nullable
15821620 private DataStreamLifecycle lifecycle = null ;
1583- private boolean failureStoreEnabled = false ;
1621+ private DataStreamOptions dataStreamOptions = DataStreamOptions . EMPTY ;
15841622 private DataStreamIndices backingIndices ;
15851623 private DataStreamIndices failureIndices = DataStreamIndices .failureIndicesBuilder (List .of ()).build ();
15861624
@@ -1605,7 +1643,7 @@ private Builder(DataStream dataStream) {
16051643 allowCustomRouting = dataStream .allowCustomRouting ;
16061644 indexMode = dataStream .indexMode ;
16071645 lifecycle = dataStream .lifecycle ;
1608- failureStoreEnabled = dataStream .failureStoreEnabled ;
1646+ dataStreamOptions = dataStream .dataStreamOptions ;
16091647 backingIndices = dataStream .backingIndices ;
16101648 failureIndices = dataStream .failureIndices ;
16111649 }
@@ -1660,8 +1698,8 @@ public Builder setLifecycle(DataStreamLifecycle lifecycle) {
16601698 return this ;
16611699 }
16621700
1663- public Builder setFailureStoreEnabled ( boolean failureStoreEnabled ) {
1664- this .failureStoreEnabled = failureStoreEnabled ;
1701+ public Builder setDataStreamOptions ( DataStreamOptions dataStreamOptions ) {
1702+ this .dataStreamOptions = dataStreamOptions ;
16651703 return this ;
16661704 }
16671705
@@ -1697,7 +1735,7 @@ public DataStream build() {
16971735 allowCustomRouting ,
16981736 indexMode ,
16991737 lifecycle ,
1700- failureStoreEnabled ,
1738+ dataStreamOptions ,
17011739 backingIndices ,
17021740 failureIndices
17031741 );
0 commit comments