diff --git a/src/main/java/org/elasticsearch/discovery/Discovery.java b/src/main/java/org/elasticsearch/discovery/Discovery.java index 5adce51c7c4..c702d98c4b1 100644 --- a/src/main/java/org/elasticsearch/discovery/Discovery.java +++ b/src/main/java/org/elasticsearch/discovery/Discovery.java @@ -24,13 +24,13 @@ import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.component.LifecycleComponent; +import org.elasticsearch.common.inject.internal.Nullable; +import org.elasticsearch.node.service.NodeService; /** * A pluggable module allowing to implement discovery of other nodes, publishing of the cluster * state to all nodes, electing a master of the cluster that raises cluster state change * events. - * - * */ public interface Discovery extends LifecycleComponent { @@ -44,6 +44,11 @@ public interface Discovery extends LifecycleComponent { String nodeDescription(); + /** + * Here as a hack to solve dep injection problem... + */ + void setNodeService(@Nullable NodeService nodeService); + /** * Publish all the changes to the cluster from the master (can be called just by the master). The publish * process should not publish this state to the master as well! (the master is sending it...). diff --git a/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java b/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java index 97bd6d9d46b..e10dd070d88 100644 --- a/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java +++ b/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java @@ -29,9 +29,11 @@ import org.elasticsearch.cluster.node.DiscoveryNodeService; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.inject.internal.Nullable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.discovery.Discovery; import org.elasticsearch.discovery.InitialStateDiscoveryListener; +import org.elasticsearch.node.service.NodeService; import org.elasticsearch.transport.TransportService; import java.util.Queue; @@ -82,6 +84,11 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem this.discoveryNodeService = discoveryNodeService; } + @Override + public void setNodeService(@Nullable NodeService nodeService) { + // nothing to do here + } + @Override protected void doStart() throws ElasticSearchException { synchronized (clusterGroups) { diff --git a/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java b/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java index a07f3e69b37..efaed31d0cb 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -142,6 +142,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen this.membership = new MembershipAction(settings, transportService, this, new MembershipListener()); } + @Override public void setNodeService(@Nullable NodeService nodeService) { this.nodeService = nodeService; } diff --git a/src/main/java/org/elasticsearch/node/service/NodeService.java b/src/main/java/org/elasticsearch/node/service/NodeService.java index 3728e450f9c..86cc371799e 100644 --- a/src/main/java/org/elasticsearch/node/service/NodeService.java +++ b/src/main/java/org/elasticsearch/node/service/NodeService.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.discovery.Discovery; import org.elasticsearch.http.HttpServer; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.monitor.MonitorService; @@ -51,12 +52,13 @@ public class NodeService extends AbstractComponent { private volatile ImmutableMap serviceAttributes = ImmutableMap.of(); @Inject - public NodeService(Settings settings, MonitorService monitorService, ClusterService clusterService, TransportService transportService, IndicesService indicesService) { + public NodeService(Settings settings, MonitorService monitorService, Discovery discovery, ClusterService clusterService, TransportService transportService, IndicesService indicesService) { super(settings); this.monitorService = monitorService; this.clusterService = clusterService; this.transportService = transportService; this.indicesService = indicesService; + discovery.setNodeService(this); } public void setHttpServer(@Nullable HttpServer httpServer) {