[ML] Reinstate DatafeedJobsIT::testRealtime_multipleStopCalls test (elastic/x-pack-elasticsearch#1542)

* Handle exception in action

Original commit: elastic/x-pack-elasticsearch@2c2f28115f
This commit is contained in:
David Kyle 2017-05-25 10:02:14 +01:00 committed by GitHub
parent 1bfc864193
commit 6befa83337
2 changed files with 21 additions and 13 deletions

View File

@ -366,20 +366,29 @@ public class StopDatafeedAction
ActionListener<Response> listener) {
DatafeedState taskStatus = DatafeedState.STOPPING;
datafeedTaskTask.updatePersistentStatus(taskStatus, ActionListener.wrap(task -> {
// we need to fork because we are now on a network threadpool
threadPool.executor(MachineLearning.UTILITY_THREAD_POOL_NAME).execute(new AbstractRunnable() {
@Override
public void onFailure(Exception e) {
listener.onFailure(e);
}
// we need to fork because we are now on a network threadpool
threadPool.executor(MachineLearning.UTILITY_THREAD_POOL_NAME).execute(new AbstractRunnable() {
@Override
public void onFailure(Exception e) {
listener.onFailure(e);
}
@Override
protected void doRun() throws Exception {
datafeedTaskTask.stop("stop_datafeed (api)", request.getStopTimeout());
listener.onResponse(new Response(true));
@Override
protected void doRun() throws Exception {
datafeedTaskTask.stop("stop_datafeed (api)", request.getStopTimeout());
listener.onResponse(new Response(true));
}
});
},
e -> {
if (e instanceof ResourceNotFoundException) {
// the task has disappeared so must have stopped
listener.onResponse(new Response(true));
} else {
listener.onFailure(e);
}
}
});
}, listener::onFailure));
));
}
private void sendResponseOrFailure(String datafeedId, ActionListener<Response> listener,

View File

@ -110,7 +110,6 @@ public class DatafeedJobsIT extends MlNativeAutodetectIntegTestCase {
});
}
@AwaitsFix(bugUrl="https://github.com/elastic/x-pack-elasticsearch/issues/1536")
public void testRealtime_multipleStopCalls() throws Exception {
String jobId = "realtime-job-multiple-stop";
final String datafeedId = jobId + "-datafeed";