diff --git a/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerConfig.java b/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerConfig.java index 17e4ebcddcf..e33a9c30fb5 100644 --- a/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerConfig.java +++ b/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerConfig.java @@ -93,7 +93,7 @@ public class HadoopDruidIndexerConfig public void configure(Binder binder) { JsonConfigProvider.bindInstance( - binder, Key.get(DruidNode.class, Self.class), new DruidNode("hadoop-indexer", "localhost", 0) + binder, Key.get(DruidNode.class, Self.class), new DruidNode("hadoop-indexer", null, null) ); } } diff --git a/server/src/main/java/io/druid/server/DruidNode.java b/server/src/main/java/io/druid/server/DruidNode.java index 363a5614df4..eef71a40886 100644 --- a/server/src/main/java/io/druid/server/DruidNode.java +++ b/server/src/main/java/io/druid/server/DruidNode.java @@ -131,7 +131,11 @@ public class DruidNode * Returns host and port together as something that can be used as part of a URI. */ public String getHostAndPort() { - return HostAndPort.fromParts(host, port).toString(); + if(port < 0) { + return HostAndPort.fromString(host).toString(); + } else { + return HostAndPort.fromParts(host, port).toString(); + } } @Override diff --git a/server/src/test/java/io/druid/initialization/InitializationTest.java b/server/src/test/java/io/druid/initialization/InitializationTest.java index 22953708cdd..2dce7260796 100644 --- a/server/src/test/java/io/druid/initialization/InitializationTest.java +++ b/server/src/test/java/io/druid/initialization/InitializationTest.java @@ -109,7 +109,7 @@ public class InitializationTest public void configure(Binder binder) { JsonConfigProvider.bindInstance( - binder, Key.get(DruidNode.class, Self.class), new DruidNode("test-inject", "localhost", 0) + binder, Key.get(DruidNode.class, Self.class), new DruidNode("test-inject", null, null) ); } } diff --git a/server/src/test/java/io/druid/server/DruidNodeTest.java b/server/src/test/java/io/druid/server/DruidNodeTest.java index 96721dece00..4679c480c11 100644 --- a/server/src/test/java/io/druid/server/DruidNodeTest.java +++ b/server/src/test/java/io/druid/server/DruidNodeTest.java @@ -34,6 +34,12 @@ public class DruidNodeTest node = new DruidNode(service, null, null); Assert.assertEquals(DruidNode.DEFAULT_HOST, node.getHost()); Assert.assertEquals(-1, node.getPort()); + Assert.assertEquals("localhost", node.getHostAndPort()); + + node = new DruidNode(service, "2001:db8:85a3::8a2e:370:7334", -1); + Assert.assertEquals("2001:db8:85a3::8a2e:370:7334", node.getHost()); + Assert.assertEquals(-1, node.getPort()); + Assert.assertEquals("[2001:db8:85a3::8a2e:370:7334]", node.getHostAndPort()); node = new DruidNode(service, "abc:123", null); Assert.assertEquals("abc", node.getHost());