Fix node service to still work when http is disabled

This commit is contained in:
Ryan Ernst 2016-07-01 12:55:41 -07:00
parent 6110dcc710
commit 62397c0c3d
2 changed files with 11 additions and 5 deletions

View File

@ -32,6 +32,7 @@ import org.elasticsearch.cluster.routing.allocation.command.CancelAllocationComm
import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Setting;
@ -166,6 +167,8 @@ public class NetworkModule extends AbstractModule {
if (HTTP_ENABLED.get(settings)) {
bind(HttpServer.class).asEagerSingleton();
httpTransportTypes.bindType(binder(), settings, HTTP_TYPE_SETTING.getKey(), NETTY_TRANSPORT);
} else {
bind(HttpServer.class).toProvider(Providers.of(null));
}
// Bind the AllocationCommandRegistry so RestClusterRerouteAction can get it.
bind(AllocationCommandRegistry.class).toInstance(allocationCommandRegistry);

View File

@ -28,6 +28,7 @@ import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
@ -58,14 +59,16 @@ public class NodeService extends AbstractComponent implements Closeable {
private final SettingsFilter settingsFilter;
private ClusterService clusterService;
private ScriptService scriptService;
private final HttpServer httpServer;
@Nullable
private HttpServer httpServer;
private final Discovery discovery;
@Inject
public NodeService(Settings settings, ThreadPool threadPool, MonitorService monitorService,
Discovery discovery, TransportService transportService, IndicesService indicesService,
PluginsService pluginService, CircuitBreakerService circuitBreakerService, HttpServer httpServer,
PluginsService pluginService, CircuitBreakerService circuitBreakerService, @Nullable HttpServer httpServer,
ProcessorsRegistry.Builder processorsRegistryBuilder, ClusterService clusterService, SettingsFilter settingsFilter) {
super(settings);
this.threadPool = threadPool;
@ -98,7 +101,7 @@ public class NodeService extends AbstractComponent implements Closeable {
monitorService.jvmService().info(),
threadPool.info(),
transportService.info(),
httpServer.info(),
httpServer == null ? null : httpServer.info(),
pluginService == null ? null : pluginService.info(),
ingestService == null ? null : ingestService.info(),
indicesService.getTotalIndexingBufferBytes()
@ -114,7 +117,7 @@ public class NodeService extends AbstractComponent implements Closeable {
jvm ? monitorService.jvmService().info() : null,
threadPool ? this.threadPool.info() : null,
transport ? transportService.info() : null,
http ? httpServer.info() : null,
http ? (httpServer == null ? null : httpServer.info()) : null,
plugin ? (pluginService == null ? null : pluginService.info()) : null,
ingest ? (ingestService == null ? null : ingestService.info()) : null,
indices ? indicesService.getTotalIndexingBufferBytes() : null
@ -132,7 +135,7 @@ public class NodeService extends AbstractComponent implements Closeable {
threadPool.stats(),
monitorService.fsService().stats(),
transportService.stats(),
httpServer.stats(),
httpServer == null ? null : httpServer.stats(),
circuitBreakerService.stats(),
scriptService.stats(),
discovery.stats(),