spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From choochootrain <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-11195][CORE] Use correct classloader fo...
Date Wed, 04 Nov 2015 05:28:34 GMT
Github user choochootrain commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9367#discussion_r43844348
  
    --- Diff: core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala ---
    @@ -366,6 +367,72 @@ class SparkSubmitSuite
         }
       }
     
    +  // SPARK-11195
    +  test("classes are correctly loaded when tasks fail") {
    +    // Compile a simple jar that throws a user defined exception on the driver
    +    val tempDir = Utils.createTempDir()
    +    val srcDir = new File(tempDir, "repro/")
    +    srcDir.mkdirs()
    +    // scalastyle:off line.size.limit
    +    val mainSource = new JavaSourceFromString(new File(srcDir, "MyJob").getAbsolutePath,
    +      """package repro;
    +        |
    +        |import java.util.*;
    +        |import java.util.regex.*;
    +        |import org.apache.spark.*;
    +        |import org.apache.spark.api.java.*;
    +        |import org.apache.spark.api.java.function.*;
    +        |
    +        |public class MyJob {
    +        |  public static class MyException extends Exception {
    +        |  }
    +        |
    +        |  public static void main(String[] args) {
    +        |    SparkConf conf = new SparkConf();
    +        |    JavaSparkContext sc = new JavaSparkContext(conf);
    +        |
    +        |    JavaRDD rdd = sc.parallelize(Arrays.asList(new Integer[]{1}), 1).map(new
Function<Integer, Boolean>() {
    +        |      public Boolean call(Integer x) throws MyException {
    +        |        throw new MyException();
    +        |      }
    +        |    });
    +        |
    +        |    try {
    +        |      rdd.collect();
    +        |
    +        |      assert(false); // should be unreachable
    +        |    } catch (Exception e) {
    +        |      // the driver should not have any problems resolving the exception class
and determining
    +        |      // why the task failed.
    +        |
    +        |      Pattern unknownFailure = Pattern.compile(".*Lost task.*: UnknownReason.*",
Pattern.DOTALL);
    +        |      Pattern expectedFailure = Pattern.compile(".*Lost task.*: repro.MyJob\\$MyException.*",
Pattern.DOTALL);
    +        |
    +        |      assert(!unknownFailure.matcher(e.getMessage()).matches());
    +        |      assert(expectedFailure.matcher(e.getMessage()).matches());
    +        |    }
    +        |  }
    +        |}
    +      """.stripMargin)
    +    // scalastyle:on line.size.limit
    +    val sparkJar = "../assembly/target/scala-2.10/spark-assembly-1.5.1-hadoop2.2.0.jar"
    --- End diff --
    
    in order to test this issue, i need to submit an external jar to `spark-submit`. i can
compile my job it using `TestUtils`, but i need to put (some version) of spark on the classpath
so that `javac` can resolve `RDD` and so on. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message