-
Notifications
You must be signed in to change notification settings - Fork 25.2k
EQL: Adds an ability to start an asynchronous EQL search #56631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds support for async searches to eql search API. This commit is limited to only submitting search API requests and doesn't provide APIs to get results nor delete the results. These functions will be added in follow up PRs. Relates to elastic#49638
Pinging @elastic/es-ql (:Query Languages/EQL) |
@elasticmachine run elasticsearch-ci/default-distro |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I left some comments but they can be addressed in the follow up (when refactoring the get and delete async).
@@ -46,6 +46,8 @@ | |||
import java.util.function.Supplier; | |||
|
|||
public class EqlPlugin extends Plugin implements ActionPlugin { | |||
// We are going to reuse the same index as normal async search until system indices are implemented | |||
public static final String INDEX = ".async-search"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should share this in core next to AsyncTaskMaintenanceService ?
I also wonder who should be responsible to start the AsyncTaskMaintenanceService
since we don't need to start it twice ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Good point. Let's deal with it in the next PR when I start moving stuff around.
if (request.hasParam("keep_alive")) { | ||
eqlRequest.keepAlive(request.paramAsTime("keep_alive", eqlRequest.keepAlive())); | ||
} | ||
eqlRequest.keepOnCompletion(request.paramAsBoolean("keep_on_completion", eqlRequest.keepOnCompletion())); | ||
} | ||
|
||
return channel -> client.execute(EqlSearchAction.INSTANCE, eqlRequest, new RestResponseListener<>(channel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use RestCancellableNodeClient
in order to get the automatic cancellation if the user closes the rest channel ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I am going to open PR against master for that in a bit since it's not async execution-specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I need AbstractEqlBlockingIntegTestCase to do IT testing for it and it only exists in this branch for now. So, I think I will open a separate PR but against this branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
private final SecurityContext securityContext; | ||
private final ClusterService clusterService; | ||
private final PlanExecutor planExecutor; | ||
private final ThreadPool threadPool; | ||
private final AsyncTaskManagementService<EqlSearchRequest, EqlSearchResponse, EqlSearchTask> asyncTaskManagementService; | ||
|
||
@Inject | ||
public TransportEqlSearchAction(Settings settings, ClusterService clusterService, TransportService transportService, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PlanExecutor
already has a Client
and NamedWriteableRegistry
injected - unless they are different, you could get them from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are the same, I just feel like having client as an explicit dependency is a bit cleaner. Otherwise, I would need to reach into PlanExecutor and possibly mock PlanExecutor in AsyncTaskManagementServiceTests. I also don't feel like providing access to client and writableRegistry shouldn't be a PlainExecutor's concern. Especially considering that writableRegistry is not even used by PlainExecutor at the moment.
Adds support for async searches to eql search API. This commit is limited to
only submitting search API requests and doesn't provide APIs to get results
nor delete the results. These functions will be added in follow up PRs.
Relates to #49638
Supersedes #56147