|
@@ -36,6 +36,7 @@ import org.elasticsearch.action.update.UpdateHelper;
|
|
|
import org.elasticsearch.bootstrap.BootstrapCheck;
|
|
|
import org.elasticsearch.client.Client;
|
|
|
import org.elasticsearch.client.node.NodeClient;
|
|
|
+import org.elasticsearch.cluster.ClusterInfo;
|
|
|
import org.elasticsearch.cluster.ClusterInfoService;
|
|
|
import org.elasticsearch.cluster.ClusterModule;
|
|
|
import org.elasticsearch.cluster.ClusterState;
|
|
@@ -50,6 +51,7 @@ import org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeService;
|
|
|
import org.elasticsearch.cluster.metadata.TemplateUpgradeService;
|
|
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
|
|
import org.elasticsearch.cluster.routing.RoutingService;
|
|
|
+import org.elasticsearch.cluster.routing.allocation.DiskThresholdMonitor;
|
|
|
import org.elasticsearch.cluster.service.ClusterService;
|
|
|
import org.elasticsearch.common.StopWatch;
|
|
|
import org.elasticsearch.common.component.Lifecycle;
|
|
@@ -225,6 +227,7 @@ public class Node implements Closeable {
|
|
|
private final NodeClient client;
|
|
|
private final Collection<LifecycleComponent> pluginLifecycleComponents;
|
|
|
private final LocalNodeFactory localNodeFactory;
|
|
|
+ private final NodeService nodeService;
|
|
|
|
|
|
/**
|
|
|
* Constructs a node with the given settings.
|
|
@@ -333,7 +336,10 @@ public class Node implements Closeable {
|
|
|
resourcesToClose.add(clusterService);
|
|
|
final IngestService ingestService = new IngestService(clusterService.getClusterSettings(), settings, threadPool, this.environment,
|
|
|
scriptModule.getScriptService(), analysisModule.getAnalysisRegistry(), pluginsService.filterPlugins(IngestPlugin.class));
|
|
|
- final ClusterInfoService clusterInfoService = newClusterInfoService(settings, clusterService, threadPool, client);
|
|
|
+ final DiskThresholdMonitor listener = new DiskThresholdMonitor(settings, clusterService::state,
|
|
|
+ clusterService.getClusterSettings(), client);
|
|
|
+ final ClusterInfoService clusterInfoService = newClusterInfoService(settings, clusterService, threadPool, client,
|
|
|
+ listener::onNewInfo);
|
|
|
final UsageService usageService = new UsageService(settings);
|
|
|
|
|
|
ModulesBuilder modules = new ModulesBuilder();
|
|
@@ -342,7 +348,6 @@ public class Node implements Closeable {
|
|
|
modules.add(pluginModule);
|
|
|
}
|
|
|
final MonitorService monitorService = new MonitorService(settings, nodeEnvironment, threadPool, clusterInfoService);
|
|
|
- modules.add(new NodeModule(this, monitorService));
|
|
|
ClusterModule clusterModule = new ClusterModule(settings, clusterService,
|
|
|
pluginsService.filterPlugins(ClusterPlugin.class), clusterInfoService);
|
|
|
modules.add(clusterModule);
|
|
@@ -438,10 +443,11 @@ public class Node implements Closeable {
|
|
|
networkService, clusterService.getMasterService(), clusterService.getClusterApplierService(),
|
|
|
clusterService.getClusterSettings(), pluginsService.filterPlugins(DiscoveryPlugin.class),
|
|
|
clusterModule.getAllocationService());
|
|
|
- NodeService nodeService = new NodeService(settings, threadPool, monitorService, discoveryModule.getDiscovery(),
|
|
|
+ this.nodeService = new NodeService(settings, threadPool, monitorService, discoveryModule.getDiscovery(),
|
|
|
transportService, indicesService, pluginsService, circuitBreakerService, scriptModule.getScriptService(),
|
|
|
httpServerTransport, ingestService, clusterService, settingsModule.getSettingsFilter());
|
|
|
modules.add(b -> {
|
|
|
+ b.bind(Node.class).toInstance(this);
|
|
|
b.bind(NodeService.class).toInstance(nodeService);
|
|
|
b.bind(NamedXContentRegistry.class).toInstance(xContentRegistry);
|
|
|
b.bind(PluginsService.class).toInstance(pluginsService);
|
|
@@ -457,7 +463,7 @@ public class Node implements Closeable {
|
|
|
b.bind(ScriptService.class).toInstance(scriptModule.getScriptService());
|
|
|
b.bind(AnalysisRegistry.class).toInstance(analysisModule.getAnalysisRegistry());
|
|
|
b.bind(IngestService.class).toInstance(ingestService);
|
|
|
- b.bind(UsageService.class).toInstance(usageService);
|
|
|
+ b.bind(UsageService.class).toInstance(usageService);
|
|
|
b.bind(NamedWriteableRegistry.class).toInstance(namedWriteableRegistry);
|
|
|
b.bind(MetaDataUpgrader.class).toInstance(metaDataUpgrader);
|
|
|
b.bind(MetaStateService.class).toInstance(metaStateService);
|
|
@@ -590,7 +596,7 @@ public class Node implements Closeable {
|
|
|
injector.getInstance(SnapshotShardsService.class).start();
|
|
|
injector.getInstance(RoutingService.class).start();
|
|
|
injector.getInstance(SearchService.class).start();
|
|
|
- injector.getInstance(MonitorService.class).start();
|
|
|
+ nodeService.getMonitorService().start();
|
|
|
|
|
|
final ClusterService clusterService = injector.getInstance(ClusterService.class);
|
|
|
|
|
@@ -704,7 +710,7 @@ public class Node implements Closeable {
|
|
|
injector.getInstance(RoutingService.class).stop();
|
|
|
injector.getInstance(ClusterService.class).stop();
|
|
|
injector.getInstance(NodeConnectionsService.class).stop();
|
|
|
- injector.getInstance(MonitorService.class).stop();
|
|
|
+ nodeService.getMonitorService().stop();
|
|
|
injector.getInstance(GatewayService.class).stop();
|
|
|
injector.getInstance(SearchService.class).stop();
|
|
|
injector.getInstance(TransportService.class).stop();
|
|
@@ -737,7 +743,7 @@ public class Node implements Closeable {
|
|
|
toClose.add(() -> stopWatch.start("tribe"));
|
|
|
toClose.add(injector.getInstance(TribeService.class));
|
|
|
toClose.add(() -> stopWatch.stop().start("node_service"));
|
|
|
- toClose.add(injector.getInstance(NodeService.class));
|
|
|
+ toClose.add(nodeService);
|
|
|
toClose.add(() -> stopWatch.stop().start("http"));
|
|
|
if (NetworkModule.HTTP_ENABLED.get(settings)) {
|
|
|
toClose.add(injector.getInstance(HttpServerTransport.class));
|
|
@@ -762,7 +768,7 @@ public class Node implements Closeable {
|
|
|
toClose.add(() -> stopWatch.stop().start("discovery"));
|
|
|
toClose.add(injector.getInstance(Discovery.class));
|
|
|
toClose.add(() -> stopWatch.stop().start("monitor"));
|
|
|
- toClose.add(injector.getInstance(MonitorService.class));
|
|
|
+ toClose.add(nodeService.getMonitorService());
|
|
|
toClose.add(() -> stopWatch.stop().start("gateway"));
|
|
|
toClose.add(injector.getInstance(GatewayService.class));
|
|
|
toClose.add(() -> stopWatch.stop().start("search"));
|
|
@@ -917,8 +923,8 @@ public class Node implements Closeable {
|
|
|
|
|
|
/** Constructs a ClusterInfoService which may be mocked for tests. */
|
|
|
protected ClusterInfoService newClusterInfoService(Settings settings, ClusterService clusterService,
|
|
|
- ThreadPool threadPool, NodeClient client) {
|
|
|
- return new InternalClusterInfoService(settings, clusterService, threadPool, client);
|
|
|
+ ThreadPool threadPool, NodeClient client, Consumer<ClusterInfo> listeners) {
|
|
|
+ return new InternalClusterInfoService(settings, clusterService, threadPool, client, listeners);
|
|
|
}
|
|
|
|
|
|
private static class LocalNodeFactory implements Function<BoundTransportAddress, DiscoveryNode> {
|