File tree Expand file tree Collapse file tree 4 files changed +30
-8
lines changed
main/scala/org/apache/kyuubi/util
test/scala/org/apache/kyuubi/util
kyuubi-server/src/main/scala/org/apache/kyuubi Expand file tree Collapse file tree 4 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -41,9 +41,12 @@ object KyuubiHadoopUtils {
41
41
classOf [Credentials ].getDeclaredField(" tokenMap" )
42
42
tokenMapField.setAccessible(true )
43
43
44
- def newHadoopConf (conf : KyuubiConf ): Configuration = {
45
- val hadoopConf = new Configuration ()
46
- conf.getAll.foreach { case (k, v) => hadoopConf.set(k, v) }
44
+ def newHadoopConf (
45
+ conf : KyuubiConf ,
46
+ loadDefaults : Boolean = true ): Configuration = {
47
+ val hadoopConf = new Configuration (loadDefaults)
48
+ conf.getAll
49
+ .foreach { case (k, v) => hadoopConf.set(k, v) }
47
50
hadoopConf
48
51
}
49
52
Original file line number Diff line number Diff line change 17
17
18
18
package org .apache .kyuubi .util
19
19
20
+ import java .util .stream .StreamSupport
21
+
20
22
import scala .util .Random
21
23
22
24
import org .apache .hadoop .io .Text
@@ -59,4 +61,18 @@ class KyuubiHadoopUtilsSuite extends KyuubiFunSuite {
59
61
KyuubiHadoopUtils .encodeCredentials(credentials))
60
62
assert(decoded.getToken(token.getKind) == credentials.getToken(token.getKind))
61
63
}
64
+
65
+ test(" new hadoop conf with kyuubi conf with loadDefaults" ) {
66
+ val abc = " kyuubi.abc"
67
+ val kyuubiConf = new KyuubiConf ()
68
+ .set(abc, " xyz" )
69
+
70
+ var hadoopConf = KyuubiHadoopUtils .newHadoopConf(kyuubiConf)
71
+ assert(StreamSupport .stream(hadoopConf.spliterator(), false )
72
+ .anyMatch(entry => entry.getKey.startsWith(" hadoop" ) || entry.getKey.startsWith(" fs" )))
73
+
74
+ hadoopConf = KyuubiHadoopUtils .newHadoopConf(kyuubiConf, loadDefaults = false )
75
+ assert(StreamSupport .stream(hadoopConf.spliterator(), false )
76
+ .noneMatch(entry => entry.getKey.startsWith(" hadoop" ) || entry.getKey.startsWith(" fs" )))
77
+ }
62
78
}
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod
31
31
import org .apache .kyuubi .Logging
32
32
import org .apache .kyuubi .config .KyuubiConf
33
33
import org .apache .kyuubi .credentials .HadoopFsDelegationTokenProvider .{disableFsCache , doAsProxyUser }
34
+ import org .apache .kyuubi .util .KyuubiHadoopUtils
34
35
35
36
class HadoopFsDelegationTokenProvider extends HadoopDelegationTokenProvider with Logging {
36
37
@@ -80,7 +81,10 @@ object HadoopFsDelegationTokenProvider {
80
81
81
82
def disableFsCache (kyuubiConf : KyuubiConf , hadoopConf : Configuration ): Configuration = {
82
83
// Avoid unnecessary disk io by not loading default resources
83
- val newConf = new Configuration (false )
84
+ val newConf = KyuubiHadoopUtils .newHadoopConf(
85
+ kyuubiConf,
86
+ loadDefaults = false )
87
+
84
88
hadoopConf.iterator().asScala.foreach(e => newConf.set(e.getKey, e.getValue))
85
89
86
90
hadoopFSsToAccess(kyuubiConf, hadoopConf)
Original file line number Diff line number Diff line change @@ -19,8 +19,6 @@ package org.apache.kyuubi.server
19
19
20
20
import java .net .InetAddress
21
21
22
- import org .apache .hadoop .conf .Configuration
23
-
24
22
import org .apache .kyuubi .config .KyuubiConf
25
23
import org .apache .kyuubi .config .KyuubiConf .SERVER_EVENT_JSON_LOG_PATH
26
24
import org .apache .kyuubi .config .KyuubiConf .SERVER_EVENT_LOGGERS
@@ -33,6 +31,7 @@ import org.apache.kyuubi.util.KyuubiHadoopUtils
33
31
class EventLoggingService extends AbstractEventLoggingService [KyuubiServerEvent ] {
34
32
35
33
override def initialize (conf : KyuubiConf ): Unit = {
34
+ val hadoopConf = KyuubiHadoopUtils .newHadoopConf(conf)
36
35
conf.get(SERVER_EVENT_LOGGERS )
37
36
.map(EventLoggerType .withName)
38
37
.foreach {
@@ -41,9 +40,9 @@ class EventLoggingService extends AbstractEventLoggingService[KyuubiServerEvent]
41
40
val jsonEventLogger = new JsonEventLogger [KyuubiServerEvent ](
42
41
s " server- $hostName" ,
43
42
SERVER_EVENT_JSON_LOG_PATH ,
44
- new Configuration () )
43
+ hadoopConf )
45
44
// TODO: #1180 kyuubiServerEvent need create logRoot automatically
46
- jsonEventLogger.createEventLogRootDir(conf, KyuubiHadoopUtils .newHadoopConf(conf) )
45
+ jsonEventLogger.createEventLogRootDir(conf, hadoopConf )
47
46
addService(jsonEventLogger)
48
47
addEventLogger(jsonEventLogger)
49
48
case logger =>
You can’t perform that action at this time.
0 commit comments