o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
URL: https://github.com/apache/incubator-livy/pull/189#discussion_r319862520
##########
File path: server/src/main/scala/org/apache/livy/server/LivyServer.scala
##########
@@ -385,6 +389,25 @@ class LivyServer extends Logging {
}
}
+ private[livy] def setServerUri(livyConf: LivyConf,
+ mockCuratorClient: Option[CuratorFramework] = None): Unit
= {
+ if (Option(livyConf.get(LIVY_ZOOKEEPER_URL)).isDefined) {
+ val discoveryManager = LivyDiscoveryManager(livyConf, mockCuratorClient)
+ val host = resolvedSeverHost(livyConf)
+ val uri = new URI(s"http://$host:${livyConf.getInt(LivyConf.SERVER_PORT)}")
+ discoveryManager.setServerUri(uri)
+ }
+ }
+
+ private def resolvedSeverHost(livyConf: LivyConf) = {
+ val host = livyConf.get(LivyConf.SERVER_HOST)
+ if (host.equals(livyConf.get(LivyConf.SERVER_HOST.dflt.toString))) {
+ InetAddress.getLocalHost.getHostName
Review comment:
You can find more detailed info in the specification which attached to the Jira ticket
```
To enable Livy Server discovery we need to set livy.zookeeper.url. During start Livy
Server we save URI to ZooKeeper. If we specify host by livy.server.host then we will
use this value. if we use the default value “0.0.0.0” the local host name will be stored(InetAddress.getLocalHost.getHostName)
to be able to communicate from other nodes. We will store address as java.net.URI (in format
schema://host:port, e.g.http://livyhostname:8998)
```
So, basically it's needed to resolve Livy Server address by replacing `0.0.0.0` default
value with the correct IP address if user didn't specify any Livy Server address in the conf
file. In this case, we can use `InetAddress.getLocalHost.getHostName` to get the address from
the node where LivyServer was started.
See your point, `InetAddress.getLocalHost.getHostAddress` might be the better choice here.
Thanks!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
|