From reviews-return-1783-archive-asf-public=cust-asf.ponee.io@livy.incubator.apache.org Mon Sep 2 09:18:09 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 07007180658 for ; Mon, 2 Sep 2019 11:18:08 +0200 (CEST) Received: (qmail 71678 invoked by uid 500); 2 Sep 2019 09:48:27 -0000 Mailing-List: contact reviews-help@livy.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: reviews@livy.incubator.apache.org Delivered-To: mailing list reviews@livy.incubator.apache.org Received: (qmail 71667 invoked by uid 99); 2 Sep 2019 09:48:27 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Sep 2019 09:48:27 +0000 From: GitBox To: reviews@livy.apache.org Subject: [GitHub] [incubator-livy] o-shevchenko commented on a change in pull request #189: [LIVY-616] Livy Server discovery Message-ID: <156741588834.32021.8961431839116177597.gitbox@gitbox.apache.org> Date: Mon, 02 Sep 2019 09:18:08 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 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: users@infra.apache.org With regards, Apache Git Services