Skip to content

Commit

Permalink
Add TaskManager to pluginServices (#112687)
Browse files Browse the repository at this point in the history
Provide access to the TaskManager in plugins so that a RemovedTaskListener can be registered. This will allow a plugin to monitor when submitted tasks complete.
  • Loading branch information
parkertimmins authored Sep 11, 2024
1 parent cd3d664 commit 3d7c7cf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/112687.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 112687
summary: Add `TaskManager` to `pluginServices`
area: Infra/Metrics
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,8 @@ private void construct(
featureService,
systemIndices,
dataStreamGlobalRetentionSettings,
documentParsingProvider
documentParsingProvider,
taskManager
);

Collection<?> pluginComponents = pluginsService.flatMap(plugin -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.elasticsearch.plugins.internal.DocumentParsingProvider;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.tasks.TaskManager;
import org.elasticsearch.telemetry.TelemetryProvider;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
Expand All @@ -48,5 +49,6 @@ public record PluginServiceInstances(
FeatureService featureService,
SystemIndices systemIndices,
DataStreamGlobalRetentionSettings dataStreamGlobalRetentionSettings,
DocumentParsingProvider documentParsingProvider
DocumentParsingProvider documentParsingProvider,
TaskManager taskManager
) implements Plugin.PluginServices {}
7 changes: 7 additions & 0 deletions server/src/main/java/org/elasticsearch/plugins/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.elasticsearch.plugins.internal.DocumentParsingProvider;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.tasks.TaskManager;
import org.elasticsearch.telemetry.TelemetryProvider;
import org.elasticsearch.threadpool.ExecutorBuilder;
import org.elasticsearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -165,6 +166,12 @@ public interface PluginServices {
* A provider of utilities to observe and report parsing of documents
*/
DocumentParsingProvider documentParsingProvider();

/**
* The task manager for the node. This should only be used by plugins
* to track task removal by registering a RemovedTaskListener.
*/
TaskManager taskManager();
}

/**
Expand Down

0 comments on commit 3d7c7cf

Please sign in to comment.