Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/reference/modules/discovery/zen.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ as gossip routers. It provides the following settings with the
|=======================================================================
|Setting |Description
|`hosts` |Either an array setting or a comma delimited setting. Each
value is either in the form of `host:port`, or in the form of
`host[port1-port2]`.
value is in the form of `host:port`.
|=======================================================================

The unicast discovery uses the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen

public static final String ACTION_NAME = "internal:discovery/zen/unicast";

public static final int LIMIT_PORTS_COUNT = 1;

private final ThreadPool threadPool;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked with @kimchy a while ago about increasing LIMIT_PORTS_COUNT to 2.
See thread here: elastic/elasticsearch-cloud-aws#99 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the related issue here: #7090

private final TransportService transportService;
private final ClusterName clusterName;
Expand Down Expand Up @@ -111,11 +109,8 @@ public UnicastZenPing(Settings settings, ThreadPool threadPool, TransportService
int idCounter = 0;
for (String host : hosts) {
try {
TransportAddress[] addresses = transportService.addressesFromString(host);
// we only limit to 1 addresses, makes no sense to ping 100 ports
for (int i = 0; (i < addresses.length && i < LIMIT_PORTS_COUNT); i++) {
configuredTargetNodes.add(new DiscoveryNode("#zen_unicast_" + (++idCounter) + "#", addresses[i], version.minimumCompatibilityVersion()));
}
TransportAddress address = transportService.addressFromString(host);
configuredTargetNodes.add(new DiscoveryNode("#zen_unicast_" + (++idCounter) + "#", address, version.minimumCompatibilityVersion()));
} catch (Exception e) {
throw new ElasticsearchIllegalArgumentException("Failed to resolve address for [" + host + "]", e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/elasticsearch/transport/Transport.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static class TransportSettings {
/**
* Returns an address from its string representation.
*/
TransportAddress[] addressesFromString(String address) throws Exception;
TransportAddress addressFromString(String address) throws Exception;

/**
* Is the address type supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ private long newRequestId() {
return requestIds.getAndIncrement();
}

public TransportAddress[] addressesFromString(String address) throws Exception {
return transport.addressesFromString(address);
public TransportAddress addressFromString(String address) throws Exception {
return transport.addressFromString(address);
}

public void registerHandler(String action, TransportRequestHandler handler) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public LocalTransport(Settings settings, ThreadPool threadPool, Version version)
}

@Override
public TransportAddress[] addressesFromString(String address) {
return new TransportAddress[]{new LocalTransportAddress(address)};
public TransportAddress addressFromString(String address) {
return new LocalTransportAddress(address);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,34 +427,12 @@ protected void doClose() throws ElasticsearchException {
}

@Override
public TransportAddress[] addressesFromString(String address) throws Exception {
int index = address.indexOf('[');
if (index != -1) {
String host = address.substring(0, index);
Set<String> ports = Strings.commaDelimitedListToSet(address.substring(index + 1, address.indexOf(']')));
List<TransportAddress> addresses = Lists.newArrayList();
for (String port : ports) {
int[] iPorts = new PortsRange(port).ports();
for (int iPort : iPorts) {
addresses.add(new InetSocketTransportAddress(host, iPort));
}
}
return addresses.toArray(new TransportAddress[addresses.size()]);
} else {
index = address.lastIndexOf(':');
if (index == -1) {
List<TransportAddress> addresses = Lists.newArrayList();
int[] iPorts = new PortsRange(this.port).ports();
for (int iPort : iPorts) {
addresses.add(new InetSocketTransportAddress(address, iPort));
}
return addresses.toArray(new TransportAddress[addresses.size()]);
} else {
String host = address.substring(0, index);
int port = Integer.parseInt(address.substring(index + 1));
return new TransportAddress[]{new InetSocketTransportAddress(host, port)};
}
public TransportAddress addressFromString(String address) throws Exception {
int index = address.lastIndexOf(':');
if (index == -1) {
return new InetSocketTransportAddress(address, Integer.parseInt(this.port));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will not work, right? cause the default is 9300-9400, which is good, since we want to try another port on the second instance we start on the same machine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused here. This is not about binding to a port when starting, only about connecting to other nodes, as far as I can judge the source codes. Starting up several nodes in parallel on one machines still works as expected

}
return new InetSocketTransportAddress(address.substring(0, index), Integer.parseInt(address.substring(index + 1)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public BoundTransportAddress boundAddress() {
}

@Override
public TransportAddress[] addressesFromString(String address) throws Exception {
public TransportAddress addressFromString(String address) throws Exception {
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ public BoundTransportAddress boundAddress() {
}

@Override
public TransportAddress[] addressesFromString(String address) throws Exception {
return transport.addressesFromString(address);
public TransportAddress addressFromString(String address) throws Exception {
return transport.addressFromString(address);
}

@Override
Expand Down