Skip to content

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

Merged
merged 1 commit into from
May 13, 2020

Conversation

imotov
Copy link
Contributor

@imotov imotov commented May 12, 2020

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

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
@imotov imotov added >enhancement :Analytics/EQL EQL querying Team:QL (Deprecated) Meta label for query languages team labels May 12, 2020
@imotov imotov requested review from costin, javanna and jimczi May 12, 2020 18:10
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (:Query Languages/EQL)

@imotov
Copy link
Contributor Author

imotov commented May 12, 2020

@elasticmachine run elasticsearch-ci/default-distro

Copy link
Contributor

@jimczi jimczi left a 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";
Copy link
Contributor

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 ?

Copy link
Contributor Author

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) {
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

@costin costin left a 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,
Copy link
Member

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.

Copy link
Contributor Author

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.

@imotov imotov merged commit fcebd4f into elastic:feature/async-eql May 13, 2020
@imotov imotov deleted the async-eql-submit branch July 17, 2020 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/EQL EQL querying >enhancement Team:QL (Deprecated) Meta label for query languages team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants