11
11
import org .elasticsearch .ElasticsearchException ;
12
12
import org .elasticsearch .client .Client ;
13
13
import org .elasticsearch .cluster .ClusterState ;
14
- import org .elasticsearch .cluster .Diff ;
15
14
import org .elasticsearch .cluster .DiffableUtils ;
16
15
import org .elasticsearch .cluster .metadata .IndexMetadata ;
17
16
import org .elasticsearch .cluster .metadata .Metadata ;
@@ -92,32 +91,29 @@ Map<String, Map<Step.StepKey, Step>> getStepMap() {
92
91
return stepMap ;
93
92
}
94
93
95
- @ SuppressWarnings ({ "unchecked" , "rawtypes" })
96
94
public void update (ClusterState clusterState ) {
97
95
final IndexLifecycleMetadata meta = clusterState .metadata ().custom (IndexLifecycleMetadata .TYPE );
98
-
99
96
assert meta != null : "IndexLifecycleMetadata cannot be null when updating the policy steps registry" ;
100
97
101
- Diff < Map <String , LifecyclePolicyMetadata >> diff = DiffableUtils . diff ( lifecyclePolicyMap , meta . getPolicyMetadatas (),
102
- DiffableUtils .getStringKeySerializer (),
103
- // Use a non-diffable value serializer. Otherwise actions in the same
104
- // action and phase that are changed show up as diffs instead of upserts.
105
- // We want to treat any change in the policy as an upsert so the map is
106
- // correctly rebuilt
107
- new DiffableUtils .NonDiffableValueSerializer <String , LifecyclePolicyMetadata >() {
108
- @ Override
109
- public void write (LifecyclePolicyMetadata value , StreamOutput out ) {
110
- // This is never called
111
- throw new UnsupportedOperationException ("should never be called" );
112
- }
98
+ DiffableUtils . MapDiff < String , LifecyclePolicyMetadata , Map <String , LifecyclePolicyMetadata >> mapDiff =
99
+ DiffableUtils .diff ( lifecyclePolicyMap , meta . getPolicyMetadatas (), DiffableUtils . getStringKeySerializer (),
100
+ // Use a non-diffable value serializer. Otherwise actions in the same
101
+ // action and phase that are changed show up as diffs instead of upserts.
102
+ // We want to treat any change in the policy as an upsert so the map is
103
+ // correctly rebuilt
104
+ new DiffableUtils .NonDiffableValueSerializer <String , LifecyclePolicyMetadata >() {
105
+ @ Override
106
+ public void write (LifecyclePolicyMetadata value , StreamOutput out ) {
107
+ // This is never called
108
+ throw new UnsupportedOperationException ("should never be called" );
109
+ }
113
110
114
- @ Override
115
- public LifecyclePolicyMetadata read (StreamInput in , String key ) {
116
- // This is never called
117
- throw new UnsupportedOperationException ("should never be called" );
118
- }
119
- });
120
- DiffableUtils .MapDiff <String , LifecyclePolicyMetadata , DiffableUtils .KeySerializer <String >> mapDiff = (DiffableUtils .MapDiff ) diff ;
111
+ @ Override
112
+ public LifecyclePolicyMetadata read (StreamInput in , String key ) {
113
+ // This is never called
114
+ throw new UnsupportedOperationException ("should never be called" );
115
+ }
116
+ });
121
117
122
118
for (String deletedPolicyName : mapDiff .getDeletes ()) {
123
119
lifecyclePolicyMap .remove (deletedPolicyName );
@@ -128,7 +124,7 @@ public LifecyclePolicyMetadata read(StreamInput in, String key) {
128
124
if (mapDiff .getUpserts ().isEmpty () == false ) {
129
125
for (LifecyclePolicyMetadata policyMetadata : mapDiff .getUpserts ().values ()) {
130
126
LifecyclePolicySecurityClient policyClient = new LifecyclePolicySecurityClient (client , ClientHelper .INDEX_LIFECYCLE_ORIGIN ,
131
- policyMetadata .getHeaders ());
127
+ policyMetadata .getHeaders ());
132
128
lifecyclePolicyMap .put (policyMetadata .getName (), policyMetadata );
133
129
List <Step > policyAsSteps = policyMetadata .getPolicy ().toSteps (policyClient , licenseState );
134
130
if (policyAsSteps .isEmpty () == false ) {
0 commit comments