Move registerCustomNameResolvers to Node class and rename it
This commit is contained in:
parent
1c03d0bb2a
commit
b62bb47663
|
@ -64,7 +64,7 @@ import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.elasticsearch.common.network.NetworkService.registerCustomNameResolvers;
|
import static org.elasticsearch.node.Node.generateCustomNameResolvers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The transport client allows to create a client that is not part of the cluster, but simply connects to one
|
* The transport client allows to create a client that is not part of the cluster, but simply connects to one
|
||||||
|
@ -112,7 +112,7 @@ public abstract class TransportClient extends AbstractClient {
|
||||||
final ThreadPool threadPool = new ThreadPool(settings);
|
final ThreadPool threadPool = new ThreadPool(settings);
|
||||||
resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS));
|
resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS));
|
||||||
final NetworkService networkService = new NetworkService(settings,
|
final NetworkService networkService = new NetworkService(settings,
|
||||||
registerCustomNameResolvers(settings, pluginsService.filterPlugins(DiscoveryPlugin.class)));
|
generateCustomNameResolvers(settings, pluginsService.filterPlugins(DiscoveryPlugin.class)));
|
||||||
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
|
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
|
||||||
try {
|
try {
|
||||||
final List<Setting<?>> additionalSettings = new ArrayList<>();
|
final List<Setting<?>> additionalSettings = new ArrayList<>();
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.elasticsearch.common.settings.Setting.Property;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.plugins.DiscoveryPlugin;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
@ -270,19 +269,4 @@ public class NetworkService extends AbstractComponent {
|
||||||
}
|
}
|
||||||
return InetAddress.getAllByName(host);
|
return InetAddress.getAllByName(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register custom name resolver a DiscoveryPlugin might provide
|
|
||||||
* @param discoveryPlugins Discovery plugins
|
|
||||||
*/
|
|
||||||
public static List<CustomNameResolver> registerCustomNameResolvers(Settings settings, List<DiscoveryPlugin> discoveryPlugins) {
|
|
||||||
List<CustomNameResolver> customNameResolvers = new ArrayList<>();
|
|
||||||
for (DiscoveryPlugin discoveryPlugin : discoveryPlugins) {
|
|
||||||
NetworkService.CustomNameResolver customNameResolver = discoveryPlugin.getCustomNameResolver(settings);
|
|
||||||
if (customNameResolver != null) {
|
|
||||||
customNameResolvers.add(customNameResolver);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return customNameResolvers;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,8 +135,6 @@ import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.elasticsearch.common.network.NetworkService.registerCustomNameResolvers;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A node represent a node within a cluster (<tt>cluster.name</tt>). The {@link #client()} can be used
|
* A node represent a node within a cluster (<tt>cluster.name</tt>). The {@link #client()} can be used
|
||||||
* in order to use a {@link Client} to perform actions/operations against the cluster.
|
* in order to use a {@link Client} to perform actions/operations against the cluster.
|
||||||
|
@ -298,7 +296,7 @@ public class Node implements Closeable {
|
||||||
final SettingsModule settingsModule = new SettingsModule(this.settings, additionalSettings, additionalSettingsFilter);
|
final SettingsModule settingsModule = new SettingsModule(this.settings, additionalSettings, additionalSettingsFilter);
|
||||||
resourcesToClose.add(resourceWatcherService);
|
resourcesToClose.add(resourceWatcherService);
|
||||||
final NetworkService networkService = new NetworkService(settings,
|
final NetworkService networkService = new NetworkService(settings,
|
||||||
registerCustomNameResolvers(settings, pluginsService.filterPlugins(DiscoveryPlugin.class)));
|
generateCustomNameResolvers(settings, pluginsService.filterPlugins(DiscoveryPlugin.class)));
|
||||||
final ClusterService clusterService = new ClusterService(settings, settingsModule.getClusterSettings(), threadPool);
|
final ClusterService clusterService = new ClusterService(settings, settingsModule.getClusterSettings(), threadPool);
|
||||||
clusterService.add(scriptModule.getScriptService());
|
clusterService.add(scriptModule.getScriptService());
|
||||||
resourcesToClose.add(clusterService);
|
resourcesToClose.add(clusterService);
|
||||||
|
@ -725,4 +723,19 @@ public class Node implements Closeable {
|
||||||
BigArrays createBigArrays(Settings settings, CircuitBreakerService circuitBreakerService) {
|
BigArrays createBigArrays(Settings settings, CircuitBreakerService circuitBreakerService) {
|
||||||
return new BigArrays(settings, circuitBreakerService);
|
return new BigArrays(settings, circuitBreakerService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate Custom Name Resolvers list based on a Discovery Plugins list
|
||||||
|
* @param discoveryPlugins Discovery plugins list
|
||||||
|
*/
|
||||||
|
public static List<NetworkService.CustomNameResolver> generateCustomNameResolvers(Settings settings, List<DiscoveryPlugin> discoveryPlugins) {
|
||||||
|
List<NetworkService.CustomNameResolver> customNameResolvers = new ArrayList<>();
|
||||||
|
for (DiscoveryPlugin discoveryPlugin : discoveryPlugins) {
|
||||||
|
NetworkService.CustomNameResolver customNameResolver = discoveryPlugin.getCustomNameResolver(settings);
|
||||||
|
if (customNameResolver != null) {
|
||||||
|
customNameResolvers.add(customNameResolver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return customNameResolvers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue