Skip to content

Commit 049e4b5

Browse files
author
ArtRand
committed
update tokens, make SparkHadoopUtil methods private
1 parent 18d77ff commit 049e4b5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class SparkHadoopUtil extends Logging {
150150
* Add or overwrite current user's credentials with serialized delegation tokens,
151151
* also confirms correct hadoop configuration is set.
152152
*/
153-
def addDelegationTokens(tokens: Array[Byte], sparkConf: SparkConf) {
153+
private[spark] def addDelegationTokens(tokens: Array[Byte], sparkConf: SparkConf) {
154154
UserGroupInformation.setConfiguration(newConfiguration(sparkConf))
155155
val creds = deserialize(tokens)
156156
logInfo(s"Adding/updating delegation tokens ${dumpTokens(creds)}")
@@ -481,7 +481,7 @@ object SparkHadoopUtil {
481481
* @param fraction fraction of the time until expiration return
482482
* @return Date when the fraction of the time until expiration has passed
483483
*/
484-
def getDateOfNextUpdate(expirationDate: Long, fraction: Double): Long = {
484+
private[spark] def getDateOfNextUpdate(expirationDate: Long, fraction: Double): Long = {
485485
val ct = System.currentTimeMillis
486486
(ct + (fraction * (expirationDate - ct))).toLong
487487
}

resource-managers/mesos/src/main/scala/org/apache/spark/scheduler/cluster/mesos/MesosHadoopDelegationTokenManager.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ private[spark] class MesosHadoopDelegationTokenManager(
9999
new Runnable {
100100
override def run(): Unit = {
101101
try {
102-
val tokensBytes = getNewDelegationTokens()
103-
broadcastDelegationTokens(tokensBytes)
102+
getNewDelegationTokens()
103+
broadcastDelegationTokens(tokens)
104104
} catch {
105105
case e: Exception =>
106106
// Log the error and try to write new tokens back in an hour
@@ -114,10 +114,9 @@ private[spark] class MesosHadoopDelegationTokenManager(
114114
scheduleRenewal(credentialRenewerRunnable)
115115
}
116116

117-
private def getNewDelegationTokens(): Array[Byte] = {
117+
private def getNewDelegationTokens(): Unit = {
118118
logInfo(s"Attempting to login to KDC with principal ${principal}")
119-
// Get new delegation tokens by logging in with a new UGI
120-
// inspired by AMCredentialRenewer.scala:L174.
119+
// Get new delegation tokens by logging in with a new UGI inspired by AMCredentialRenewer.scala
121120
// Don't protect against keytabFile being empty because it's guarded above.
122121
val ugi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytabFile.get)
123122
logInfo("Successfully logged into KDC")
@@ -142,7 +141,8 @@ private[spark] class MesosHadoopDelegationTokenManager(
142141

143142
// Add the temp credentials back to the original ones.
144143
UserGroupInformation.getCurrentUser.addCredentials(tempCreds)
145-
SparkHadoopUtil.get.serialize(tempCreds)
144+
// update tokens for late or dynamically added executors
145+
tokens = SparkHadoopUtil.get.serialize(tempCreds)
146146
}
147147

148148
private def broadcastDelegationTokens(tokens: Array[Byte]) = {

0 commit comments

Comments
 (0)