From 244cd422985792e67814867dddd7661ccf332290 Mon Sep 17 00:00:00 2001 From: kimchy Date: Wed, 25 Aug 2010 00:44:04 +0300 Subject: [PATCH] allow to use just hosts when using unicast discover, will use the transport level ports --- .../transport/netty/NettyTransport.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java index 0ddc47828f8..908dcd391fb 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java @@ -340,11 +340,17 @@ public class NettyTransport extends AbstractLifecycleComponent implem } else { index = address.lastIndexOf(':'); if (index == -1) { - throw new ElasticSearchIllegalStateException("Port must be provided to create inet address from [" + address + "]"); + List 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)}; } - String host = address.substring(0, index); - int port = Integer.parseInt(address.substring(index + 1)); - return new TransportAddress[]{new InetSocketTransportAddress(host, port)}; } }