1313import org .elasticsearch .cluster .health .ClusterHealthStatus ;
1414import org .elasticsearch .cluster .metadata .IndexAbstraction ;
1515import org .elasticsearch .cluster .metadata .IndexMetadata ;
16- import org .elasticsearch .common .Nullable ;
1716import org .elasticsearch .common .ParseField ;
1817import org .elasticsearch .common .Strings ;
1918import org .elasticsearch .common .io .stream .StreamInput ;
@@ -44,7 +43,6 @@ public class SearchableSnapshotAction implements LifecycleAction {
4443
4544 public static final ParseField SNAPSHOT_REPOSITORY = new ParseField ("snapshot_repository" );
4645 public static final ParseField FORCE_MERGE_INDEX = new ParseField ("force_merge_index" );
47- public static final ParseField STORAGE = new ParseField ("storage" );
4846 public static final String CONDITIONAL_DATASTREAM_CHECK_KEY = BranchingStep .NAME + "-on-datastream-check" ;
4947 public static final String CONDITIONAL_SKIP_ACTION_STEP = BranchingStep .NAME + "-check-prerequisites" ;
5048 public static final String CONDITIONAL_SKIP_GENERATE_AND_CLEAN = BranchingStep .NAME + "-check-existing-snapshot" ;
@@ -53,21 +51,11 @@ public class SearchableSnapshotAction implements LifecycleAction {
5351 public static final String PARTIAL_RESTORED_INDEX_PREFIX = "partial-" ;
5452
5553 private static final ConstructingObjectParser <SearchableSnapshotAction , Void > PARSER = new ConstructingObjectParser <>(NAME ,
56- a -> {
57- String storageName = (String ) a [2 ];
58- final MountSearchableSnapshotRequest .Storage storageType ;
59- if (storageName == null ) {
60- storageType = null ;
61- } else {
62- storageType = MountSearchableSnapshotRequest .Storage .fromString (storageName );
63- }
64- return new SearchableSnapshotAction ((String ) a [0 ], a [1 ] == null || (boolean ) a [1 ], storageType );
65- });
54+ a -> new SearchableSnapshotAction ((String ) a [0 ], a [1 ] == null || (boolean ) a [1 ]));
6655
6756 static {
6857 PARSER .declareString (ConstructingObjectParser .constructorArg (), SNAPSHOT_REPOSITORY );
6958 PARSER .declareBoolean (ConstructingObjectParser .optionalConstructorArg (), FORCE_MERGE_INDEX );
70- PARSER .declareString (ConstructingObjectParser .optionalConstructorArg (), STORAGE );
7159 }
7260
7361
@@ -77,21 +65,17 @@ public static SearchableSnapshotAction parse(XContentParser parser) {
7765
7866 private final String snapshotRepository ;
7967 private final boolean forceMergeIndex ;
80- @ Nullable
81- private final MountSearchableSnapshotRequest .Storage storageType ;
8268
83- public SearchableSnapshotAction (String snapshotRepository , boolean forceMergeIndex ,
84- @ Nullable MountSearchableSnapshotRequest .Storage type ) {
69+ public SearchableSnapshotAction (String snapshotRepository , boolean forceMergeIndex ) {
8570 if (Strings .hasText (snapshotRepository ) == false ) {
8671 throw new IllegalArgumentException ("the snapshot repository must be specified" );
8772 }
8873 this .snapshotRepository = snapshotRepository ;
8974 this .forceMergeIndex = forceMergeIndex ;
90- this .storageType = type ;
9175 }
9276
9377 public SearchableSnapshotAction (String snapshotRepository ) {
94- this (snapshotRepository , true , null );
78+ this (snapshotRepository , true );
9579 }
9680
9781 public SearchableSnapshotAction (StreamInput in ) throws IOException {
@@ -101,22 +85,12 @@ public SearchableSnapshotAction(StreamInput in) throws IOException {
10185 } else {
10286 this .forceMergeIndex = true ;
10387 }
104- if (in .getVersion ().onOrAfter (Version .V_7_12_0 )) {
105- this .storageType = in .readOptionalEnum (MountSearchableSnapshotRequest .Storage .class );
106- } else {
107- this .storageType = null ;
108- }
10988 }
11089
11190 boolean isForceMergeIndex () {
11291 return forceMergeIndex ;
11392 }
11493
115- @ Nullable
116- public MountSearchableSnapshotRequest .Storage getStorageType () {
117- return storageType ;
118- }
119-
12094 public String getSnapshotRepository () {
12195 return snapshotRepository ;
12296 }
@@ -290,28 +264,15 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
290264 * Resolves the prefix to be used for the mounted index depending on the provided key
291265 */
292266 String getRestoredIndexPrefix (StepKey currentKey ) {
293- if (storageType == null ) {
294- if (currentKey .getPhase ().equals (TimeseriesLifecycleType .FROZEN_PHASE )) {
295- return PARTIAL_RESTORED_INDEX_PREFIX ;
296- } else {
297- return FULL_RESTORED_INDEX_PREFIX ;
298- }
299- }
300- switch (storageType ) {
301- case FULL_COPY :
302- return FULL_RESTORED_INDEX_PREFIX ;
303- case SHARED_CACHE :
304- return PARTIAL_RESTORED_INDEX_PREFIX ;
305- default :
306- throw new IllegalArgumentException ("unexpected storage type: " + storageType );
267+ if (currentKey .getPhase ().equals (TimeseriesLifecycleType .FROZEN_PHASE )) {
268+ return PARTIAL_RESTORED_INDEX_PREFIX ;
269+ } else {
270+ return FULL_RESTORED_INDEX_PREFIX ;
307271 }
308272 }
309273
310- // Resolves the storage type from a Nullable to non-Nullable type
274+ // Resolves the storage type depending on which phase the index is in
311275 MountSearchableSnapshotRequest .Storage getConcreteStorageType (StepKey currentKey ) {
312- if (storageType != null ) {
313- return storageType ;
314- }
315276 if (currentKey .getPhase ().equals (TimeseriesLifecycleType .FROZEN_PHASE )) {
316277 return MountSearchableSnapshotRequest .Storage .SHARED_CACHE ;
317278 } else {
@@ -335,19 +296,13 @@ public void writeTo(StreamOutput out) throws IOException {
335296 if (out .getVersion ().onOrAfter (Version .V_7_10_0 )) {
336297 out .writeBoolean (forceMergeIndex );
337298 }
338- if (out .getVersion ().onOrAfter (Version .V_7_12_0 )) {
339- out .writeOptionalEnum (storageType );
340- }
341299 }
342300
343301 @ Override
344302 public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
345303 builder .startObject ();
346304 builder .field (SNAPSHOT_REPOSITORY .getPreferredName (), snapshotRepository );
347305 builder .field (FORCE_MERGE_INDEX .getPreferredName (), forceMergeIndex );
348- if (storageType != null ) {
349- builder .field (STORAGE .getPreferredName (), storageType );
350- }
351306 builder .endObject ();
352307 return builder ;
353308 }
@@ -361,12 +316,11 @@ public boolean equals(Object o) {
361316 return false ;
362317 }
363318 SearchableSnapshotAction that = (SearchableSnapshotAction ) o ;
364- return Objects .equals (snapshotRepository , that .snapshotRepository ) &&
365- Objects .equals (storageType , that .storageType );
319+ return Objects .equals (snapshotRepository , that .snapshotRepository );
366320 }
367321
368322 @ Override
369323 public int hashCode () {
370- return Objects .hash (snapshotRepository , storageType );
324+ return Objects .hash (snapshotRepository );
371325 }
372326}
0 commit comments