Module org.elasticsearch.xcore
Class AsyncTaskIndexService<R extends AsyncResponse<R>>
java.lang.Object
org.elasticsearch.xpack.core.async.AsyncTaskIndexService<R>
A service that exposes the CRUD operations for the async task-specific index.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAsyncTaskIndexService(String index, ClusterService clusterService, ThreadContext threadContext, Client client, String origin, Writeable.Reader<R> reader, NamedWriteableRegistry registry, BigArrays bigArrays) -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateResponse(String docId, Map<String, String> headers, R response, ActionListener<DocWriteResponse> listener) Stores the initial response with the original headers of the authenticated user and the expected expiration time.voidcreateResponseForEQL(String docId, Map<String, String> headers, Map<String, List<String>> responseHeaders, R response, ActionListener<DocWriteResponse> listener) voidcreateResponseForEQL(String docId, Map<String, String> headers, R response, ActionListener<DocWriteResponse> listener) Stores the initial response with the original headers of the authenticated user and the expected expiration time.voiddeleteResponse(AsyncExecutionId asyncExecutionId, ActionListener<DeleteResponse> listener) Deletes the providedasyncTaskIdfrom the index if present.Returns the internal client.Returns the internal client wrapped with the async user origin.voidgetResponse(AsyncExecutionId asyncExecutionId, boolean restoreResponseHeaders, ActionListener<R> listener) Gets the response from the index if present, or delegate aResourceNotFoundExceptionfailure to the provided listener if not.static SystemIndexDescriptorstatic <T extends AsyncTask>
TgetTask(TaskManager taskManager, AsyncExecutionId asyncExecutionId, Class<T> tClass) Returns theAsyncTaskif the providedasyncTaskIdis registered in the task manager,nullotherwise.<T extends AsyncTask>
TgetTaskAndCheckAuthentication(TaskManager taskManager, AsyncExecutionId asyncExecutionId, Class<T> tClass) Returns theAsyncTaskif the providedasyncTaskIdis registered in the task manager,nullotherwise.static <T extends AsyncTask>
TgetTaskAndCheckAuthentication(TaskManager taskManager, AsyncSearchSecurity security, AsyncExecutionId asyncExecutionId, Class<T> tClass) Returns theAsyncTaskif the providedasyncTaskIdis registered in the task manager,nullotherwise.static voidrestoreResponseHeadersContext(ThreadContext threadContext, Map<String, List<String>> responseHeaders) Restores the providedresponseHeadersto the current thread context.<T extends AsyncTask,SR extends SearchStatusResponse>
voidretrieveStatus(GetAsyncStatusRequest request, TaskManager taskManager, Class<T> tClass, Function<T, SR> statusProducerFromTask, TriFunction<R, Long, String, SR> statusProducerFromIndex, ActionListener<SR> originalListener) Retrieve the status of the async search or async or stored eql search.voidupdateExpirationTime(String docId, long expirationTimeMillis, ActionListener<UpdateResponse> listener) Updates the expiration time of the provideddocIdif the place-holder document is still present (update).voidupdateResponse(String docId, Map<String, List<String>> responseHeaders, R response, ActionListener<UpdateResponse> listener)
-
Field Details
-
HEADERS_FIELD
- See Also:
-
RESPONSE_HEADERS_FIELD
- See Also:
-
EXPIRATION_TIME_FIELD
- See Also:
-
RESULT_FIELD
- See Also:
-
-
Constructor Details
-
AsyncTaskIndexService
public AsyncTaskIndexService(String index, ClusterService clusterService, ThreadContext threadContext, Client client, String origin, Writeable.Reader<R> reader, NamedWriteableRegistry registry, BigArrays bigArrays)
-
-
Method Details
-
getSystemIndexDescriptor
-
getClientWithOrigin
Returns the internal client wrapped with the async user origin. -
getClient
Returns the internal client. -
getSecurity
-
createResponseForEQL
public void createResponseForEQL(String docId, Map<String, String> headers, R response, ActionListener<DocWriteResponse> listener) Stores the initial response with the original headers of the authenticated user and the expected expiration time. Currently for EQL we don't set limit for a stored async response TODO: add limit for stored async response in EQL, and instead of this method use createResponse -
createResponseForEQL
-
createResponse
public void createResponse(String docId, Map<String, String> headers, R response, ActionListener<DocWriteResponse> listener) Stores the initial response with the original headers of the authenticated user and the expected expiration time. -
updateResponse
public void updateResponse(String docId, Map<String, List<String>> responseHeaders, R response, ActionListener<UpdateResponse> listener) -
updateExpirationTime
public void updateExpirationTime(String docId, long expirationTimeMillis, ActionListener<UpdateResponse> listener) Updates the expiration time of the provideddocIdif the place-holder document is still present (update). -
deleteResponse
public void deleteResponse(AsyncExecutionId asyncExecutionId, ActionListener<DeleteResponse> listener) Deletes the providedasyncTaskIdfrom the index if present. -
getTask
public static <T extends AsyncTask> T getTask(TaskManager taskManager, AsyncExecutionId asyncExecutionId, Class<T> tClass) throws IOException Returns theAsyncTaskif the providedasyncTaskIdis registered in the task manager,nullotherwise.- Throws:
IOException
-
getTaskAndCheckAuthentication
public <T extends AsyncTask> T getTaskAndCheckAuthentication(TaskManager taskManager, AsyncExecutionId asyncExecutionId, Class<T> tClass) throws IOException Returns theAsyncTaskif the providedasyncTaskIdis registered in the task manager,nullotherwise. This method throws aResourceNotFoundExceptionif the authenticated user is not the creator of the original task.- Throws:
IOException
-
getTaskAndCheckAuthentication
public static <T extends AsyncTask> T getTaskAndCheckAuthentication(TaskManager taskManager, AsyncSearchSecurity security, AsyncExecutionId asyncExecutionId, Class<T> tClass) throws IOException Returns theAsyncTaskif the providedasyncTaskIdis registered in the task manager,nullotherwise. This method throws aResourceNotFoundExceptionif the authenticated user is not the creator of the original task.- Throws:
IOException
-
getResponse
public void getResponse(AsyncExecutionId asyncExecutionId, boolean restoreResponseHeaders, ActionListener<R> listener) Gets the response from the index if present, or delegate aResourceNotFoundExceptionfailure to the provided listener if not. When the providedrestoreResponseHeadersistrue, this method also restores the response headers of the original request in the current thread context. -
retrieveStatus
public <T extends AsyncTask,SR extends SearchStatusResponse> void retrieveStatus(GetAsyncStatusRequest request, TaskManager taskManager, Class<T> tClass, Function<T, SR> statusProducerFromTask, TriFunction<R, Long, String, SR> statusProducerFromIndex, ActionListener<SR> originalListener) Retrieve the status of the async search or async or stored eql search. Retrieve from the task if the task is still available or from the index. -
restoreResponseHeadersContext
public static void restoreResponseHeadersContext(ThreadContext threadContext, Map<String, List<String>> responseHeaders) Restores the providedresponseHeadersto the current thread context.
-