java.lang.Object
io.evitadb.driver.ClientTaskTracker
- All Implemented Interfaces:
Closeable,AutoCloseable
This class is responsible for tracking the status of client tasks and updating them in the background. Each returned
task status received on the client that is not yet finished needs to be tracked and updated by this service, because
it contains
CompletableFuture that might be trapped in the client's pipeline that would be waiting indefinitely
if the future is not completed. If the futures are not used at all, they would be garbage collected and might be
evicted from the tracke
d queue prematurely. Also the tasks are evicted from the queue when they are finished.- Author:
- Jan Novotný (novotny@fg.cz), FG Forrest a.s. (c) 2024
-
Constructor Summary
ConstructorsConstructorDescriptionClientTaskTracker(EvitaManagementContract evitaManagement, int clientTaskLimit, int refreshIntervalMillis) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the tracker and cancels all the tasks that are being tracked (only on the client side, the server side tasks will remain running / queued).<S,T> ClientTask<S, T> createTask(TaskStatus<S, T> taskStatus) Creates a new client task.
-
Constructor Details
-
ClientTaskTracker
public ClientTaskTracker(@Nonnull EvitaManagementContract evitaManagement, int clientTaskLimit, int refreshIntervalMillis)
-
-
Method Details
-
createTask
Creates a new client task. If the task is not yet completed (finished or failed), it is added to the queue of tracked tasks and its status is updated in the background, so that theTask.getFutureResult()is completed when the task is finished.- Type Parameters:
S- the type of the settings of the taskT- the type of the result of the task- Parameters:
taskStatus- the status of the task to be tracked- Returns:
- the client task that is tracking the status of the task
-
close
public void close()Closes the tracker and cancels all the tasks that are being tracked (only on the client side, the server side tasks will remain running / queued).- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-