Implement cancellation of indexing works simply by allowing the user to call cancel() on the returned future.
In the work processing thread, if the future is complete with a CancellationException, we'll just skip the corresponding work. If it's not, we'll send the work to the REST client and add an exception handler (.exceptionally(...) to the user-returned future: if the future is completed with a CancellationException, we'll cancel the HTTP request ( is it possible? using the Cancellable object returned by the REST client, see https://github.com/elastic/elasticsearch/pull/45379 ). |
|