Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction;
Expand Down Expand Up @@ -78,7 +79,13 @@ public void execute(DataFrameAnalyticsTask task, DataFrameAnalyticsState current
case STARTED:
task.updatePersistentTaskState(reindexingState, ActionListener.wrap(
updatedTask -> reindexingStateListener.onResponse(config),
reindexingStateListener::onFailure));
error -> {
if (error instanceof ResourceNotFoundException) {
// The task has been stopped
} else {
reindexingStateListener.onFailure(error);
}
}));
break;
// The task has fully reindexed the documents and we should continue on with our analyses
case ANALYZING:
Expand Down Expand Up @@ -221,7 +228,13 @@ private void startAnalytics(DataFrameAnalyticsTask task, DataFrameAnalyticsConfi
task.markAsCompleted();
}
}),
error -> task.updateState(DataFrameAnalyticsState.FAILED, error.getMessage())
error -> {
if (error instanceof ResourceNotFoundException) {
// Task has stopped
} else {
task.updateState(DataFrameAnalyticsState.FAILED, error.getMessage());
}
}
));
},
error -> task.updateState(DataFrameAnalyticsState.FAILED, error.getMessage())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ protected void onCancelled() {

@Override
public void markAsCompleted() {
persistProgress(() -> super.markAsCompleted());
// It is possible that the stop API has been called in the meantime and that
// may also cause this method to be called. We check whether we have already
// been marked completed to avoid doing it twice.
if (isCompleted() == false) {
persistProgress(() -> super.markAsCompleted());
}
}

@Override
Expand Down