set the node service on the discovery to get the additional service level attributes (issue #1532)

This commit is contained in:
Shay Banon 2011-12-12 20:22:19 +02:00
parent 775339d78a
commit ce999489d5
4 changed files with 18 additions and 3 deletions

View File

@ -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<Discovery> {
@ -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...).

View File

@ -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<Discovery> implem
this.discoveryNodeService = discoveryNodeService;
}
@Override
public void setNodeService(@Nullable NodeService nodeService) {
// nothing to do here
}
@Override
protected void doStart() throws ElasticSearchException {
synchronized (clusterGroups) {

View File

@ -142,6 +142,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
this.membership = new MembershipAction(settings, transportService, this, new MembershipListener());
}
@Override
public void setNodeService(@Nullable NodeService nodeService) {
this.nodeService = nodeService;
}

View File

@ -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<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) {