|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + * |
| 4 | + * The OpenSearch Contributors require contributions made to |
| 5 | + * this file be licensed under the Apache-2.0 license or a |
| 6 | + * compatible open source license. |
| 7 | + */ |
| 8 | + |
| 9 | +package org.opensearch.plugins; |
| 10 | + |
| 11 | +import org.opensearch.client.Client; |
| 12 | +import org.opensearch.cluster.metadata.IndexNameExpressionResolver; |
| 13 | +import org.opensearch.cluster.service.ClusterService; |
| 14 | +import org.opensearch.common.annotation.ExperimentalApi; |
| 15 | +import org.opensearch.common.lifecycle.LifecycleComponent; |
| 16 | +import org.opensearch.core.common.io.stream.NamedWriteable; |
| 17 | +import org.opensearch.core.common.io.stream.NamedWriteableRegistry; |
| 18 | +import org.opensearch.core.xcontent.NamedXContentRegistry; |
| 19 | +import org.opensearch.env.Environment; |
| 20 | +import org.opensearch.env.NodeEnvironment; |
| 21 | +import org.opensearch.indices.IndicesService; |
| 22 | +import org.opensearch.repositories.RepositoriesService; |
| 23 | +import org.opensearch.script.ScriptService; |
| 24 | +import org.opensearch.telemetry.metrics.MetricsRegistry; |
| 25 | +import org.opensearch.telemetry.tracing.Tracer; |
| 26 | +import org.opensearch.threadpool.ThreadPool; |
| 27 | +import org.opensearch.watcher.ResourceWatcherService; |
| 28 | + |
| 29 | +import java.util.Collection; |
| 30 | +import java.util.Collections; |
| 31 | +import java.util.function.Supplier; |
| 32 | + |
| 33 | +/** |
| 34 | + * Plugin that provides the telemetry registries to build component with telemetry and also provide a way to |
| 35 | + * pass telemetry registries to the implementing plugins for adding instrumentation in the code. |
| 36 | + * |
| 37 | + * @opensearch.experimental |
| 38 | + */ |
| 39 | +@ExperimentalApi |
| 40 | +public interface IndicesAwarePlugin { |
| 41 | + |
| 42 | + /** |
| 43 | + * Returns components added by this plugin. |
| 44 | + * <p> |
| 45 | + * Any components returned that implement {@link LifecycleComponent} will have their lifecycle managed. |
| 46 | + * Note: To aid in the migration away from guice, all objects returned as components will be bound in guice |
| 47 | + * to themselves. |
| 48 | + * |
| 49 | + * @param client A client to make requests to the system |
| 50 | + * @param clusterService A service to allow watching and updating cluster state |
| 51 | + * @param threadPool A service to allow retrieving an executor to run an async action |
| 52 | + * @param resourceWatcherService A service to watch for changes to node local files |
| 53 | + * @param scriptService A service to allow running scripts on the local node |
| 54 | + * @param xContentRegistry the registry for extensible xContent parsing |
| 55 | + * @param environment the environment for path and setting configurations |
| 56 | + * @param nodeEnvironment the node environment used coordinate access to the data paths |
| 57 | + * @param namedWriteableRegistry the registry for {@link NamedWriteable} object parsing |
| 58 | + * @param indexNameExpressionResolver A service that resolves expression to index and alias names |
| 59 | + * @param repositoriesServiceSupplier A supplier for the service that manages snapshot repositories; will return null when this method |
| 60 | + * is called, but will return the repositories service once the node is initialized. |
| 61 | + * @param tracer the tracer to add tracing instrumentation. |
| 62 | + * @param metricsRegistry the registry for metrics instrumentation. |
| 63 | + * @param indicesService A service to track indices |
| 64 | + */ |
| 65 | + default Collection<Object> createComponents( |
| 66 | + Client client, |
| 67 | + ClusterService clusterService, |
| 68 | + ThreadPool threadPool, |
| 69 | + ResourceWatcherService resourceWatcherService, |
| 70 | + ScriptService scriptService, |
| 71 | + NamedXContentRegistry xContentRegistry, |
| 72 | + Environment environment, |
| 73 | + NodeEnvironment nodeEnvironment, |
| 74 | + NamedWriteableRegistry namedWriteableRegistry, |
| 75 | + IndexNameExpressionResolver indexNameExpressionResolver, |
| 76 | + Supplier<RepositoriesService> repositoriesServiceSupplier, |
| 77 | + Tracer tracer, |
| 78 | + MetricsRegistry metricsRegistry, |
| 79 | + IndicesService indicesService |
| 80 | + ) { |
| 81 | + return Collections.emptyList(); |
| 82 | + } |
| 83 | +} |
0 commit comments