@@ -40,20 +40,19 @@ private[kafka010] object TokenUtil extends Logging {
40
40
override def getKind : Text = TOKEN_KIND ;
41
41
}
42
42
43
- private def printToken (token : DelegationToken ): Unit = {
44
- if (log.isDebugEnabled) {
45
- val dateFormat = new SimpleDateFormat (" yyyy-MM-dd'T'HH:mm" )
46
- logDebug(" %-15s %-30s %-15s %-25s %-15s %-15s %-15s" .format(
47
- " TOKENID" , " HMAC" , " OWNER" , " RENEWERS" , " ISSUEDATE" , " EXPIRYDATE" , " MAXDATE" ))
48
- val tokenInfo = token.tokenInfo
49
- logDebug(" %-15s [hidden] %-15s %-25s %-15s %-15s %-15s" .format(
50
- tokenInfo.tokenId,
51
- tokenInfo.owner,
52
- tokenInfo.renewersAsString,
53
- dateFormat.format(tokenInfo.issueTimestamp),
54
- dateFormat.format(tokenInfo.expiryTimestamp),
55
- dateFormat.format(tokenInfo.maxTimestamp)))
56
- }
43
+ def obtainToken (sparkConf : SparkConf ): (Token [_ <: TokenIdentifier ], Long ) = {
44
+ val adminClient = AdminClient .create(createAdminClientProperties(sparkConf))
45
+ val createDelegationTokenOptions = new CreateDelegationTokenOptions ()
46
+ val createResult = adminClient.createDelegationToken(createDelegationTokenOptions)
47
+ val token = createResult.delegationToken().get()
48
+ printToken(token)
49
+
50
+ new Token [KafkaDelegationTokenIdentifier ](
51
+ token.tokenInfo.tokenId.getBytes,
52
+ token.hmacAsBase64String.getBytes,
53
+ TOKEN_KIND ,
54
+ TOKEN_SERVICE
55
+ )
57
56
}
58
57
59
58
private [kafka010] def createAdminClientProperties (sparkConf : SparkConf ): Properties = {
@@ -94,18 +93,19 @@ private[kafka010] object TokenUtil extends Logging {
94
93
adminClientProperties
95
94
}
96
95
97
- def obtainToken (sparkConf : SparkConf ): Token [_ <: TokenIdentifier ] = {
98
- val adminClient = AdminClient .create(createAdminClientProperties(sparkConf))
99
- val createDelegationTokenOptions = new CreateDelegationTokenOptions ()
100
- val createResult = adminClient.createDelegationToken(createDelegationTokenOptions)
101
- val token = createResult.delegationToken().get()
102
- printToken(token)
103
-
104
- new Token [KafkaDelegationTokenIdentifier ](
105
- token.tokenInfo.tokenId.getBytes,
106
- token.hmacAsBase64String.getBytes,
107
- TOKEN_KIND ,
108
- TOKEN_SERVICE
109
- )
96
+ private def printToken (token : DelegationToken ): Unit = {
97
+ if (log.isDebugEnabled) {
98
+ val dateFormat = new SimpleDateFormat (" yyyy-MM-dd'T'HH:mm" )
99
+ logDebug(" %-15s %-30s %-15s %-25s %-15s %-15s %-15s" .format(
100
+ " TOKENID" , " HMAC" , " OWNER" , " RENEWERS" , " ISSUEDATE" , " EXPIRYDATE" , " MAXDATE" ))
101
+ val tokenInfo = token.tokenInfo
102
+ logDebug(" %-15s [hidden] %-15s %-25s %-15s %-15s %-15s" .format(
103
+ tokenInfo.tokenId,
104
+ tokenInfo.owner,
105
+ tokenInfo.renewersAsString,
106
+ dateFormat.format(tokenInfo.issueTimestamp),
107
+ dateFormat.format(tokenInfo.expiryTimestamp),
108
+ dateFormat.format(tokenInfo.maxTimestamp)))
109
+ }
110
110
}
111
111
}
0 commit comments