13
13
import org .elasticsearch .cluster .health .ClusterHealthStatus ;
14
14
import org .elasticsearch .cluster .metadata .IndexAbstraction ;
15
15
import org .elasticsearch .cluster .metadata .IndexMetadata ;
16
- import org .elasticsearch .common .Nullable ;
17
16
import org .elasticsearch .common .ParseField ;
18
17
import org .elasticsearch .common .Strings ;
19
18
import org .elasticsearch .common .io .stream .StreamInput ;
@@ -44,7 +43,6 @@ public class SearchableSnapshotAction implements LifecycleAction {
44
43
45
44
public static final ParseField SNAPSHOT_REPOSITORY = new ParseField ("snapshot_repository" );
46
45
public static final ParseField FORCE_MERGE_INDEX = new ParseField ("force_merge_index" );
47
- public static final ParseField STORAGE = new ParseField ("storage" );
48
46
public static final String CONDITIONAL_DATASTREAM_CHECK_KEY = BranchingStep .NAME + "-on-datastream-check" ;
49
47
public static final String CONDITIONAL_SKIP_ACTION_STEP = BranchingStep .NAME + "-check-prerequisites" ;
50
48
public static final String CONDITIONAL_SKIP_GENERATE_AND_CLEAN = BranchingStep .NAME + "-check-existing-snapshot" ;
@@ -53,21 +51,11 @@ public class SearchableSnapshotAction implements LifecycleAction {
53
51
public static final String PARTIAL_RESTORED_INDEX_PREFIX = "partial-" ;
54
52
55
53
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 ]));
66
55
67
56
static {
68
57
PARSER .declareString (ConstructingObjectParser .constructorArg (), SNAPSHOT_REPOSITORY );
69
58
PARSER .declareBoolean (ConstructingObjectParser .optionalConstructorArg (), FORCE_MERGE_INDEX );
70
- PARSER .declareString (ConstructingObjectParser .optionalConstructorArg (), STORAGE );
71
59
}
72
60
73
61
@@ -77,21 +65,17 @@ public static SearchableSnapshotAction parse(XContentParser parser) {
77
65
78
66
private final String snapshotRepository ;
79
67
private final boolean forceMergeIndex ;
80
- @ Nullable
81
- private final MountSearchableSnapshotRequest .Storage storageType ;
82
68
83
- public SearchableSnapshotAction (String snapshotRepository , boolean forceMergeIndex ,
84
- @ Nullable MountSearchableSnapshotRequest .Storage type ) {
69
+ public SearchableSnapshotAction (String snapshotRepository , boolean forceMergeIndex ) {
85
70
if (Strings .hasText (snapshotRepository ) == false ) {
86
71
throw new IllegalArgumentException ("the snapshot repository must be specified" );
87
72
}
88
73
this .snapshotRepository = snapshotRepository ;
89
74
this .forceMergeIndex = forceMergeIndex ;
90
- this .storageType = type ;
91
75
}
92
76
93
77
public SearchableSnapshotAction (String snapshotRepository ) {
94
- this (snapshotRepository , true , null );
78
+ this (snapshotRepository , true );
95
79
}
96
80
97
81
public SearchableSnapshotAction (StreamInput in ) throws IOException {
@@ -101,22 +85,12 @@ public SearchableSnapshotAction(StreamInput in) throws IOException {
101
85
} else {
102
86
this .forceMergeIndex = true ;
103
87
}
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
- }
109
88
}
110
89
111
90
boolean isForceMergeIndex () {
112
91
return forceMergeIndex ;
113
92
}
114
93
115
- @ Nullable
116
- public MountSearchableSnapshotRequest .Storage getStorageType () {
117
- return storageType ;
118
- }
119
-
120
94
public String getSnapshotRepository () {
121
95
return snapshotRepository ;
122
96
}
@@ -290,28 +264,15 @@ public List<Step> toSteps(Client client, String phase, StepKey nextStepKey) {
290
264
* Resolves the prefix to be used for the mounted index depending on the provided key
291
265
*/
292
266
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 ;
307
271
}
308
272
}
309
273
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
311
275
MountSearchableSnapshotRequest .Storage getConcreteStorageType (StepKey currentKey ) {
312
- if (storageType != null ) {
313
- return storageType ;
314
- }
315
276
if (currentKey .getPhase ().equals (TimeseriesLifecycleType .FROZEN_PHASE )) {
316
277
return MountSearchableSnapshotRequest .Storage .SHARED_CACHE ;
317
278
} else {
@@ -335,19 +296,13 @@ public void writeTo(StreamOutput out) throws IOException {
335
296
if (out .getVersion ().onOrAfter (Version .V_7_10_0 )) {
336
297
out .writeBoolean (forceMergeIndex );
337
298
}
338
- if (out .getVersion ().onOrAfter (Version .V_7_12_0 )) {
339
- out .writeOptionalEnum (storageType );
340
- }
341
299
}
342
300
343
301
@ Override
344
302
public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
345
303
builder .startObject ();
346
304
builder .field (SNAPSHOT_REPOSITORY .getPreferredName (), snapshotRepository );
347
305
builder .field (FORCE_MERGE_INDEX .getPreferredName (), forceMergeIndex );
348
- if (storageType != null ) {
349
- builder .field (STORAGE .getPreferredName (), storageType );
350
- }
351
306
builder .endObject ();
352
307
return builder ;
353
308
}
@@ -361,12 +316,11 @@ public boolean equals(Object o) {
361
316
return false ;
362
317
}
363
318
SearchableSnapshotAction that = (SearchableSnapshotAction ) o ;
364
- return Objects .equals (snapshotRepository , that .snapshotRepository ) &&
365
- Objects .equals (storageType , that .storageType );
319
+ return Objects .equals (snapshotRepository , that .snapshotRepository );
366
320
}
367
321
368
322
@ Override
369
323
public int hashCode () {
370
- return Objects .hash (snapshotRepository , storageType );
324
+ return Objects .hash (snapshotRepository );
371
325
}
372
326
}
0 commit comments