Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends
}
}

private val client = ugi.doAs(new PrivilegedExceptionAction[YarnRMClient]() {
def run: YarnRMClient = new YarnRMClient()
})
private val client = doAsUser { new YarnRMClient() }

// Default to twice the number of executors (twice the maximum number of executors if dynamic
// allocation is enabled), with a minimum of 3.
Expand Down Expand Up @@ -178,7 +176,7 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends
// Load the list of localized files set by the client. This is used when launching executors,
// and is loaded here so that these configs don't pollute the Web UI's environment page in
// cluster mode.
private val localResources = {
private val localResources = doAsUser {
logInfo("Preparing Local resources")
val resources = HashMap[String, LocalResource]()

Expand Down Expand Up @@ -240,9 +238,9 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends
}

final def run(): Int = {
ugi.doAs(new PrivilegedExceptionAction[Unit]() {
def run: Unit = runImpl()
})
doAsUser {
runImpl()
}
exitCode
}

Expand Down Expand Up @@ -790,6 +788,12 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends
}
}

private def doAsUser[T](fn: => T): T = {
ugi.doAs(new PrivilegedExceptionAction[T]() {
override def run: T = fn
})
}

}

object ApplicationMaster extends Logging {
Expand Down