mirror of https://github.com/apache/druid.git
fix port not set in DruidNode
This commit is contained in:
parent
8b3652a67a
commit
59542c41f8
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,8 +131,12 @@ public class DruidNode
|
|||
* Returns host and port together as something that can be used as part of a URI.
|
||||
*/
|
||||
public String getHostAndPort() {
|
||||
if(port < 0) {
|
||||
return HostAndPort.fromString(host).toString();
|
||||
} else {
|
||||
return HostAndPort.fromParts(host, port).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue