This is an automated email from the ASF dual-hosted git repository.
csy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new 4285abc3a [KYUUBI #6396] Add caching for KerberosAuthentication using
ticketCache key
4285abc3a is described below
commit 4285abc3ae44e15465587e1afdf82cd003c5654a
Author: senmiaoliu <[email protected]>
AuthorDate: Thu May 23 11:16:19 2024 +0800
[KYUUBI #6396] Add caching for KerberosAuthentication using ticketCache key
# :mag: Description
## Issue References ๐
This pull request fixes #6396
## Describe Your Solution ๐ง
By using a cache to store CachingKerberosAuthentication objects keyed by
the ticket cache path, we ensure that each unique ticket cache path generates a
distinct authentication object.
## Types of changes :bookmark:
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
## Test Plan ๐งช
#### Behavior Without This Pull Request :coffin:
#### Behavior With This Pull Request :tada:
#### Related Unit Tests
---
# Checklist ๐
- [x] This patch was not authored or co-authored using [Generative
Tooling](https://www.apache.org/legal/generative-tooling.html)
**Be nice. Be informative.**
Closes #6401 from lsm1/branch-kyuubi-6396.
Closes #6396
bb8f738e1 [senmiaoliu] fix kyuubiClientTicketCache
Authored-by: senmiaoliu <[email protected]>
Signed-off-by: Shaoyun Chen <[email protected]>
---
.../jdbc/hive/auth/KerberosAuthenticationManager.java | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/KerberosAuthenticationManager.java
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/KerberosAuthenticationManager.java
index 3df9aa836..6a639c7d6 100644
---
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/KerberosAuthenticationManager.java
+++
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/KerberosAuthenticationManager.java
@@ -22,18 +22,19 @@ import java.util.concurrent.ConcurrentHashMap;
public class KerberosAuthenticationManager {
- private static CachingKerberosAuthentication GLOBAL_TGT_CACHE_AUTHENTICATION;
+ private static final Map<String, CachingKerberosAuthentication>
TGT_CACHE_AUTHENTICATION_CACHE =
+ new ConcurrentHashMap<>();
private static final Map<String, CachingKerberosAuthentication>
KEYTAB_AUTHENTICATION_CACHE =
new ConcurrentHashMap<>();
- public static synchronized CachingKerberosAuthentication
getTgtCacheAuthentication(
- String ticketCache) {
- if (GLOBAL_TGT_CACHE_AUTHENTICATION == null) {
- KerberosAuthentication tgtCacheAuth = new
KerberosAuthentication(ticketCache);
- GLOBAL_TGT_CACHE_AUTHENTICATION = new
CachingKerberosAuthentication(tgtCacheAuth);
- }
- return GLOBAL_TGT_CACHE_AUTHENTICATION;
+ public static CachingKerberosAuthentication getTgtCacheAuthentication(String
ticketCache) {
+ return TGT_CACHE_AUTHENTICATION_CACHE.computeIfAbsent(
+ ticketCache,
+ key -> {
+ KerberosAuthentication tgtCacheAuth = new
KerberosAuthentication(ticketCache);
+ return new CachingKerberosAuthentication(tgtCacheAuth);
+ });
}
public static CachingKerberosAuthentication getKeytabAuthentication(