Github user steveloughran commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15377#discussion_r82441129
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
    @@ -2474,25 +2474,36 @@ private[spark] class CallerContext(
        val context = "SPARK_" + from + appIdStr + appAttemptIdStr +
          jobIdStr + stageIdStr + stageAttemptIdStr + taskIdStr + 
taskAttemptNumberStr
     
    +   private var callerContextSupported: Boolean = true
    +
       /**
        * Set up the caller context [[context]] by invoking Hadoop 
CallerContext API of
        * [[org.apache.hadoop.ipc.CallerContext]], which was added in hadoop 
2.8.
        */
       def setCurrentContext(): Boolean = {
    -    var succeed = false
    -    try {
    -      // scalastyle:off classforname
    -      val callerContext = 
Class.forName("org.apache.hadoop.ipc.CallerContext")
    -      val Builder = 
Class.forName("org.apache.hadoop.ipc.CallerContext$Builder")
    -      // scalastyle:on classforname
    -      val builderInst = 
Builder.getConstructor(classOf[String]).newInstance(context)
    -      val hdfsContext = Builder.getMethod("build").invoke(builderInst)
    -      callerContext.getMethod("setCurrent", callerContext).invoke(null, 
hdfsContext)
    -      succeed = true
    -    } catch {
    -      case NonFatal(e) => logInfo("Fail to set Spark caller context", e)
    +    if (!callerContextSupported) {
    +      false
    +    } else {
    +      try {
    +        // scalastyle:off classforname
    +        val callerContext = 
Class.forName("org.apache.hadoop.ipc.CallerContext")
    +        val builder = 
Class.forName("org.apache.hadoop.ipc.CallerContext$Builder")
    +        // scalastyle:on classforname
    +        val builderInst = 
builder.getConstructor(classOf[String]).newInstance(context)
    +        val hdfsContext = builder.getMethod("build").invoke(builderInst)
    +        callerContext.getMethod("setCurrent", callerContext).invoke(null, 
hdfsContext)
    +        true
    +      } catch {
    +        case e: ClassNotFoundException =>
    +          logInfo(
    +            s"Fail to set Spark caller context: requires Hadoop 2.8 or 
later: ${e.getMessage}")
    +          callerContextSupported = false
    +          false
    +        case NonFatal(e) =>
    +          logWarning("Fail to set Spark caller context", e)
    --- End diff --
    
    There's some different deployment situations here.
    
    1. you are running on Hadoop 2.8, want caller context. A failure here is 
something to mention.
    1. you are running on Hadoop <= 2.7, don't want context or care about it. 
Here another stack trace is going to be a distraction; if it's not a support 
call then it gets added to the list of "error messages you learn to ignore". 
(this is my current state, BTW)
    1. you want caller context, but are running on an incompatible version of 
Hadoop. Again, here, logging the CNFE makes sense.
    
    Question is: do you need anything if the caller context is disabled? As I 
don't see you do. And there's a Hadoop config option 
`hadoop.caller.context.enabled` (default false), which controls that.
    
    What about looking for the config option, if it is set going through the 
introspection work, reporting problems with stack traces. And if unset: don't 
even bother with the introspection?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to