Skip to content

Commit 3afe59f

Browse files
committed
Move AzureUnicastHostsProvider to AzureDiscoveryModule
Related to #9099 Closes #48
1 parent dee924b commit 3afe59f

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

src/main/java/org/elasticsearch/discovery/azure/AzureDiscovery.java

+2-28
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,16 @@
1919

2020
package org.elasticsearch.discovery.azure;
2121

22-
import org.elasticsearch.Version;
23-
import org.elasticsearch.cloud.azure.AzureComputeService;
2422
import org.elasticsearch.cluster.ClusterName;
2523
import org.elasticsearch.cluster.ClusterService;
2624
import org.elasticsearch.cluster.node.DiscoveryNodeService;
2725
import org.elasticsearch.cluster.settings.DynamicSettings;
28-
import org.elasticsearch.common.collect.ImmutableList;
2926
import org.elasticsearch.common.inject.Inject;
30-
import org.elasticsearch.common.network.NetworkService;
3127
import org.elasticsearch.common.settings.Settings;
3228
import org.elasticsearch.discovery.DiscoverySettings;
3329
import org.elasticsearch.discovery.zen.ZenDiscovery;
3430
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
35-
import org.elasticsearch.discovery.zen.ping.ZenPing;
3631
import org.elasticsearch.discovery.zen.ping.ZenPingService;
37-
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
3832
import org.elasticsearch.node.settings.NodeSettingsService;
3933
import org.elasticsearch.threadpool.ThreadPool;
4034
import org.elasticsearch.transport.TransportService;
@@ -49,29 +43,9 @@ public class AzureDiscovery extends ZenDiscovery {
4943
@Inject
5044
public AzureDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService,
5145
ClusterService clusterService, NodeSettingsService nodeSettingsService, ZenPingService pingService,
52-
DiscoveryNodeService discoveryNodeService, AzureComputeService azureService, NetworkService networkService,
53-
DiscoverySettings discoverySettings, ElectMasterService electMasterService, DynamicSettings dynamicSettings,
54-
Version version) {
46+
DiscoveryNodeService discoveryNodeService,
47+
DiscoverySettings discoverySettings, ElectMasterService electMasterService, DynamicSettings dynamicSettings) {
5548
super(settings, clusterName, threadPool, transportService, clusterService, nodeSettingsService,
5649
discoveryNodeService, pingService, electMasterService, discoverySettings, dynamicSettings);
57-
if (settings.getAsBoolean("cloud.enabled", true)) {
58-
ImmutableList<? extends ZenPing> zenPings = pingService.zenPings();
59-
UnicastZenPing unicastZenPing = null;
60-
for (ZenPing zenPing : zenPings) {
61-
if (zenPing instanceof UnicastZenPing) {
62-
unicastZenPing = (UnicastZenPing) zenPing;
63-
break;
64-
}
65-
}
66-
67-
if (unicastZenPing != null) {
68-
// update the unicast zen ping to add cloud hosts provider
69-
// and, while we are at it, use only it and not the multicast for example
70-
unicastZenPing.addHostsProvider(new AzureUnicastHostsProvider(settings, azureService, transportService, networkService, version));
71-
pingService.zenPings(ImmutableList.of(unicastZenPing));
72-
} else {
73-
logger.warn("failed to apply azure unicast discovery, no unicast ping found");
74-
}
75-
}
7650
}
7751
}

src/main/java/org/elasticsearch/discovery/azure/AzureDiscoveryModule.java

+4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ public AzureDiscoveryModule(Settings settings) {
4040
super();
4141
this.logger = Loggers.getLogger(getClass(), settings);
4242
this.settings = settings;
43+
if (AzureModule.isDiscoveryReady(settings, logger)) {
44+
addUnicastHostProvider(AzureUnicastHostsProvider.class);
45+
}
4346
}
47+
4448
@Override
4549
protected void bindDiscovery() {
4650
if (AzureModule.isDiscoveryReady(settings, logger)) {

0 commit comments

Comments
 (0)