Skip to content

Commit

Permalink
javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
ywelsch committed Jun 22, 2018
1 parent e4cec9a commit 0d54fd2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@

import static java.util.Collections.emptyList;

/**
* An implementation of {@link UnicastHostsProvider} that reads hosts/ports
* from the "discovery.zen.ping.unicast.hosts" node setting. If the port is
* left off an entry, a default port of 9300 is assumed.
*
* An example unicast hosts setting might look as follows:
* [67.81.244.10, 67.81.244.11:9305, 67.81.244.15:9400]
*/
public class SettingsBasedHostsProvider extends AbstractComponent implements UnicastHostsProvider {

public static final Setting<List<String>> DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING =
Setting.listSetting("discovery.zen.ping.unicast.hosts", emptyList(), Function.identity(),
Setting.Property.NodeScope);
Setting.listSetting("discovery.zen.ping.unicast.hosts", emptyList(), Function.identity(), Setting.Property.NodeScope);

// these limits are per-address
public static final int LIMIT_FOREIGN_PORTS_COUNT = 1;
Expand All @@ -49,7 +56,7 @@ public SettingsBasedHostsProvider(Settings settings, TransportService transportS

if (DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.exists(settings)) {
configuredHosts = DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.get(settings);
// we only limit to 1 addresses, makes no sense to ping 100 ports
// we only limit to 1 address, makes no sense to ping 100 ports
limitPortCounts = LIMIT_FOREIGN_PORTS_COUNT;
} else {
// if unicast hosts are not specified, fill with simple defaults on the local machine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public interface UnicastHostsProvider {
*/
List<TransportAddress> buildDynamicHosts(HostsResolver hostsResolver);

/**
* Helper object that allows to resolve a list of hosts to a list of transport addresses.
* Each host is resolved into a transport address (or a collection of addresses if the
* number of ports is greater than one)
*/
interface HostsResolver {
List<TransportAddress> resolveHosts(List<String> hosts, int limitPortCounts);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ public UnicastZenPing(Settings settings, ThreadPool threadPool, TransportService
}

/**
* Resolves a list of hosts to a list of discovery nodes. Each host is resolved into a transport address (or a collection of addresses
* if the number of ports is greater than one) and the transport addresses are used to created discovery nodes. Host lookups are done
* in parallel using specified executor service up to the specified resolve timeout.
* Resolves a list of hosts to a list of transport addresses. Each host is resolved into a transport address (or a collection of
* addresses if the number of ports is greater than one). Host lookups are done in parallel using specified executor service up
* to the specified resolve timeout.
*
* @param executorService the executor service used to parallelize hostname lookups
* @param logger logger used for logging messages regarding hostname lookups
Expand Down

0 comments on commit 0d54fd2

Please sign in to comment.