Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e1d9f71
One loader workers.
holdenk Mar 21, 2014
648b559
Both class loaders compile. Now for testing
holdenk Mar 21, 2014
8d2241e
Adda FakeClass for testing ClassLoader precedence options
holdenk Mar 21, 2014
16aecd1
Doesn't quite work
holdenk Mar 21, 2014
792d961
Almost works
holdenk Mar 22, 2014
7ef4628
Clean up
holdenk Mar 23, 2014
22d83cb
Add a test suite for the executor url class loader suite
holdenk Mar 23, 2014
47046ff
Remove bad import'
holdenk Mar 23, 2014
dc4fe44
Does not depend on being in my home directory
holdenk Mar 23, 2014
691ee00
It works ish
holdenk Mar 23, 2014
9e2d236
It works comrade
holdenk Mar 23, 2014
8a67302
Test are good
holdenk Mar 23, 2014
4919bf9
Fix parent calling class loader issue
holdenk Mar 24, 2014
d90d217
Fix fall back with custom class loader and add a test for it
holdenk Mar 24, 2014
a343350
Update rat-excludes and remove a useless file
holdenk Mar 25, 2014
241b03d
fix my rat excludes
holdenk Mar 25, 2014
bb8d179
Fix issues with the repl class loader
holdenk Mar 25, 2014
125ea7f
Easier to just remove those files, we don't need them
holdenk Mar 25, 2014
a0ef85a
Fix style issues
holdenk Mar 25, 2014
7752594
re-add https comment
holdenk Mar 25, 2014
aa95083
CR feedback
holdenk Mar 25, 2014
d4ae848
rewrite component into scala
holdenk Mar 25, 2014
7a7bf5f
CR feedback
holdenk Mar 25, 2014
261aaee
simplify executorurlclassloader a bit
holdenk Mar 25, 2014
858aba2
Remove a bunch of test junk
holdenk Apr 8, 2014
9f68f10
Start rewriting the ExecutorURLClassLoaderSuite to not use the hard c…
holdenk Apr 8, 2014
204b199
Fix the generated classes
holdenk Apr 8, 2014
f0b7114
Fix the core/src/test/scala/org/apache/spark/executor/ExecutorURLClas…
holdenk Apr 8, 2014
644719f
User the class generator for the repl class loader tests too
holdenk Apr 8, 2014
7546549
CR feedback, merge some of the testutils methods down, rename the cla…
holdenk Apr 8, 2014
8f89965
Fix tests for new class name
holdenk Apr 8, 2014
1955232
Fix long line in TestUtils
holdenk Apr 8, 2014
cf0cac9
Fix the executorclassloader
holdenk Apr 8, 2014
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
Prev Previous commit
Next Next commit
Add a test suite for the executor url class loader suite
  • Loading branch information
holdenk committed Apr 8, 2014
commit 22d83cb1338a0e4a438f8b18fbc06ef7c4ad1d07
31 changes: 31 additions & 0 deletions core/src/main/java/org/apache/spark/util/ParentClassLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.util;

/**
* A class loader which makes findClass accesiable to the child
*/
public class ParentClassLoader extends ClassLoader {
public ParentClassLoader(ClassLoader parent) {
super(parent);
}
@Override
public Class<?> findClass(String name) throws ClassNotFoundException {
return super.loadClass(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package org.apache.spark.executor

import java.net.{URLClassLoader, URL}

import org.apache.spark.util.ParentClassLoader

/**
* The addURL method in URLClassLoader is protected. We subclass it to make this accessible.
* We also make changes so user classes can come before the default classes.
Expand All @@ -36,11 +38,7 @@ private[spark] class ExecutorURLClassLoader(urls: Array[URL], parent: ClassLoade
}
}

object parentClassLoader extends ClassLoader(parent) {
override def findClass(name: String): Class[_] = {
super.findClass(name)
}
}
val parentClassLoader = new ParentClassLoader(parent)

override def findClass(name: String): Class[_] = {
if (!userFirst) {
Expand Down
Binary file added core/src/test/resources/fake-spark-class-2.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.executor

import java.io.File
import java.net.URLClassLoader

import org.scalatest.FunSuite

import org.apache.spark.test.FakeClass

class ExecutorURLClassLoaderSuite extends FunSuite {

val urls = List(new File("/home/holden/repos/spark/core/src/test/resources/fake-spark-class.jar").toURI.toURL).toArray
val urls2 = List(new File("/home/holden/repos/spark/core/src/test/resources/fake-spark-class-2.jar").toURI.toURL).toArray
test("child first") {
val parentLoader = new ExecutorURLClassLoader(urls2, null, false)
val classLoader = new ExecutorURLClassLoader(urls, parentLoader, true)
val fakeClass = classLoader.loadClass("org.apache.spark.test.FakeClass2").newInstance()
val fakeClassVersion = fakeClass.toString
assert(fakeClassVersion === "1")
}

test("parent first") {
val parentLoader = new URLClassLoader(urls2, null)
val classLoader = new ExecutorURLClassLoader(urls, parentLoader, false)
val fakeClass = classLoader.loadClass("org.apache.spark.test.FakeClass1").newInstance()
val fakeClassVersion = fakeClass.toString
assert(fakeClassVersion === "2")
}
}