|
152 | 152 | import java.util.Collections; |
153 | 153 | import java.util.List; |
154 | 154 | import java.util.Map; |
155 | | -import java.util.concurrent.CopyOnWriteArrayList; |
156 | 155 | import java.util.concurrent.CountDownLatch; |
157 | 156 | import java.util.concurrent.TimeUnit; |
158 | 157 | import java.util.function.Consumer; |
@@ -229,7 +228,6 @@ public static final Settings addNodeNameIfNeeded(Settings settings, final String |
229 | 228 | private final Collection<LifecycleComponent> pluginLifecycleComponents; |
230 | 229 | private final LocalNodeFactory localNodeFactory; |
231 | 230 | private final NodeService nodeService; |
232 | | - private final List<Runnable> onStartedListeners = new CopyOnWriteArrayList<>(); |
233 | 231 |
|
234 | 232 | /** |
235 | 233 | * Constructs a node with the given settings. |
@@ -394,7 +392,9 @@ protected Node(final Environment environment, Collection<Class<? extends Plugin> |
394 | 392 |
|
395 | 393 | Collection<Object> pluginComponents = pluginsService.filterPlugins(Plugin.class).stream() |
396 | 394 | .flatMap(p -> p.createComponents(client, clusterService, threadPool, resourceWatcherService, |
397 | | - scriptModule.getScriptService(), xContentRegistry).stream()) |
| 395 | + scriptModule.getScriptService(), xContentRegistry, environment, nodeEnvironment, |
| 396 | + namedWriteableRegistry, |
| 397 | + (settings, configPath) -> newNode(settings, classpathPlugins, configPath)).stream()) |
398 | 398 | .collect(Collectors.toList()); |
399 | 399 | final RestController restController = actionModule.getRestController(); |
400 | 400 | final NetworkModule networkModule = new NetworkModule(settings, false, pluginsService.filterPlugins(NetworkPlugin.class), |
@@ -439,7 +439,6 @@ protected Node(final Environment environment, Collection<Class<? extends Plugin> |
439 | 439 | transportService, indicesService, pluginsService, circuitBreakerService, scriptModule.getScriptService(), |
440 | 440 | httpServerTransport, ingestService, clusterService, settingsModule.getSettingsFilter()); |
441 | 441 | modules.add(b -> { |
442 | | - b.bind(NodeBuilder.class).toInstance(new NodeBuilder(this, classpathPlugins)); |
443 | 442 | b.bind(Node.class).toInstance(this); |
444 | 443 | b.bind(NodeService.class).toInstance(nodeService); |
445 | 444 | b.bind(NamedXContentRegistry.class).toInstance(xContentRegistry); |
@@ -517,10 +516,6 @@ protected Node(final Environment environment, Collection<Class<? extends Plugin> |
517 | 516 | } |
518 | 517 | } |
519 | 518 |
|
520 | | - public void addOnStartedListener(Runnable runnable) { |
521 | | - onStartedListeners.add(runnable); |
522 | | - } |
523 | | - |
524 | 519 | // visible for testing |
525 | 520 | static void warnIfPreRelease(final Version version, final boolean isSnapshot, final Logger logger) { |
526 | 521 | if (!version.isRelease() || isSnapshot) { |
@@ -674,7 +669,7 @@ public void onTimeout(TimeValue timeout) { |
674 | 669 |
|
675 | 670 | logger.info("started"); |
676 | 671 |
|
677 | | - onStartedListeners.forEach(Runnable::run); |
| 672 | + pluginsService.filterPlugins(ClusterPlugin.class).forEach(ClusterPlugin::onNodeStarted); |
678 | 673 |
|
679 | 674 | return this; |
680 | 675 | } |
@@ -908,21 +903,6 @@ private List<NetworkService.CustomNameResolver> getCustomNameResolvers(List<Disc |
908 | 903 | return customNameResolvers; |
909 | 904 | } |
910 | 905 |
|
911 | | - public static class NodeBuilder { |
912 | | - |
913 | | - private final Node node; |
914 | | - private final Collection<Class<? extends Plugin>> classpathPlugins; |
915 | | - |
916 | | - public NodeBuilder(Node node, Collection<Class<? extends Plugin>> classpathPlugins) { |
917 | | - this.node = node; |
918 | | - this.classpathPlugins = classpathPlugins; |
919 | | - } |
920 | | - |
921 | | - public Node newNode(Settings settings, Path configPath) { |
922 | | - return node.newNode(settings, classpathPlugins, configPath); |
923 | | - } |
924 | | - } |
925 | | - |
926 | 906 | /** Constructs a new node based on the following settings. Overridden by tests */ |
927 | 907 | protected Node newNode(Settings settings, Collection<Class<? extends Plugin>> classpathPlugins, Path configPath) { |
928 | 908 | return new Node(new Environment(settings, configPath), classpathPlugins); |
|
0 commit comments