Skip to content

Commit 3924998

Browse files
committed
simplifying, using correct listener
1 parent 1b15ad4 commit 3924998

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/task/ReindexDataStreamPersistentTaskExecutor.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.elasticsearch.cluster.service.ClusterService;
2929
import org.elasticsearch.common.settings.Setting;
3030
import org.elasticsearch.core.Nullable;
31+
import org.elasticsearch.core.Strings;
3132
import org.elasticsearch.core.TimeValue;
3233
import org.elasticsearch.index.Index;
3334
import org.elasticsearch.persistent.AllocatedPersistentTask;
@@ -44,7 +45,6 @@
4445
import java.util.List;
4546
import java.util.Map;
4647
import java.util.NoSuchElementException;
47-
import java.util.function.BiConsumer;
4848

4949
import static org.elasticsearch.xpack.core.deprecation.DeprecatedIndexPredicate.getReindexRequiredPredicate;
5050

@@ -221,31 +221,31 @@ private void maybeProcessNextIndex(
221221
l -> client.execute(
222222
ReindexDataStreamIndexAction.INSTANCE,
223223
reindexDataStreamIndexRequest,
224-
l.delegateResponse(new BiConsumer<ActionListener<ReindexDataStreamIndexAction.Response>, Exception>() {
225-
@Override
226-
public void accept(ActionListener<ReindexDataStreamIndexAction.Response> responseActionListener, Exception e) {
227-
IndexMetadata sourceIndex = clusterService.state().getMetadata().index(index.getName());
228-
if (sourceIndex == null) {
229-
/*
230-
* One possible cause of exception here is that the source index no longer exists. This can happen if ILM
231-
* performs certain actions while reindex is happening, or if a user manually deletes it. In this case we don't
232-
* want to fail the task. We treat it as a success and move on. The updateDataStreamOrCleanup method will make
233-
* an attempt at deleting the destination index if it has been created.
234-
*/
235-
logger.debug(
224+
l.delegateResponse((responseActionListener, e) -> {
225+
IndexMetadata sourceIndex = clusterService.state().getMetadata().index(index.getName());
226+
if (sourceIndex == null) {
227+
/*
228+
* One possible cause of exception here is that the source index no longer exists. This can happen if ILM
229+
* performs certain actions while reindex is happening, or if a user manually deletes it. In this case we don't
230+
* want to fail the task. We treat it as a success and move on. The updateDataStreamOrCleanup method will make
231+
* an attempt at deleting the destination index if it has been created.
232+
*/
233+
logger.debug(
234+
() -> Strings.format(
236235
"The source index {} in the data stream {} was removed during processing",
237236
index.getName(),
238237
sourceDataStream
239-
);
240-
// We need the destination index name in the response so that updateDataStreamOrCleanup can delete it
241-
l.onResponse(
242-
new ReindexDataStreamIndexAction.Response(
243-
ReindexDataStreamIndexTransportAction.generateDestIndexName(index.getName())
244-
)
245-
);
246-
} else {
247-
l.onFailure(e);
248-
}
238+
),
239+
e
240+
);
241+
// We need the destination index name in the response so that updateDataStreamOrCleanup can delete it
242+
responseActionListener.onResponse(
243+
new ReindexDataStreamIndexAction.Response(
244+
ReindexDataStreamIndexTransportAction.generateDestIndexName(index.getName())
245+
)
246+
);
247+
} else {
248+
responseActionListener.onFailure(e);
249249
}
250250
})
251251
)

0 commit comments

Comments
 (0)