forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent Duplicate ILM Cluster State Updates from Being Created (elast…
…ic#78390) Prevent duplicate ILM tasks from being enqueued to fix the most immediate issues around elastic#78246. The ILM logic should be further improved though. I did not include `MoveToErrorStepUpdateTask` in this change yet as I wasn't entirely sure how valid/safe hashing/comparing arbitrary `Exception`s would be. That could be looked into in a follow-up as well. Relates elastic#77466 Closes elastic#78246
- Loading branch information
1 parent
490c23b
commit 357de11
Showing
12 changed files
with
175 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...n/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleClusterStateUpdateTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.ilm; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.ClusterStateUpdateTask; | ||
import org.elasticsearch.common.util.concurrent.ListenableFuture; | ||
|
||
/** | ||
* Base class for index lifecycle cluster state update tasks that requires implementing {@code equals} and {@code hashCode} to allow | ||
* for these tasks to be deduplicated by {@link IndexLifecycleRunner}. | ||
*/ | ||
public abstract class IndexLifecycleClusterStateUpdateTask extends ClusterStateUpdateTask { | ||
|
||
private final ListenableFuture<Void> listener = new ListenableFuture<>(); | ||
|
||
@Override | ||
public final void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { | ||
listener.onResponse(null); | ||
onClusterStateProcessed(source, oldState, newState); | ||
} | ||
|
||
@Override | ||
public final void onFailure(String source, Exception e) { | ||
listener.onFailure(e); | ||
handleFailure(source, e); | ||
} | ||
|
||
/** | ||
* Add a listener that is resolved once this update has been processed or failed and before either the | ||
* {@link #onClusterStateProcessed(String, ClusterState, ClusterState)} or the {@link #handleFailure(String, Exception)} hooks are | ||
* executed. | ||
*/ | ||
public final void addListener(ActionListener<Void> listener) { | ||
this.listener.addListener(listener); | ||
} | ||
|
||
/** | ||
* This method is functionally the same as {@link ClusterStateUpdateTask#clusterStateProcessed(String, ClusterState, ClusterState)} | ||
* and implementations can override it as they would override {@code ClusterStateUpdateTask#clusterStateProcessed}. | ||
*/ | ||
protected void onClusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { | ||
} | ||
|
||
@Override | ||
public abstract boolean equals(Object other); | ||
|
||
@Override | ||
public abstract int hashCode(); | ||
|
||
/** | ||
* This method is functionally the same as {@link ClusterStateUpdateTask#onFailure(String, Exception)} and implementations can override | ||
* it as they would override {@code ClusterStateUpdateTask#onFailure}. | ||
*/ | ||
protected abstract void handleFailure(String source, Exception e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.