elasticsearch 怎么用源码启动 调试
发布网友
发布时间:2022-04-24 05:54
我来回答
共1个回答
热心网友
时间:2023-10-04 05:24
脚本内容不再赘述,java主类位于org.elasticsearch.bootstrap。主要逻辑是生成了一个InternalNode节点,并且启动了一个keepalive线程。结点的启动代表整个es进程启动了。
InternalNode节点是通过NodeBuilder来生成的,节点在构造函数中通过MoleBuilder类来进行模块的注入(是对Guice的一个封装而已),同时生成injector实例,如下
MolesBuilder moles = new MolesBuilder();
moles.add(new Version.Mole(version));
moles.add(new CacheRecyclerMole(settings));
moles.add(new PageCacheRecyclerMole(settings));
moles.add(new BigArraysMole(settings));
moles.add(new PluginsMole(settings, pluginsService));
moles.add(new SettingsMole(settings));
moles.add(new NodeMole(this));
moles.add(new NetworkMole());
moles.add(new ScriptMole(settings));
moles.add(new EnvironmentMole(environment));
moles.add(new NodeEnvironmentMole(nodeEnvironment));
moles.add(new ClusterNameMole(settings));
moles.add(new ThreadPoolMole(settings));
moles.add(new DiscoveryMole(settings));
moles.add(new ClusterMole(settings));
moles.add(new RestMole(settings));
moles.add(new TransportMole(settings));
if (settings.getAsBoolean("http.enabled", true)) {
moles.add(new HttpServerMole(settings));
}
moles.add(new RiversMole(settings));
moles.add(new IndicesMole(settings));
moles.add(new SearchMole());
moles.add(new ActionMole(false));
moles.add(new MonitorMole(settings));
moles.add(new GatewayMole(settings));
moles.add(new NodeClientMole());
moles.add(new BulkUdpMole());
moles.add(new ShapeMole());
moles.add(new PercolatorMole());
moles.add(new ResourceWatcherMole());
moles.add(new RepositoriesMole());
moles.add(new TribeMole());
injector = moles.createInjector();
在InternalNode的start方法中,用injector对各个模块完成启动,各自负责各自的功能,如下:
injector.getInstance(Discovery.class).setAllocationService(injector.getInstance(AllocationService.class));
for (Class<? extends LifecycleComponent> plugin : pluginsService.services()) {
injector.getInstance(plugin).start();
}
injector.getInstance(MappingUpdatedAction.class).start();
injector.getInstance(IndicesService.class).start();
injector.getInstance(IndexingMemoryController.class).start();
injector.getInstance(IndicesClusterStateService.class).start();
injector.getInstance(IndicesTTLService.class).start();
injector.getInstance(RiversManager.class).start();
injector.getInstance(SnapshotsService.class).start();
injector.getInstance(ClusterService.class).start();
injector.getInstance(RoutingService.class).start();
injector.getInstance(SearchService.class).start();
injector.getInstance(MonitorService.class).start();
injector.getInstance(RestController.class).start();
injector.getInstance(TransportService.class).start();
DiscoveryService discoService = injector.getInstance(DiscoveryService.class).start();
discoService.waitForInitialState();
// gateway should start after disco, so it can try and recovery from gateway on "start"
injector.getInstance(GatewayService.class).start();
if (settings.getAsBoolean("http.enabled", true)) {
injector.getInstance(HttpServer.class).start();
}
injector.getInstance(BulkUdpService.class).start();
injector.getInstance(ResourceWatcherService.class).start();
injector.getInstance(TribeService.class).start();
至此,es进程启动完毕。
guice相关介绍可以参见以下链接:
关键点在于:
@inject注释---guice会扫描inject注释,并对方法中出现的参数实例寻找对应注册的实例进行初始化。
热心网友
时间:2023-10-04 05:24
脚本内容不再赘述,java主类位于org.elasticsearch.bootstrap。主要逻辑是生成了一个InternalNode节点,并且启动了一个keepalive线程。结点的启动代表整个es进程启动了。
InternalNode节点是通过NodeBuilder来生成的,节点在构造函数中通过MoleBuilder类来进行模块的注入(是对Guice的一个封装而已),同时生成injector实例,如下
MolesBuilder moles = new MolesBuilder();
moles.add(new Version.Mole(version));
moles.add(new CacheRecyclerMole(settings));
moles.add(new PageCacheRecyclerMole(settings));
moles.add(new BigArraysMole(settings));
moles.add(new PluginsMole(settings, pluginsService));
moles.add(new SettingsMole(settings));
moles.add(new NodeMole(this));
moles.add(new NetworkMole());
moles.add(new ScriptMole(settings));
moles.add(new EnvironmentMole(environment));
moles.add(new NodeEnvironmentMole(nodeEnvironment));
moles.add(new ClusterNameMole(settings));
moles.add(new ThreadPoolMole(settings));
moles.add(new DiscoveryMole(settings));
moles.add(new ClusterMole(settings));
moles.add(new RestMole(settings));
moles.add(new TransportMole(settings));
if (settings.getAsBoolean("http.enabled", true)) {
moles.add(new HttpServerMole(settings));
}
moles.add(new RiversMole(settings));
moles.add(new IndicesMole(settings));
moles.add(new SearchMole());
moles.add(new ActionMole(false));
moles.add(new MonitorMole(settings));
moles.add(new GatewayMole(settings));
moles.add(new NodeClientMole());
moles.add(new BulkUdpMole());
moles.add(new ShapeMole());
moles.add(new PercolatorMole());
moles.add(new ResourceWatcherMole());
moles.add(new RepositoriesMole());
moles.add(new TribeMole());
injector = moles.createInjector();
在InternalNode的start方法中,用injector对各个模块完成启动,各自负责各自的功能,如下:
injector.getInstance(Discovery.class).setAllocationService(injector.getInstance(AllocationService.class));
for (Class<? extends LifecycleComponent> plugin : pluginsService.services()) {
injector.getInstance(plugin).start();
}
injector.getInstance(MappingUpdatedAction.class).start();
injector.getInstance(IndicesService.class).start();
injector.getInstance(IndexingMemoryController.class).start();
injector.getInstance(IndicesClusterStateService.class).start();
injector.getInstance(IndicesTTLService.class).start();
injector.getInstance(RiversManager.class).start();
injector.getInstance(SnapshotsService.class).start();
injector.getInstance(ClusterService.class).start();
injector.getInstance(RoutingService.class).start();
injector.getInstance(SearchService.class).start();
injector.getInstance(MonitorService.class).start();
injector.getInstance(RestController.class).start();
injector.getInstance(TransportService.class).start();
DiscoveryService discoService = injector.getInstance(DiscoveryService.class).start();
discoService.waitForInitialState();
// gateway should start after disco, so it can try and recovery from gateway on "start"
injector.getInstance(GatewayService.class).start();
if (settings.getAsBoolean("http.enabled", true)) {
injector.getInstance(HttpServer.class).start();
}
injector.getInstance(BulkUdpService.class).start();
injector.getInstance(ResourceWatcherService.class).start();
injector.getInstance(TribeService.class).start();
至此,es进程启动完毕。
guice相关介绍可以参见以下链接:
关键点在于:
@inject注释---guice会扫描inject注释,并对方法中出现的参数实例寻找对应注册的实例进行初始化。