[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319872213 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: We already have one in ZooKeeperManager LivyDiscovery is a hight level of abstraction which is used for better understanding, single responsibility and API simplification 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319872213 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: We already have one in ZooKeeperManager LivyDiscovery is a hight layer of abstraction which is used for better understanding, single responsibility and API simplification 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319879135 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: Also, I have tried to make all configurations more generic and configurable on the top level to use it everywhere. As far as I see, for now, we have a couple of PRs with different ZK logic which can't be reused a lot and I see too specific confs like `livy.server.thrift.zookeeper.quorum` instead of simple common `livy.zookeeper.url` which can be reused. In this PR I want to not only add LivyServer discovery but also create init structure for subsequent work with ZooKeeper. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319879135 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: Also, I have tried to make all configurations more generic and configurable on the top level to use it everywhere. As far as I see, for now, we have a couple of PRs with different ZK logic which can't be reused a lot and I see too specific confs like "livy.server.thrift.zookeeper.quorum" instead of simple common "livy.zookeeper.url" which can be reused. In this PR I want to not only add LivyServer discovery but also create init structure for subsequent work with ZooKeeper. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319879135 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: Also, all configuration I have tried to make more generic and configurable on the top level to use it everywhere. As far as I see, for now, we have a couple of PRs with different ZK logic which can't be reused a lot and I see too specific confs like "livy.server.thrift.zookeeper.quorum". In this PR I want to not only add LivyServer discovery but also create init structure for subsequent work with ZooKeeper. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319877176 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: ZooKeeperManager should be used every time by design when we need to store something to ZK. I think we need to have one logic for ZK interaction for LivyServer discovery, ZK state store, Livy HA, Livy Thrift Server HA. That's why I moved this functionality to the separated trait, to make it reuseable for someone else. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319875674 ## 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: PR was updated 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319872213 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: We have one in ZooKeeperManager LivyDiscovery is a hight layer of abstraction which is used for better understanding, single responsibility and API simplification 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319872213 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: We have one in ZooKeeperManager LivyDiscovery is a hight layer of abstraction which is used for better understanding, single responcibility and API simplification 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319873921 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: I just refactored StateStore to move functionality for communication with ZK from ZooKeeperStateStore.scala to separated trait ZooKeeperManager.scala. In ZooKeeperStateStore we will use ZooKeeperManager to store data in ZK. ZooKeeperManager code was not changed except couple small improvements for configurations to make it more flexible. We can use this trait everywhere when we need to store something to ZooKeeper since it's generic: ``` def setData(key: String, value: Object): Unit = { val prefixedKey = prefixKey(key) val data = serializeToBytes(value) if (exist(prefixedKey)) { curatorClient.setData().forPath(prefixedKey, data) } else { curatorClient.create().creatingParentsIfNeeded().forPath(prefixedKey, data) } } def getData[T: ClassTag](key: String): Option[T] = { val prefixedKey = prefixKey(key) if (exist(prefixedKey)) { Option(deserialize[T](curatorClient.getData().forPath(prefixedKey))) } else { None } } ``` 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319873921 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: I just refactored StateStore to move functionality for communication with ZK from ZooKeeperStateStore.scala to separated trait ZooKeeperManager.scala. In ZooKeeperStateStore we will use ZooKeeperManager to store data in ZK. ZooKeeperManager code was not changed except couple small improvements for configurations to make it more flexible. We can use this trait everywhere when we need to store something to ZooKeeper since it generic: ``` def setData(key: String, value: Object): Unit = { val prefixedKey = prefixKey(key) val data = serializeToBytes(value) if (exist(prefixedKey)) { curatorClient.setData().forPath(prefixedKey, data) } else { curatorClient.create().creatingParentsIfNeeded().forPath(prefixedKey, data) } } def getData[T: ClassTag](key: String): Option[T] = { val prefixedKey = prefixKey(key) if (exist(prefixedKey)) { Option(deserialize[T](curatorClient.getData().forPath(prefixedKey))) } else { None } } ``` 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319873921 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: I just refactored StateStore to move functionality for communication with ZK from ZooKeeperStateStore.scala to separated trait ZooKeeperManager.scala. In ZooKeeperStateStore we will useZooKeeperManager to store data in ZK. ZooKeeperManager code was not changed except couple small improvements for configurations to make it more flexible. We can use this trait everywhere when we need to store something to ZooKeeper since in generic, e.g: ``` def setData(key: String, value: Object): Unit = { val prefixedKey = prefixKey(key) val data = serializeToBytes(value) if (exist(prefixedKey)) { curatorClient.setData().forPath(prefixedKey, data) } else { curatorClient.create().creatingParentsIfNeeded().forPath(prefixedKey, data) } } def getData[T: ClassTag](key: String): Option[T] = { val prefixedKey = prefixKey(key) if (exist(prefixedKey)) { Option(deserialize[T](curatorClient.getData().forPath(prefixedKey))) } else { None } } ``` 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319872213 ## File path: server/src/main/scala/org/apache/livy/server/discovery/LivyDiscoveryManager.scala ## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.livy.server.discovery + +import java.net.URI + +import org.apache.curator.framework.CuratorFramework + +import org.apache.livy.LivyConf + +/** + * Livy Server Discovery manager. + * Stores information about Livy Server location in ZooKeeper. + * The address will be stored in + * "/{@code LIVY_ZOOKEEPER_NAMESPACE}/{@code LIVY_SERVER_ZOOKEEPER_NAMESPACE}" znode + * By default, the full path to znode is /livy/server.uri. + * Need to set {@code livy.zookeeper.url} to be able to get information from ZooKeeper. + * + * @param livyConf - Livy configurations + * @param mockCuratorClient - used for testing + */ +class LivyDiscoveryManager(val livyConf: LivyConf, Review comment: We have one in ZooKeeperManager LivyDiscovery just uses it to simplify API 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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_r319867875 ## 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: oh, I see it's my mistake. good catch! `livyConf.get(LivyConf.SERVER_HOST.dflt.toString)` not make a sense in this case, looks like it's typical copy problem 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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 to store. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery
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 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 to store. 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: us...@infra.apache.org With regards, Apache Git Services