Skip to content

Commit

Permalink
set the node service on the discovery to get the additional service l…
Browse files Browse the repository at this point in the history
…evel attributes (issue #1532)
  • Loading branch information
kimchy committed Dec 12, 2011
1 parent 775339d commit ce99948
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/main/java/org/elasticsearch/discovery/Discovery.java
Expand Up @@ -24,13 +24,13 @@
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<Discovery> {

Expand All @@ -44,6 +44,11 @@ public interface Discovery extends LifecycleComponent<Discovery> {

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...).
Expand Down
Expand Up @@ -29,9 +29,11 @@
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;
Expand Down Expand Up @@ -82,6 +84,11 @@ public LocalDiscovery(Settings settings, ClusterName clusterName, TransportServi
this.discoveryNodeService = discoveryNodeService;
}

@Override
public void setNodeService(@Nullable NodeService nodeService) {
// nothing to do here
}

@Override
protected void doStart() throws ElasticSearchException {
synchronized (clusterGroups) {
Expand Down
Expand Up @@ -142,6 +142,7 @@ public ZenDiscovery(Settings settings, ClusterName clusterName, ThreadPool threa
this.membership = new MembershipAction(settings, transportService, this, new MembershipListener());
}

@Override
public void setNodeService(@Nullable NodeService nodeService) {
this.nodeService = nodeService;
}
Expand Down
Expand Up @@ -28,6 +28,7 @@
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;
Expand All @@ -51,12 +52,13 @@ public class NodeService extends AbstractComponent {
private volatile ImmutableMap<String, String> 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) {
Expand Down

0 comments on commit ce99948

Please sign in to comment.