Skip to content

Commit bd3d4d7

Browse files
yanghuaulysses-you
authored andcommitted
[KYUUBI #1503] Introduce FlinkThriftBinaryFrontendService to do the further initialization
… <!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html 2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'. 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'. --> ### _Why are the changes needed?_ <!-- Please clarify why the changes are needed. For instance, 1. If you add a feature, you can talk about the use case of it. 2. If you fix a bug, you can clarify why it is a bug. --> ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1512 from yanghua/KYUUBI-1503. Closes #1503 b41fa73 [yanghua] [KYUUBI #1503] Introduce FlinkThriftBinaryFrontendService to do the further initialization Authored-by: yanghua <yanghua1127@gmail.com> Signed-off-by: ulysses-you <ulyssesyou@apache.org>
1 parent 940c6c1 commit bd3d4d7

File tree

3 files changed

+56
-42
lines changed

3 files changed

+56
-42
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.kyuubi.engine.flink
19+
20+
import org.apache.kyuubi.ha.client.{EngineServiceDiscovery, ServiceDiscovery}
21+
import org.apache.kyuubi.service.{Serverable, Service, ThriftBinaryFrontendService}
22+
23+
class FlinkThriftBinaryFrontendService(
24+
override val serverable: Serverable)
25+
extends ThriftBinaryFrontendService("FlinkThriftBinaryFrontendService") {
26+
27+
override lazy val discoveryService: Option[Service] = {
28+
if (ServiceDiscovery.supportServiceDiscovery(conf)) {
29+
Some(new EngineServiceDiscovery(this))
30+
} else {
31+
None
32+
}
33+
}
34+
35+
}

externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/kyuubi/engine/spark/SparkThriftBinaryFrontendServiceSuite.scala

Lines changed: 0 additions & 42 deletions
This file was deleted.

kyuubi-common/src/test/scala/org/apache/kyuubi/service/ThriftFrontendServiceSuite.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import org.apache.thrift.transport.TSocket
2727

2828
import org.apache.kyuubi.{KyuubiFunSuite, KyuubiSQLException, Utils}
2929
import org.apache.kyuubi.config.KyuubiConf
30+
import org.apache.kyuubi.config.KyuubiConf.{FRONTEND_THRIFT_BINARY_BIND_HOST, FRONTEND_THRIFT_BINARY_BIND_PORT}
3031
import org.apache.kyuubi.operation.{OperationHandle, OperationType}
3132
import org.apache.kyuubi.service.ThriftBinaryFrontendService.{FeServiceServerContext, SERVER_VERSION}
3233
import org.apache.kyuubi.service.authentication.PlainSASLHelper
@@ -117,6 +118,26 @@ class ThriftFrontendServiceSuite extends KyuubiFunSuite {
117118
assert(errResp.getStatus.getStatusCode === TStatusCode.ERROR_STATUS)
118119
}
119120

121+
test("engine connect url use hostname") {
122+
val conf = new KyuubiConf()
123+
.set(FRONTEND_THRIFT_BINARY_BIND_HOST.key, "localhost")
124+
.set(FRONTEND_THRIFT_BINARY_BIND_PORT, 0)
125+
val service = new ThriftBinaryFrontendService("DummyThriftBinaryFrontendService") {
126+
override val serverable: Serverable = new NoopThriftBinaryFrontendServer
127+
override val discoveryService: Option[Service] = None
128+
}
129+
intercept[IllegalStateException](service.connectionUrl)
130+
131+
conf.set(KyuubiConf.ENGINE_CONNECTION_URL_USE_HOSTNAME, true)
132+
service.initialize(conf)
133+
// default use hostname
134+
assert(service.connectionUrl.startsWith("localhost"))
135+
136+
// use ip address
137+
conf.set(KyuubiConf.ENGINE_CONNECTION_URL_USE_HOSTNAME, false)
138+
assert(service.connectionUrl.startsWith("127.0.0.1"))
139+
}
140+
120141
test("open session") {
121142
withThriftClient { client =>
122143
val req = new TOpenSessionReq()

0 commit comments

Comments
 (0)