Skip to content

Commit c656af7

Browse files
committed
conf to set
1 parent f42a7d6 commit c656af7

File tree

30 files changed

+125
-108
lines changed

30 files changed

+125
-108
lines changed

docs/configuration/settings.md

Lines changed: 16 additions & 16 deletions
Large diffs are not rendered by default.

externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/PlanOnlyStatement.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class PlanOnlyStatement(
4141
extends SparkOperation(session) {
4242

4343
private val operationLog: OperationLog = OperationLog.createOperationLog(session, getHandle)
44-
private val planExcludes: Seq[String] = {
45-
spark.conf.getOption(OPERATION_PLAN_ONLY_EXCLUDES.key).map(_.split(",").map(_.trim).toSeq)
44+
private val planExcludes: Set[String] = {
45+
spark.conf.getOption(OPERATION_PLAN_ONLY_EXCLUDES.key).map(_.split(",").map(_.trim).toSet)
4646
.getOrElse(session.sessionManager.getConf.get(OPERATION_PLAN_ONLY_EXCLUDES))
4747
}
4848

externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/kyuubi/SparkSQLEngineListener.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ import org.apache.kyuubi.service.{Serverable, ServiceState}
4040
class SparkSQLEngineListener(server: Serverable) extends SparkListener with Logging {
4141

4242
// the conf of server is null before initialized, use lazy val here
43-
private lazy val deregisterExceptions: Seq[String] =
43+
private lazy val deregisterExceptions: Set[String] =
4444
server.getConf.get(ENGINE_DEREGISTER_EXCEPTION_CLASSES)
45-
private lazy val deregisterMessages: Seq[String] =
45+
private lazy val deregisterMessages: Set[String] =
4646
server.getConf.get(ENGINE_DEREGISTER_EXCEPTION_MESSAGES)
4747
private lazy val deregisterExceptionTTL: Long =
4848
server.getConf.get(ENGINE_DEREGISTER_EXCEPTION_TTL)
@@ -74,7 +74,7 @@ class SparkSQLEngineListener(server: Serverable) extends SparkListener with Logg
7474
case JobFailed(e) if e != null =>
7575
val cause = findCause(e)
7676
var deregisterInfo: Option[String] = None
77-
if (deregisterExceptions.exists(_.equals(cause.getClass.getCanonicalName))) {
77+
if (deregisterExceptions.contains(cause.getClass.getCanonicalName)) {
7878
deregisterInfo = Some("Job failed exception class is in the set of " +
7979
s"${ENGINE_DEREGISTER_EXCEPTION_CLASSES.key}, deregistering the engine.")
8080
} else if (deregisterMessages.exists(stringifyException(cause).contains)) {

kyuubi-common/src/main/scala/org/apache/kyuubi/config/ConfigBuilder.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,12 @@ private[kyuubi] case class TypedConfigBuilder[T](
206206
/** Turns the config entry into a sequence of values of the underlying type. */
207207
def toSequence(sp: String = ","): TypedConfigBuilder[Seq[T]] = {
208208
parent._type = "seq"
209-
TypedConfigBuilder(parent, strToSeq(_, fromStr, sp), seqToStr(_, toStr))
209+
TypedConfigBuilder(parent, strToSeq(_, fromStr, sp), iterableToStr(_, toStr))
210+
}
211+
212+
def toSet(sp: String = ",", skipBlank: Boolean = true): TypedConfigBuilder[Set[T]] = {
213+
parent._type = "set"
214+
TypedConfigBuilder(parent, strToSet(_, fromStr, sp, skipBlank), iterableToStr(_, toStr))
210215
}
211216

212217
def createOptional: OptionalConfigEntry[T] = {

kyuubi-common/src/main/scala/org/apache/kyuubi/config/ConfigHelpers.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.kyuubi.config
1919

20+
import org.apache.commons.lang3.StringUtils
21+
2022
import org.apache.kyuubi.Utils
2123

2224
object ConfigHelpers {
@@ -25,7 +27,11 @@ object ConfigHelpers {
2527
Utils.strToSeq(str, sp).map(converter)
2628
}
2729

28-
def seqToStr[T](v: Seq[T], stringConverter: T => String): String = {
29-
v.map(stringConverter).mkString(",")
30+
def strToSet[T](str: String, converter: String => T, sp: String, skipBlank: Boolean): Set[T] = {
31+
Utils.strToSeq(str, sp).filter(!skipBlank || StringUtils.isNotBlank(_)).map(converter).toSet
32+
}
33+
34+
def iterableToStr[T](v: Iterable[T], stringConverter: T => String, sp: String = ","): String = {
35+
v.map(stringConverter).mkString(sp)
3036
}
3137
}

kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,13 @@ object KyuubiConf {
483483
.stringConf
484484
.createOptional
485485

486-
val FRONTEND_THRIFT_BINARY_SSL_DISALLOWED_PROTOCOLS: ConfigEntry[Seq[String]] =
486+
val FRONTEND_THRIFT_BINARY_SSL_DISALLOWED_PROTOCOLS: ConfigEntry[Set[String]] =
487487
buildConf("kyuubi.frontend.thrift.binary.ssl.disallowed.protocols")
488488
.doc("SSL versions to disallow for Kyuubi thrift binary frontend.")
489489
.version("1.7.0")
490490
.stringConf
491-
.toSequence()
492-
.createWithDefault(Seq("SSLv2", "SSLv3"))
491+
.toSet()
492+
.createWithDefault(Set("SSLv2", "SSLv3"))
493493

494494
val FRONTEND_THRIFT_BINARY_SSL_INCLUDE_CIPHER_SUITES: ConfigEntry[Seq[String]] =
495495
buildConf("kyuubi.frontend.thrift.binary.ssl.include.ciphersuites")
@@ -765,7 +765,7 @@ object KyuubiConf {
765765
.stringConf
766766
.createWithDefault("X-Real-IP")
767767

768-
val AUTHENTICATION_METHOD: ConfigEntry[Seq[String]] = buildConf("kyuubi.authentication")
768+
val AUTHENTICATION_METHOD: ConfigEntry[Set[String]] = buildConf("kyuubi.authentication")
769769
.doc("A comma-separated list of client authentication types." +
770770
"<ul>" +
771771
" <li>NOSASL: raw transport.</li>" +
@@ -801,11 +801,11 @@ object KyuubiConf {
801801
.serverOnly
802802
.stringConf
803803
.transformToUpperCase
804-
.toSequence()
804+
.toSet()
805805
.checkValue(
806806
_.forall(AuthTypes.values.map(_.toString).contains),
807807
s"the authentication type should be one or more of ${AuthTypes.values.mkString(",")}")
808-
.createWithDefault(Seq(AuthTypes.NONE.toString))
808+
.createWithDefault(Set(AuthTypes.NONE.toString))
809809

810810
val AUTHENTICATION_CUSTOM_CLASS: OptionalConfigEntry[String] =
811811
buildConf("kyuubi.authentication.custom.class")
@@ -861,25 +861,25 @@ object KyuubiConf {
861861
.stringConf
862862
.createOptional
863863

864-
val AUTHENTICATION_LDAP_GROUP_FILTER: ConfigEntry[Seq[String]] =
864+
val AUTHENTICATION_LDAP_GROUP_FILTER: ConfigEntry[Set[String]] =
865865
buildConf("kyuubi.authentication.ldap.groupFilter")
866866
.doc("COMMA-separated list of LDAP Group names (short name not full DNs). " +
867867
"For example: HiveAdmins,HadoopAdmins,Administrators")
868868
.version("1.7.0")
869869
.serverOnly
870870
.stringConf
871-
.toSequence()
872-
.createWithDefault(Nil)
871+
.toSet()
872+
.createWithDefault(Set.empty)
873873

874-
val AUTHENTICATION_LDAP_USER_FILTER: ConfigEntry[Seq[String]] =
874+
val AUTHENTICATION_LDAP_USER_FILTER: ConfigEntry[Set[String]] =
875875
buildConf("kyuubi.authentication.ldap.userFilter")
876876
.doc("COMMA-separated list of LDAP usernames (just short names, not full DNs). " +
877877
"For example: hiveuser,impalauser,hiveadmin,hadoopadmin")
878878
.version("1.7.0")
879879
.serverOnly
880880
.stringConf
881-
.toSequence()
882-
.createWithDefault(Nil)
881+
.toSet()
882+
.createWithDefault(Set.empty)
883883

884884
val AUTHENTICATION_LDAP_GUID_KEY: ConfigEntry[String] =
885885
buildConf("kyuubi.authentication.ldap.guidKey")
@@ -1142,14 +1142,14 @@ object KyuubiConf {
11421142
.stringConf
11431143
.createOptional
11441144

1145-
val KUBERNETES_CONTEXT_ALLOW_LIST: ConfigEntry[Seq[String]] =
1145+
val KUBERNETES_CONTEXT_ALLOW_LIST: ConfigEntry[Set[String]] =
11461146
buildConf("kyuubi.kubernetes.context.allow.list")
11471147
.doc("The allowed kubernetes context list, if it is empty," +
11481148
" there is no kubernetes context limitation.")
11491149
.version("1.8.0")
11501150
.stringConf
1151-
.toSequence()
1152-
.createWithDefault(Nil)
1151+
.toSet()
1152+
.createWithDefault(Set.empty)
11531153

11541154
val KUBERNETES_NAMESPACE: ConfigEntry[String] =
11551155
buildConf("kyuubi.kubernetes.namespace")
@@ -1158,14 +1158,14 @@ object KyuubiConf {
11581158
.stringConf
11591159
.createWithDefault("default")
11601160

1161-
val KUBERNETES_NAMESPACE_ALLOW_LIST: ConfigEntry[Seq[String]] =
1161+
val KUBERNETES_NAMESPACE_ALLOW_LIST: ConfigEntry[Set[String]] =
11621162
buildConf("kyuubi.kubernetes.namespace.allow.list")
11631163
.doc("The allowed kubernetes namespace list, if it is empty," +
11641164
" there is no kubernetes namespace limitation.")
11651165
.version("1.8.0")
11661166
.stringConf
1167-
.toSequence()
1168-
.createWithDefault(Nil)
1167+
.toSet()
1168+
.createWithDefault(Set.empty)
11691169

11701170
val KUBERNETES_MASTER: OptionalConfigEntry[String] =
11711171
buildConf("kyuubi.kubernetes.master.address")
@@ -1517,7 +1517,7 @@ object KyuubiConf {
15171517
.timeConf
15181518
.createWithDefault(Duration.ofMinutes(30L).toMillis)
15191519

1520-
val SESSION_CONF_IGNORE_LIST: ConfigEntry[Seq[String]] =
1520+
val SESSION_CONF_IGNORE_LIST: ConfigEntry[Set[String]] =
15211521
buildConf("kyuubi.session.conf.ignore.list")
15221522
.doc("A comma-separated list of ignored keys. If the client connection contains any of" +
15231523
" them, the key and the corresponding value will be removed silently during engine" +
@@ -1527,10 +1527,10 @@ object KyuubiConf {
15271527
" configurations via SET syntax.")
15281528
.version("1.2.0")
15291529
.stringConf
1530-
.toSequence()
1531-
.createWithDefault(Nil)
1530+
.toSet()
1531+
.createWithDefault(Set.empty)
15321532

1533-
val SESSION_CONF_RESTRICT_LIST: ConfigEntry[Seq[String]] =
1533+
val SESSION_CONF_RESTRICT_LIST: ConfigEntry[Set[String]] =
15341534
buildConf("kyuubi.session.conf.restrict.list")
15351535
.doc("A comma-separated list of restricted keys. If the client connection contains any of" +
15361536
" them, the connection will be rejected explicitly during engine bootstrap and connection" +
@@ -1540,8 +1540,8 @@ object KyuubiConf {
15401540
" configurations via SET syntax.")
15411541
.version("1.2.0")
15421542
.stringConf
1543-
.toSequence()
1544-
.createWithDefault(Nil)
1543+
.toSet()
1544+
.createWithDefault(Set.empty)
15451545

15461546
val SESSION_USER_SIGN_ENABLED: ConfigEntry[Boolean] =
15471547
buildConf("kyuubi.session.user.sign.enabled")
@@ -1589,7 +1589,7 @@ object KyuubiConf {
15891589
.booleanConf
15901590
.createWithDefault(true)
15911591

1592-
val SESSION_LOCAL_DIR_ALLOW_LIST: ConfigEntry[Seq[String]] =
1592+
val SESSION_LOCAL_DIR_ALLOW_LIST: ConfigEntry[Set[String]] =
15931593
buildConf("kyuubi.session.local.dir.allow.list")
15941594
.doc("The local dir list that are allowed to access by the kyuubi session application. " +
15951595
" End-users might set some parameters such as `spark.files` and it will " +
@@ -1602,8 +1602,8 @@ object KyuubiConf {
16021602
.stringConf
16031603
.checkValue(dir => dir.startsWith(File.separator), "the dir should be absolute path")
16041604
.transform(dir => dir.stripSuffix(File.separator) + File.separator)
1605-
.toSequence()
1606-
.createWithDefault(Nil)
1605+
.toSet()
1606+
.createWithDefault(Set.empty)
16071607

16081608
val BATCH_APPLICATION_CHECK_INTERVAL: ConfigEntry[Long] =
16091609
buildConf("kyuubi.batch.application.check.interval")
@@ -1619,7 +1619,7 @@ object KyuubiConf {
16191619
.timeConf
16201620
.createWithDefault(Duration.ofMinutes(3).toMillis)
16211621

1622-
val BATCH_CONF_IGNORE_LIST: ConfigEntry[Seq[String]] =
1622+
val BATCH_CONF_IGNORE_LIST: ConfigEntry[Set[String]] =
16231623
buildConf("kyuubi.batch.conf.ignore.list")
16241624
.doc("A comma-separated list of ignored keys for batch conf. If the batch conf contains" +
16251625
" any of them, the key and the corresponding value will be removed silently during batch" +
@@ -1631,8 +1631,8 @@ object KyuubiConf {
16311631
" for the Spark batch job with key `kyuubi.batchConf.spark.spark.master`.")
16321632
.version("1.6.0")
16331633
.stringConf
1634-
.toSequence()
1635-
.createWithDefault(Nil)
1634+
.toSet()
1635+
.createWithDefault(Set.empty)
16361636

16371637
val BATCH_INTERNAL_REST_CLIENT_SOCKET_TIMEOUT: ConfigEntry[Long] =
16381638
buildConf("kyuubi.batch.internal.rest.client.socket.timeout")
@@ -2076,24 +2076,24 @@ object KyuubiConf {
20762076
.toSequence(";")
20772077
.createWithDefault(Nil)
20782078

2079-
val ENGINE_DEREGISTER_EXCEPTION_CLASSES: ConfigEntry[Seq[String]] =
2079+
val ENGINE_DEREGISTER_EXCEPTION_CLASSES: ConfigEntry[Set[String]] =
20802080
buildConf("kyuubi.engine.deregister.exception.classes")
20812081
.doc("A comma-separated list of exception classes. If there is any exception thrown," +
20822082
" whose class matches the specified classes, the engine would deregister itself.")
20832083
.version("1.2.0")
20842084
.stringConf
2085-
.toSequence()
2086-
.createWithDefault(Nil)
2085+
.toSet()
2086+
.createWithDefault(Set.empty)
20872087

2088-
val ENGINE_DEREGISTER_EXCEPTION_MESSAGES: ConfigEntry[Seq[String]] =
2088+
val ENGINE_DEREGISTER_EXCEPTION_MESSAGES: ConfigEntry[Set[String]] =
20892089
buildConf("kyuubi.engine.deregister.exception.messages")
20902090
.doc("A comma-separated list of exception messages. If there is any exception thrown," +
20912091
" whose message or stacktrace matches the specified message list, the engine would" +
20922092
" deregister itself.")
20932093
.version("1.2.0")
20942094
.stringConf
2095-
.toSequence()
2096-
.createWithDefault(Nil)
2095+
.toSet()
2096+
.createWithDefault(Set.empty)
20972097

20982098
val ENGINE_DEREGISTER_JOB_MAX_FAILURES: ConfigEntry[Int] =
20992099
buildConf("kyuubi.engine.deregister.job.max.failures")
@@ -2400,7 +2400,7 @@ object KyuubiConf {
24002400
"'plain', 'json'.")
24012401
.createWithDefault(PlainStyle.name)
24022402

2403-
val OPERATION_PLAN_ONLY_EXCLUDES: ConfigEntry[Seq[String]] =
2403+
val OPERATION_PLAN_ONLY_EXCLUDES: ConfigEntry[Set[String]] =
24042404
buildConf("kyuubi.operation.plan.only.excludes")
24052405
.doc("Comma-separated list of query plan names, in the form of simple class names, i.e, " +
24062406
"for `SET abc=xyz`, the value will be `SetCommand`. For those auxiliary plans, such as " +
@@ -2410,8 +2410,8 @@ object KyuubiConf {
24102410
s"See also ${OPERATION_PLAN_ONLY_MODE.key}.")
24112411
.version("1.5.0")
24122412
.stringConf
2413-
.toSequence()
2414-
.createWithDefault(Seq(
2413+
.toSet()
2414+
.createWithDefault(Set(
24152415
"ResetCommand",
24162416
"SetCommand",
24172417
"SetNamespaceCommand",
@@ -2614,14 +2614,14 @@ object KyuubiConf {
26142614
.intConf
26152615
.createOptional
26162616

2617-
val SERVER_LIMIT_CONNECTIONS_USER_UNLIMITED_LIST: ConfigEntry[Seq[String]] =
2617+
val SERVER_LIMIT_CONNECTIONS_USER_UNLIMITED_LIST: ConfigEntry[Set[String]] =
26182618
buildConf("kyuubi.server.limit.connections.user.unlimited.list")
26192619
.doc("The maximum connections of the user in the white list will not be limited.")
26202620
.version("1.7.0")
26212621
.serverOnly
26222622
.stringConf
2623-
.toSequence()
2624-
.createWithDefault(Nil)
2623+
.toSet()
2624+
.createWithDefault(Set.empty)
26252625

26262626
val SERVER_LIMIT_BATCH_CONNECTIONS_PER_USER: OptionalConfigEntry[Int] =
26272627
buildConf("kyuubi.server.limit.batch.connections.per.user")
@@ -2683,15 +2683,15 @@ object KyuubiConf {
26832683
.timeConf
26842684
.createWithDefaultString("PT30M")
26852685

2686-
val SERVER_ADMINISTRATORS: ConfigEntry[Seq[String]] =
2686+
val SERVER_ADMINISTRATORS: ConfigEntry[Set[String]] =
26872687
buildConf("kyuubi.server.administrators")
26882688
.doc("Comma-separated list of Kyuubi service administrators. " +
26892689
"We use this config to grant admin permission to any service accounts.")
26902690
.version("1.8.0")
26912691
.serverOnly
26922692
.stringConf
2693-
.toSequence()
2694-
.createWithDefault(Nil)
2693+
.toSet()
2694+
.createWithDefault(Set.empty)
26952695

26962696
val OPERATION_SPARK_LISTENER_ENABLED: ConfigEntry[Boolean] =
26972697
buildConf("kyuubi.operation.spark.listener.enabled")

kyuubi-common/src/main/scala/org/apache/kyuubi/service/TBinaryFrontendService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ abstract class TBinaryFrontendService(name: String)
134134
keyStorePassword: String,
135135
keyStoreType: Option[String],
136136
keyStoreAlgorithm: Option[String],
137-
disallowedSslProtocols: Seq[String],
137+
disallowedSslProtocols: Set[String],
138138
includeCipherSuites: Seq[String]): TServerSocket = {
139139
val params =
140140
if (includeCipherSuites.nonEmpty) {

kyuubi-common/src/main/scala/org/apache/kyuubi/service/authentication/KyuubiAuthenticationFactory.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class KyuubiAuthenticationFactory(conf: KyuubiConf, isServer: Boolean = true) ex
3939

4040
private val authTypes = conf.get(AUTHENTICATION_METHOD).map(AuthTypes.withName)
4141
private val none = authTypes.contains(NONE)
42-
private val noSasl = authTypes == Seq(NOSASL)
42+
private val noSasl = authTypes == Set(NOSASL)
4343
private val kerberosEnabled = authTypes.contains(KERBEROS)
4444
private val plainAuthTypeOpt = authTypes.filterNot(_.equals(KERBEROS))
4545
.filterNot(_.equals(NOSASL)).headOption

kyuubi-common/src/main/scala/org/apache/kyuubi/service/authentication/ldap/GroupFilterFactory.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object GroupFilterFactory extends FilterFactory {
3838
}
3939
}
4040

41-
class GroupMembershipKeyFilter(groupFilter: Seq[String]) extends Filter with Logging {
41+
class GroupMembershipKeyFilter(groupFilter: Set[String]) extends Filter with Logging {
4242

4343
@throws[AuthenticationException]
4444
override def apply(ldap: DirSearch, user: String): Unit = {
@@ -70,7 +70,7 @@ class GroupMembershipKeyFilter(groupFilter: Seq[String]) extends Filter with Log
7070
}
7171
}
7272

73-
class UserMembershipKeyFilter(groupFilter: Seq[String]) extends Filter with Logging {
73+
class UserMembershipKeyFilter(groupFilter: Set[String]) extends Filter with Logging {
7474
@throws[AuthenticationException]
7575
override def apply(ldap: DirSearch, user: String): Unit = {
7676
info(s"Authenticating user '$user' using $classOf[UserMembershipKeyFilter].getSimpleName")

kyuubi-common/src/main/scala/org/apache/kyuubi/service/authentication/ldap/UserFilterFactory.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ object UserFilterFactory extends FilterFactory with Logging {
2929
}
3030
}
3131

32-
class UserFilter(_userFilter: Seq[String]) extends Filter with Logging {
32+
class UserFilter(_userFilter: Set[String]) extends Filter with Logging {
3333

34-
lazy val userFilter: Seq[String] = _userFilter.map(_.toLowerCase)
34+
lazy val userFilter: Set[String] = _userFilter.map(_.toLowerCase)
3535

3636
@throws[AuthenticationException]
3737
override def apply(ldap: DirSearch, user: String): Unit = {

0 commit comments

Comments
 (0)