Move AzureUnicastHostsProvider to AzureDiscoveryModule
Related to elasticsearch/elasticsearch#9099 Closes #48
This commit is contained in:
parent
dee924bb05
commit
3afe59ff69
|
@ -19,22 +19,16 @@
|
||||||
|
|
||||||
package org.elasticsearch.discovery.azure;
|
package org.elasticsearch.discovery.azure;
|
||||||
|
|
||||||
import org.elasticsearch.Version;
|
|
||||||
import org.elasticsearch.cloud.azure.AzureComputeService;
|
|
||||||
import org.elasticsearch.cluster.ClusterName;
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNodeService;
|
import org.elasticsearch.cluster.node.DiscoveryNodeService;
|
||||||
import org.elasticsearch.cluster.settings.DynamicSettings;
|
import org.elasticsearch.cluster.settings.DynamicSettings;
|
||||||
import org.elasticsearch.common.collect.ImmutableList;
|
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.network.NetworkService;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.discovery.DiscoverySettings;
|
import org.elasticsearch.discovery.DiscoverySettings;
|
||||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||||
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
||||||
import org.elasticsearch.discovery.zen.ping.ZenPing;
|
|
||||||
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
||||||
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
|
|
||||||
import org.elasticsearch.node.settings.NodeSettingsService;
|
import org.elasticsearch.node.settings.NodeSettingsService;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
@ -49,29 +43,9 @@ public class AzureDiscovery extends ZenDiscovery {
|
||||||
@Inject
|
@Inject
|
||||||
public AzureDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService,
|
public AzureDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService,
|
||||||
ClusterService clusterService, NodeSettingsService nodeSettingsService, ZenPingService pingService,
|
ClusterService clusterService, NodeSettingsService nodeSettingsService, ZenPingService pingService,
|
||||||
DiscoveryNodeService discoveryNodeService, AzureComputeService azureService, NetworkService networkService,
|
DiscoveryNodeService discoveryNodeService,
|
||||||
DiscoverySettings discoverySettings, ElectMasterService electMasterService, DynamicSettings dynamicSettings,
|
DiscoverySettings discoverySettings, ElectMasterService electMasterService, DynamicSettings dynamicSettings) {
|
||||||
Version version) {
|
|
||||||
super(settings, clusterName, threadPool, transportService, clusterService, nodeSettingsService,
|
super(settings, clusterName, threadPool, transportService, clusterService, nodeSettingsService,
|
||||||
discoveryNodeService, pingService, electMasterService, discoverySettings, dynamicSettings);
|
discoveryNodeService, pingService, electMasterService, discoverySettings, dynamicSettings);
|
||||||
if (settings.getAsBoolean("cloud.enabled", true)) {
|
|
||||||
ImmutableList<? extends ZenPing> zenPings = pingService.zenPings();
|
|
||||||
UnicastZenPing unicastZenPing = null;
|
|
||||||
for (ZenPing zenPing : zenPings) {
|
|
||||||
if (zenPing instanceof UnicastZenPing) {
|
|
||||||
unicastZenPing = (UnicastZenPing) zenPing;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unicastZenPing != null) {
|
|
||||||
// update the unicast zen ping to add cloud hosts provider
|
|
||||||
// and, while we are at it, use only it and not the multicast for example
|
|
||||||
unicastZenPing.addHostsProvider(new AzureUnicastHostsProvider(settings, azureService, transportService, networkService, version));
|
|
||||||
pingService.zenPings(ImmutableList.of(unicastZenPing));
|
|
||||||
} else {
|
|
||||||
logger.warn("failed to apply azure unicast discovery, no unicast ping found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,11 @@ public class AzureDiscoveryModule extends ZenDiscoveryModule {
|
||||||
super();
|
super();
|
||||||
this.logger = Loggers.getLogger(getClass(), settings);
|
this.logger = Loggers.getLogger(getClass(), settings);
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
if (AzureModule.isDiscoveryReady(settings, logger)) {
|
||||||
|
addUnicastHostProvider(AzureUnicastHostsProvider.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void bindDiscovery() {
|
protected void bindDiscovery() {
|
||||||
if (AzureModule.isDiscoveryReady(settings, logger)) {
|
if (AzureModule.isDiscoveryReady(settings, logger)) {
|
||||||
|
|
Loading…
Reference in New Issue