Skip to content

Commit

Permalink
[KYUUBI apache#2644] Add etcd discovery client for HA
Browse files Browse the repository at this point in the history
### _Why are the changes needed?_

Add etcd discovery client for HA

### _How was this patch tested?_
- [x] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes apache#2767 from hddong/etcd-support.

Closes apache#2644

6fa3757 [hongdongdong] Rebase and remove from rat-excludes
fc23a2b [hongdongdong] upgrade grpc-1.47.0
61c77d2 [hongdongdong] Fix tests
28abd13 [hongdongdong] fix comments
9e81a6a [hongdongdong] Rename HA_ZK_ENGINE_REF_ID to HA_ENGINE_REF_ID
aa2b426 [hongdongdong] [KYUUBI apache#2644][WIP] Add etcd discovery client for HA

Authored-by: hongdongdong <hongdongdong@cmss.chinamobile.com>
Signed-off-by: Kent Yao <yao@apache.org>
  • Loading branch information
hddong authored and yaooqinn committed Jul 12, 2022
1 parent 9060bf2 commit 32970ce
Show file tree
Hide file tree
Showing 28 changed files with 1,222 additions and 271 deletions.
3 changes: 3 additions & 0 deletions LICENSE-binary
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ io.dropwizard.metrics:metrics-jmx
io.dropwizard.metrics:metrics-json
io.dropwizard.metrics:metrics-jvm
io.fabric8:kubernetes-client
io.etcd:jetcd-core
io.grpc:grpc-core
io.grpc:grpc-protobuf
io.netty:netty-all
io.netty:netty-buffer
io.netty:netty-codec
Expand Down
32 changes: 31 additions & 1 deletion dev/dependencyList
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#

HikariCP/4.0.3//HikariCP-4.0.3.jar
animal-sniffer-annotations/1.19//animal-sniffer-annotations-1.19.jar
annotations/4.1.1.4//annotations-4.1.1.4.jar
aopalliance-repackaged/2.6.1//aopalliance-repackaged-2.6.1.jar
automaton/1.11-8//automaton-1.11-8.jar
classgraph/4.8.138//classgraph-4.8.138.jar
Expand All @@ -28,8 +30,19 @@ curator-client/2.12.0//curator-client-2.12.0.jar
curator-framework/2.12.0//curator-framework-2.12.0.jar
curator-recipes/2.12.0//curator-recipes-2.12.0.jar
derby/10.14.2.0//derby-10.14.2.0.jar
error_prone_annotations/2.10.0//error_prone_annotations-2.10.0.jar
failsafe/2.4.4//failsafe-2.4.4.jar
fliptables/1.0.2//fliptables-1.0.2.jar
generex/1.0.2//generex-1.0.2.jar
grpc-api/1.47.0//grpc-api-1.47.0.jar
grpc-context/1.47.0//grpc-context-1.47.0.jar
grpc-core/1.47.0//grpc-core-1.47.0.jar
grpc-grpclb/1.47.0//grpc-grpclb-1.47.0.jar
grpc-netty/1.47.0//grpc-netty-1.47.0.jar
grpc-protobuf-lite/1.47.0//grpc-protobuf-lite-1.47.0.jar
grpc-protobuf/1.47.0//grpc-protobuf-1.47.0.jar
grpc-stub/1.47.0//grpc-stub-1.47.0.jar
gson/2.8.9//gson-2.8.9.jar
guava/30.1-jre//guava-30.1-jre.jar
hadoop-client-api/3.3.1//hadoop-client-api-3.3.1.jar
hadoop-client-runtime/3.3.1//hadoop-client-runtime-3.3.1.jar
Expand All @@ -47,6 +60,7 @@ hk2-utils/2.6.1//hk2-utils-2.6.1.jar
htrace-core4/4.1.0-incubating//htrace-core4-4.1.0-incubating.jar
httpclient/4.5.13//httpclient-4.5.13.jar
httpcore/4.4.15//httpcore-4.4.15.jar
j2objc-annotations/1.3//j2objc-annotations-1.3.jar
jackson-annotations/2.13.3//jackson-annotations-2.13.3.jar
jackson-core/2.13.3//jackson-core-2.13.3.jar
jackson-databind/2.13.3//jackson-databind-2.13.3.jar
Expand All @@ -72,6 +86,10 @@ jersey-entity-filtering/2.36//jersey-entity-filtering-2.36.jar
jersey-hk2/2.36//jersey-hk2-2.36.jar
jersey-media-json-jackson/2.36//jersey-media-json-jackson-2.36.jar
jersey-server/2.36//jersey-server-2.36.jar
jetcd-api/0.7.1//jetcd-api-0.7.1.jar
jetcd-common/0.7.1//jetcd-common-0.7.1.jar
jetcd-core/0.7.1//jetcd-core-0.7.1.jar
jetcd-grpc/0.7.1//jetcd-grpc-0.7.1.jar
jetty-http/9.4.48.v20220622//jetty-http-9.4.48.v20220622.jar
jetty-io/9.4.48.v20220622//jetty-io-9.4.48.v20220622.jar
jetty-security/9.4.48.v20220622//jetty-security-9.4.48.v20220622.jar
Expand Down Expand Up @@ -115,9 +133,15 @@ metrics-json/4.2.8//metrics-json-4.2.8.jar
metrics-jvm/4.2.8//metrics-jvm-4.2.8.jar
netty-all/4.1.73.Final//netty-all-4.1.73.Final.jar
netty-buffer/4.1.73.Final//netty-buffer-4.1.73.Final.jar
netty-codec-dns/4.1.74.Final//netty-codec-dns-4.1.74.Final.jar
netty-codec-http/4.1.72.Final//netty-codec-http-4.1.72.Final.jar
netty-codec-http2/4.1.72.Final//netty-codec-http2-4.1.72.Final.jar
netty-codec-socks/4.1.72.Final//netty-codec-socks-4.1.72.Final.jar
netty-codec/4.1.73.Final//netty-codec-4.1.73.Final.jar
netty-common/4.1.73.Final//netty-common-4.1.73.Final.jar
netty-handler-proxy/4.1.72.Final//netty-handler-proxy-4.1.72.Final.jar
netty-handler/4.1.73.Final//netty-handler-4.1.73.Final.jar
netty-resolver-dns/4.1.74.Final//netty-resolver-dns-4.1.74.Final.jar
netty-resolver/4.1.73.Final//netty-resolver-4.1.73.Final.jar
netty-tcnative-classes/2.0.46.Final//netty-tcnative-classes-2.0.46.Final.jar
netty-transport-classes-epoll/4.1.73.Final//netty-transport-classes-epoll-4.1.73.Final.jar
Expand All @@ -126,12 +150,16 @@ netty-transport-native-epoll/4.1.73.Final/linux-aarch_64/netty-transport-native-
netty-transport-native-epoll/4.1.73.Final/linux-x86_64/netty-transport-native-epoll-4.1.73.Final-linux-x86_64.jar
netty-transport-native-kqueue/4.1.73.Final/osx-aarch_64/netty-transport-native-kqueue-4.1.73.Final-osx-aarch_64.jar
netty-transport-native-kqueue/4.1.73.Final/osx-x86_64/netty-transport-native-kqueue-4.1.73.Final-osx-x86_64.jar
netty-transport-native-unix-common/4.1.73.Final//netty-transport-native-unix-common-4.1.73.Final.jar
netty-transport-native-unix-common/4.1.72.Final//netty-transport-native-unix-common-4.1.72.Final.jar
netty-transport/4.1.73.Final//netty-transport-4.1.73.Final.jar
okhttp/3.12.12//okhttp-3.12.12.jar
okio/1.15.0//okio-1.15.0.jar
osgi-resource-locator/1.0.3//osgi-resource-locator-1.0.3.jar
paranamer/2.8//paranamer-2.8.jar
perfmark-api/0.25.0//perfmark-api-0.25.0.jar
proto-google-common-protos/2.0.1//proto-google-common-protos-2.0.1.jar
protobuf-java-util/3.19.2//protobuf-java-util-3.19.2.jar
protobuf-java/3.19.2//protobuf-java-3.19.2.jar
scala-library/2.12.15//scala-library-2.12.15.jar
scopt_2.12/4.1.0//scopt_2.12-4.1.0.jar
simpleclient/0.14.1//simpleclient-0.14.1.jar
Expand All @@ -149,5 +177,7 @@ swagger-core/2.2.1//swagger-core-2.2.1.jar
swagger-integration/2.2.1//swagger-integration-2.2.1.jar
swagger-jaxrs2/2.2.1//swagger-jaxrs2-2.2.1.jar
swagger-models/2.2.1//swagger-models-2.2.1.jar
vertx-core/4.2.7//vertx-core-4.2.7.jar
vertx-grpc/4.2.7//vertx-grpc-4.2.7.jar
zjsonpatch/0.3.0//zjsonpatch-0.3.0.jar
zookeeper/3.4.14//zookeeper-3.4.14.jar
1 change: 1 addition & 0 deletions docs/deployment/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ Key | Default | Meaning | Type | Since
--- | --- | --- | --- | ---
kyuubi.ha.addresses||The connection string for the discovery ensemble|string|1.6.0
kyuubi.ha.client.class|org.apache.kyuubi.ha.client.zookeeper.ZookeeperDiscoveryClient|Class name for service discovery client.|string|1.6.0
kyuubi.ha.etcd.lease.timeout|PT10S|Timeout for etcd keep alive lease. The kyuubi server will known unexpected loss of engine after up to this seconds.|duration|1.6.0
kyuubi.ha.namespace|kyuubi|The root directory for the service to deploy its instance uri|string|1.6.0
kyuubi.ha.zookeeper.acl.enabled|false|Set to true if the zookeeper ensemble is kerberized|boolean|1.0.0
kyuubi.ha.zookeeper.auth.digest|&lt;undefined&gt;|The digest auth string is used for zookeeper authentication, like: username:password.|string|1.3.2
Expand Down
59 changes: 59 additions & 0 deletions externals/kyuubi-spark-sql-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</dependency>

<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_${scala.binary.version}</artifactId>
Expand Down Expand Up @@ -179,6 +189,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.etcd</groupId>
<artifactId>jetcd-launcher</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -192,6 +208,14 @@
<shadedArtifactAttached>false</shadedArtifactAttached>
<artifactSet>
<includes>
<include>com.google.guava:*</include>
<include>com.google.protobuf:*</include>
<include>io.etcd:*</include>
<include>io.grpc:*</include>
<include>io.netty:*</include>
<include>io.perfmark:perfmark-api</include>
<include>io.vertx:*</include>
<include>net.jodah:failsafe</include>
<include>org.apache.kyuubi:kyuubi-common_${scala.binary.version}</include>
<include>org.apache.kyuubi:kyuubi-events_${scala.binary.version}</include>
<include>org.apache.kyuubi:kyuubi-ha_${scala.binary.version}</include>
Expand Down Expand Up @@ -249,6 +273,41 @@
<include>org.apache.thrift.**</include>
</includes>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>${kyuubi.shade.packageName}.com.google</shadedPattern>
<includes>
<include>com.google.**</include>
</includes>
</relocation>
<relocation>
<pattern>io.netty</pattern>
<shadedPattern>${kyuubi.shade.packageName}.io.netty</shadedPattern>
<includes>
<include>io.netty.**</include>
</includes>
</relocation>
<relocation>
<pattern>io.vertx</pattern>
<shadedPattern>${kyuubi.shade.packageName}.io.vertx</shadedPattern>
<includes>
<include>io.vertx.**</include>
</includes>
</relocation>
<relocation>
<pattern>net.jodah</pattern>
<shadedPattern>${kyuubi.shade.packageName}.net.jodah</shadedPattern>
<includes>
<include>net.jodah.**</include>
</includes>
</relocation>
<relocation>
<pattern>io.perfmark</pattern>
<shadedPattern>${kyuubi.shade.packageName}.io.perfmark</shadedPattern>
<includes>
<include>io.perfmark.**</include>
</includes>
</relocation>
</relocations>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# 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.
#

io.grpc.internal.PickFirstLoadBalancerProvider
io.grpc.util.SecretRoundRobinLoadBalancerProvider$Provider
io.grpc.grpclb.GrpclbLoadBalancerProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# 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.
#

io.etcd.jetcd.resolver.DnsSrvResolverProvider
io.etcd.jetcd.resolver.HttpResolverProvider
io.etcd.jetcd.resolver.HttpsResolverProvider
io.etcd.jetcd.resolver.IPResolverProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.kyuubi.engine.spark

import org.apache.kyuubi.config.KyuubiConf.ENGINE_CHECK_INTERVAL
import org.apache.kyuubi.config.KyuubiConf.ENGINE_SHARE_LEVEL
import org.apache.kyuubi.config.KyuubiConf.ENGINE_SPARK_MAX_LIFETIME
import org.apache.kyuubi.engine.ShareLevel
import org.apache.kyuubi.engine.ShareLevel.ShareLevel

trait EtcdShareLevelSparkEngineSuite
extends ShareLevelSparkEngineTests with WithEtcdCluster {
override def withKyuubiConf: Map[String, String] = {
super.withKyuubiConf ++
etcdConf ++ Map(
ENGINE_SHARE_LEVEL.key -> shareLevel.toString,
ENGINE_SPARK_MAX_LIFETIME.key -> "PT20s",
ENGINE_CHECK_INTERVAL.key -> "PT5s")
}
}

class EtcdConnectionLevelSparkEngineSuite extends EtcdShareLevelSparkEngineSuite {
override def shareLevel: ShareLevel = ShareLevel.CONNECTION
}

class EtcdUserLevelSparkEngineSuite extends EtcdShareLevelSparkEngineSuite {
override def shareLevel: ShareLevel = ShareLevel.USER
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import java.util.UUID
import org.scalatest.concurrent.PatienceConfiguration.Timeout
import org.scalatest.time.SpanSugar.convertIntToGrainOfTime

import org.apache.kyuubi.config.KyuubiConf.ENGINE_CHECK_INTERVAL
import org.apache.kyuubi.config.KyuubiConf.ENGINE_SHARE_LEVEL
import org.apache.kyuubi.config.KyuubiConf.ENGINE_SPARK_MAX_LIFETIME
import org.apache.kyuubi.engine.ShareLevel
import org.apache.kyuubi.engine.ShareLevel.ShareLevel
import org.apache.kyuubi.operation.HiveJDBCTestHelper
Expand All @@ -34,15 +31,10 @@ import org.apache.kyuubi.service.ServiceState
* This suite is to test some behavior with spark engine in different share level.
* e.g. cleanup discovery service before stop.
*/
abstract class ShareLevelSparkEngineSuite
trait ShareLevelSparkEngineTests
extends WithDiscoverySparkSQLEngine with HiveJDBCTestHelper {
def shareLevel: ShareLevel
override def withKyuubiConf: Map[String, String] = {
super.withKyuubiConf ++ Map(
ENGINE_SHARE_LEVEL.key -> shareLevel.toString,
ENGINE_SPARK_MAX_LIFETIME.key -> "PT20s",
ENGINE_CHECK_INTERVAL.key -> "PT5s")
}

override protected def jdbcUrl: String = getJdbcUrl
override val namespace: String = {
// for test, we always use uuid as namespace
Expand Down Expand Up @@ -85,11 +77,3 @@ abstract class ShareLevelSparkEngineSuite
}
}
}

class ConnectionLevelSparkEngineSuite extends ShareLevelSparkEngineSuite {
override def shareLevel: ShareLevel = ShareLevel.CONNECTION
}

class UserLevelSparkEngineSuite extends ShareLevelSparkEngineSuite {
override def shareLevel: ShareLevel = ShareLevel.USER
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,16 @@

package org.apache.kyuubi.engine.spark

import org.apache.kyuubi.Utils
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.ha.HighAvailabilityConf.{HA_ADDRESSES, HA_NAMESPACE, HA_ZK_AUTH_TYPE}
import org.apache.kyuubi.ha.client.AuthTypes
import org.apache.kyuubi.ha.HighAvailabilityConf.HA_NAMESPACE
import org.apache.kyuubi.ha.client.DiscoveryClient
import org.apache.kyuubi.ha.client.DiscoveryClientProvider
import org.apache.kyuubi.zookeeper.{EmbeddedZookeeper, ZookeeperConf}

trait WithDiscoverySparkSQLEngine extends WithSparkSQLEngine {
private var zkServer: EmbeddedZookeeper = _
def namespace: String
override def withKyuubiConf: Map[String, String] = {
assert(zkServer != null)
Map(
HA_ADDRESSES.key -> zkServer.getConnectString,
HA_ZK_AUTH_TYPE.key -> AuthTypes.NONE.toString,
HA_NAMESPACE.key -> namespace)
}

override def beforeAll(): Unit = {
zkServer = new EmbeddedZookeeper()
val zkData = Utils.createTempDir()
val tmpConf = KyuubiConf()
tmpConf.set(ZookeeperConf.ZK_CLIENT_PORT, 0)
tmpConf.set(ZookeeperConf.ZK_DATA_DIR, zkData.toString)
zkServer.initialize(tmpConf)
zkServer.start()
}
def namespace: String

override def afterAll(): Unit = {
if (zkServer != null) {
zkServer.stop()
}
override def withKyuubiConf: Map[String, String] = {
Map(HA_NAMESPACE.key -> namespace)
}

override protected def beforeEach(): Unit = {
Expand All @@ -65,12 +42,4 @@ trait WithDiscoverySparkSQLEngine extends WithSparkSQLEngine {
def withDiscoveryClient(f: DiscoveryClient => Unit): Unit = {
DiscoveryClientProvider.withDiscoveryClient(kyuubiConf)(f)
}

protected def getDiscoveryConnectionString: String = {
if (zkServer == null) {
""
} else {
zkServer.getConnectString
}
}
}
Loading

0 comments on commit 32970ce

Please sign in to comment.