Move generateCustomNameResolvers to DiscoveryPlugin interface
This commit is contained in:
parent
e9339a1960
commit
e949101cc7
|
@ -64,7 +64,7 @@ import java.util.List;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.elasticsearch.node.Node.generateCustomNameResolvers;
|
||||
import static org.elasticsearch.plugins.DiscoveryPlugin.generateCustomNameResolvers;
|
||||
|
||||
/**
|
||||
* The transport client allows to create a client that is not part of the cluster, but simply connects to one
|
||||
|
|
|
@ -135,6 +135,8 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.elasticsearch.plugins.DiscoveryPlugin.generateCustomNameResolvers;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -723,19 +725,4 @@ public class Node implements Closeable {
|
|||
BigArrays createBigArrays(Settings settings, CircuitBreakerService 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ import org.elasticsearch.index.analysis.TokenFilterFactory;
|
|||
import org.elasticsearch.index.analysis.TokenizerFactory;
|
||||
import org.elasticsearch.indices.analysis.AnalysisModule.AnalysisProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
@ -55,4 +57,19 @@ public interface DiscoveryPlugin {
|
|||
default NetworkService.CustomNameResolver getCustomNameResolver(Settings settings) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Custom Name Resolvers list based on a Discovery Plugins list
|
||||
* @param discoveryPlugins Discovery plugins list
|
||||
*/
|
||||
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