Skip to content

Commit

Permalink
Code review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
axw committed Nov 5, 2024
1 parent 89455be commit 0cff8db
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ private void putComposableTemplate(
public void onResponse(AcknowledgedResponse response) {
if (response.isAcknowledged()) {
if (applyRolloverAfterTemplateV2Update()) {
invokeRollover(state, templateName, indexTemplate, creationCheck);
invokeRollover(state, templateName, indexTemplate, () -> creationCheck.set((false)));
} else {
creationCheck.set(false);
}
Expand Down Expand Up @@ -786,33 +786,33 @@ protected void onPutPipelineFailure(String pipelineId, Exception e) {

/**
* invokeRollover rolls over any data streams matching the index template,
* and then sets creationCheck to false.
* and then invokes runAfter.
*/
private void invokeRollover(
final ClusterState state,
final String templateName,
final ComposableIndexTemplate indexTemplate,
final AtomicBoolean creationCheck
final Runnable runAfter
) {
final Executor executor = threadPool.generic();
executor.execute(() -> {
List<String> rolloverTargets = findRolloverTargetDataStreams(state, templateName, indexTemplate);
if (rolloverTargets.isEmpty()) {
creationCheck.set(false);
runAfter.run();
return;
}
GroupedActionListener<RolloverResponse> groupedActionListener = new GroupedActionListener<>(
rolloverTargets.size(),
new ActionListener<>() {
@Override
public void onResponse(Collection<RolloverResponse> rolloverResponses) {
creationCheck.set(false);
runAfter.run();
onRolloversBulkResponse(rolloverResponses);
}

@Override
public void onFailure(Exception e) {
creationCheck.set(false);
runAfter.run();
onRolloverFailure(e);
}
}
Expand Down

0 comments on commit 0cff8db

Please sign in to comment.