6
6
*/
7
7
package org .elasticsearch .xpack .eql .plugin ;
8
8
9
- import org .elasticsearch .action .ActionListener ;
10
- import org .elasticsearch .action .ActionListenerResponseHandler ;
11
9
import org .elasticsearch .action .support .ActionFilters ;
12
- import org .elasticsearch .action .support .HandledTransportAction ;
13
10
import org .elasticsearch .client .Client ;
14
- import org .elasticsearch .cluster .node .DiscoveryNode ;
15
11
import org .elasticsearch .cluster .service .ClusterService ;
16
12
import org .elasticsearch .common .inject .Inject ;
17
13
import org .elasticsearch .common .io .stream .NamedWriteableRegistry ;
18
14
import org .elasticsearch .common .io .stream .Writeable ;
19
15
import org .elasticsearch .common .util .BigArrays ;
20
- import org .elasticsearch .tasks .Task ;
21
16
import org .elasticsearch .threadpool .ThreadPool ;
22
17
import org .elasticsearch .transport .TransportService ;
23
- import org .elasticsearch .xpack .core .XPackPlugin ;
24
- import org .elasticsearch .xpack .core .async .AsyncExecutionId ;
25
- import org .elasticsearch .xpack .core .async .AsyncTaskIndexService ;
26
- import org .elasticsearch .xpack .core .async .GetAsyncStatusRequest ;
27
18
import org .elasticsearch .xpack .eql .action .EqlSearchResponse ;
28
19
import org .elasticsearch .xpack .eql .action .EqlSearchTask ;
29
- import org .elasticsearch .xpack .eql .action .EqlStatusResponse ;
30
- import org .elasticsearch .xpack .eql .async .StoredAsyncResponse ;
20
+ import org .elasticsearch .xpack .ql .plugin .AbstractTransportQlAsyncGetStatusAction ;
31
21
32
- import java .util .Objects ;
33
-
34
- import static org .elasticsearch .xpack .core .ClientHelper .ASYNC_SEARCH_ORIGIN ;
35
-
36
-
37
- public class TransportEqlAsyncGetStatusAction extends HandledTransportAction <GetAsyncStatusRequest , EqlStatusResponse > {
38
- private final TransportService transportService ;
39
- private final ClusterService clusterService ;
40
- private final AsyncTaskIndexService <StoredAsyncResponse <EqlSearchResponse >> store ;
41
22
23
+ public class TransportEqlAsyncGetStatusAction extends AbstractTransportQlAsyncGetStatusAction <EqlSearchResponse , EqlSearchTask > {
42
24
@ Inject
43
25
public TransportEqlAsyncGetStatusAction (TransportService transportService ,
44
26
ActionFilters actionFilters ,
@@ -47,31 +29,12 @@ public TransportEqlAsyncGetStatusAction(TransportService transportService,
47
29
Client client ,
48
30
ThreadPool threadPool ,
49
31
BigArrays bigArrays ) {
50
- super (EqlAsyncGetStatusAction .NAME , transportService , actionFilters , GetAsyncStatusRequest ::new );
51
- this .transportService = transportService ;
52
- this .clusterService = clusterService ;
53
- Writeable .Reader <StoredAsyncResponse <EqlSearchResponse >> reader = in -> new StoredAsyncResponse <>(EqlSearchResponse ::new , in );
54
- this .store = new AsyncTaskIndexService <>(XPackPlugin .ASYNC_RESULTS_INDEX , clusterService ,
55
- threadPool .getThreadContext (), client , ASYNC_SEARCH_ORIGIN , reader , registry , bigArrays );
32
+ super (EqlAsyncGetStatusAction .NAME , transportService , actionFilters , clusterService , registry , client , threadPool , bigArrays ,
33
+ EqlSearchTask .class );
56
34
}
57
35
58
36
@ Override
59
- protected void doExecute (Task task , GetAsyncStatusRequest request , ActionListener <EqlStatusResponse > listener ) {
60
- AsyncExecutionId searchId = AsyncExecutionId .decode (request .getId ());
61
- DiscoveryNode node = clusterService .state ().nodes ().get (searchId .getTaskId ().getNodeId ());
62
- DiscoveryNode localNode = clusterService .state ().getNodes ().getLocalNode ();
63
- if (node == null || Objects .equals (node , localNode )) {
64
- store .retrieveStatus (
65
- request ,
66
- taskManager ,
67
- EqlSearchTask .class ,
68
- EqlSearchTask ::getStatusResponse ,
69
- EqlStatusResponse ::getStatusFromStoredSearch ,
70
- listener
71
- );
72
- } else {
73
- transportService .sendRequest (node , EqlAsyncGetStatusAction .NAME , request ,
74
- new ActionListenerResponseHandler <>(listener , EqlStatusResponse ::new , ThreadPool .Names .SAME ));
75
- }
37
+ protected Writeable .Reader <EqlSearchResponse > responseReader () {
38
+ return EqlSearchResponse ::new ;
76
39
}
77
40
}
0 commit comments