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

    https://github.com/apache/spark/pull/4111#discussion_r23333878
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkContext.scala ---
    @@ -379,6 +379,41 @@ class SparkContext(config: SparkConf) extends Logging 
with ExecutorAllocationCli
         }
       executorAllocationManager.foreach(_.start())
     
    +  // Use reflection to instantiate listeners specified via the 
`spark.extraListeners` configuration
    +  // or the SPARK_EXTRA_LISTENERS environment variable
    +  try {
    +    val listenerClassNames: Seq[String] = {
    +      val fromSparkConf = conf.get("spark.extraListeners", "").split(',')
    +      val fromEnvVar = 
Option(conf.getenv("SPARK_EXTRA_LISTENERS")).getOrElse("").split(',')
    +      (fromSparkConf ++ fromEnvVar).map(_.trim).filter(_ != "")
    +    }
    +    for (className <- listenerClassNames) {
    +      val listenerClass = Class.forName(className).asInstanceOf[Class[_ <: 
SparkListener]]
    +      val listener = try {
    +        listenerClass.getConstructor(classOf[SparkConf]).newInstance(conf)
    +      } catch {
    --- End diff --
    
    So using exceptions for basically branching is not really great. You can 
alternatively use:
    
http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getDeclaredConstructors%28%29
 to find the right constructor.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to