@Override protected ClassLoader createProgramInvocationClassLoader() { return new WeakReferenceDelegatorClassLoader(mapReduceClassLoader); }
@Override protected ClassLoader createProgramInvocationClassLoader() { return new WeakReferenceDelegatorClassLoader(mapReduceClassLoader); }
@Override protected ClassLoader createProgramInvocationClassLoader() { if (mapReduceClassLoader == null) { // This shouldn't happen. Just to prevent bug and be able to catch it in unit-test. throw new IllegalStateException("The MapReduceClassLoader is not yet set"); } return new WeakReferenceDelegatorClassLoader(mapReduceClassLoader); }
@Override protected ClassLoader createProgramInvocationClassLoader() { if (mapReduceClassLoader == null) { // This shouldn't happen. Just to prevent bug and be able to catch it in unit-test. throw new IllegalStateException("The MapReduceClassLoader is not yet set"); } return new WeakReferenceDelegatorClassLoader(mapReduceClassLoader); }
public WeakReferenceDelegatorClassLoader(ClassLoader classLoader) { // Wrap the parent with a weak reference as well. super(EMPTY_URLS, classLoader.getParent() == null ? null : new WeakReferenceDelegatorClassLoader(classLoader.getParent())); this.delegate = new WeakReference<>(classLoader); }
public WeakReferenceDelegatorClassLoader(ClassLoader classLoader) { // Wrap the parent with a weak reference as well. super(EMPTY_URLS, classLoader.getParent() == null ? null : new WeakReferenceDelegatorClassLoader(classLoader.getParent())); this.delegate = new WeakReference<>(classLoader); }
@Override protected ClassLoader createProgramInvocationClassLoader() { sparkClassLoader = new SparkClassLoader(this); ClassLoader classLoader = new WeakReferenceDelegatorClassLoader(sparkClassLoader); hConf.setClassLoader(classLoader); return classLoader; }
@Override protected ClassLoader createProgramInvocationClassLoader() { sparkClassLoader = new SparkClassLoader(this); ClassLoader classLoader = new WeakReferenceDelegatorClassLoader(sparkClassLoader); hConf.setClassLoader(classLoader); return classLoader; }
@Override protected ClassLoader createProgramInvocationClassLoader() { sparkClassLoader = new SparkClassLoader(this); ClassLoader classLoader = new WeakReferenceDelegatorClassLoader(sparkClassLoader); hConf.setClassLoader(classLoader); return classLoader; }
public void run(Context context) throws IOException, InterruptedException { MapReduceClassLoader classLoader = MapReduceClassLoader.getFromConfiguration(context.getConfiguration()); ClassLoader weakReferenceClassLoader = new WeakReferenceDelegatorClassLoader(classLoader);
public void run(Context context) throws IOException, InterruptedException { MapReduceClassLoader classLoader = MapReduceClassLoader.getFromConfiguration(context.getConfiguration()); ClassLoader weakReferenceClassLoader = new WeakReferenceDelegatorClassLoader(classLoader);
public void run(Context context) throws IOException, InterruptedException { MapReduceClassLoader classLoader = MapReduceClassLoader.getFromConfiguration(context.getConfiguration()); ClassLoader weakReferenceClassLoader = new WeakReferenceDelegatorClassLoader(classLoader);
public void run(Context context) throws IOException, InterruptedException { MapReduceClassLoader classLoader = MapReduceClassLoader.getFromConfiguration(context.getConfiguration()); ClassLoader weakReferenceClassLoader = new WeakReferenceDelegatorClassLoader(classLoader);
@Test public void testWeakReferenceClassLoader() throws Exception { // Creates a jar that has Application class in it. Location jar = AppJarHelper.createDeploymentJar(new LocalLocationFactory(TMP_FOLDER.newFolder()), ClassLoaderTest.class); // Create a class loader that load from that jar. File unpackDir = TMP_FOLDER.newFolder(); BundleJarUtil.unJar(jar, unpackDir); ClassLoader cl = new DirectoryClassLoader(unpackDir, null, "lib"); // Wrap it with the WeakReference ClassLoader ClassLoader classLoader = new WeakReferenceDelegatorClassLoader(cl); // Load class from the wrapped ClassLoader, should succeed and should be loaded by the delegating ClassLoader. Class<?> cls = classLoader.loadClass(ClassLoaderTest.class.getName()); Assert.assertSame(cl, cls.getClassLoader()); Assert.assertSame(cl, Delegators.getDelegate(classLoader, ClassLoader.class)); // There is no good way to test the GC of the weak reference referent since it depends on GC. }