-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[ZEPPELIN-3986]. Cannot access any JAR in yarn cluster mode #3308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * 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.zeppelin.interpreter.integration; | ||
|
|
||
| public class DummyClass { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,19 +22,24 @@ | |
| import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; | ||
| import org.apache.hadoop.yarn.api.records.YarnApplicationState; | ||
| import org.apache.hadoop.yarn.exceptions.YarnException; | ||
| import org.apache.maven.model.Model; | ||
| import org.apache.maven.model.io.xpp3.MavenXpp3Reader; | ||
| import org.apache.zeppelin.interpreter.Interpreter; | ||
| import org.apache.zeppelin.interpreter.InterpreterContext; | ||
| import org.apache.zeppelin.interpreter.InterpreterException; | ||
| import org.apache.zeppelin.interpreter.InterpreterFactory; | ||
| import org.apache.zeppelin.interpreter.InterpreterResult; | ||
| import org.apache.zeppelin.interpreter.InterpreterSetting; | ||
| import org.apache.zeppelin.interpreter.InterpreterSettingManager; | ||
| import org.codehaus.plexus.util.xml.pull.XmlPullParserException; | ||
| import org.junit.AfterClass; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.io.File; | ||
| import java.io.FileReader; | ||
| import java.io.IOException; | ||
| import java.util.EnumSet; | ||
|
|
||
|
|
@@ -80,7 +85,14 @@ public static void tearDown() throws IOException { | |
| } | ||
| } | ||
|
|
||
| private void testInterpreterBasics() throws IOException, InterpreterException { | ||
| private void testInterpreterBasics() throws IOException, InterpreterException, XmlPullParserException { | ||
| // add jars & packages for testing | ||
| InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark"); | ||
| sparkInterpreterSetting.setProperty("spark.jars.packages", "com.maxmind.geoip2:geoip2:2.5.0"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use something in org.apache.zeppelin instead?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may already shipped to spark driver and put under classpath. So it is better to use some other libraries. |
||
| MavenXpp3Reader reader = new MavenXpp3Reader(); | ||
| Model model = reader.read(new FileReader("pom.xml")); | ||
| sparkInterpreterSetting.setProperty("spark.jars", new File("target/zeppelin-interpreter-integration-" + model.getVersion() + ".jar").getAbsolutePath()); | ||
|
|
||
| // test SparkInterpreter | ||
| Interpreter sparkInterpreter = interpreterFactory.getInterpreter("user1", "note1", "spark.spark", "test"); | ||
|
|
||
|
|
@@ -93,6 +105,11 @@ private void testInterpreterBasics() throws IOException, InterpreterException { | |
| assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code()); | ||
| assertTrue(interpreterResult.message().get(0).getData().contains("45")); | ||
|
|
||
| // test jars & packages can be loaded correctly | ||
| interpreterResult = sparkInterpreter.interpret("import org.apache.zeppelin.interpreter.integration.DummyClass\n" + | ||
| "import com.maxmind.geoip2._", context); | ||
| assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code()); | ||
|
|
||
| // test PySparkInterpreter | ||
| Interpreter pySparkInterpreter = interpreterFactory.getInterpreter("user1", "note1", "spark.pyspark", "test"); | ||
| interpreterResult = pySparkInterpreter.interpret("sqlContext.createDataFrame([(1,'a'),(2,'b')], ['id','name']).registerTempTable('test')", context); | ||
|
|
@@ -123,7 +140,7 @@ private void testInterpreterBasics() throws IOException, InterpreterException { | |
| } | ||
|
|
||
| @Test | ||
| public void testLocalMode() throws IOException, YarnException, InterpreterException { | ||
| public void testLocalMode() throws IOException, YarnException, InterpreterException, XmlPullParserException { | ||
| InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark"); | ||
| sparkInterpreterSetting.setProperty("master", "local[*]"); | ||
| sparkInterpreterSetting.setProperty("SPARK_HOME", sparkHome); | ||
|
|
@@ -143,7 +160,7 @@ public void testLocalMode() throws IOException, YarnException, InterpreterExcept | |
| } | ||
|
|
||
| @Test | ||
| public void testYarnClientMode() throws IOException, YarnException, InterruptedException, InterpreterException { | ||
| public void testYarnClientMode() throws IOException, YarnException, InterruptedException, InterpreterException, XmlPullParserException { | ||
| InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark"); | ||
| sparkInterpreterSetting.setProperty("master", "yarn-client"); | ||
| sparkInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath()); | ||
|
|
@@ -166,7 +183,7 @@ public void testYarnClientMode() throws IOException, YarnException, InterruptedE | |
| } | ||
|
|
||
| @Test | ||
| public void testYarnClusterMode() throws IOException, YarnException, InterruptedException, InterpreterException { | ||
| public void testYarnClusterMode() throws IOException, YarnException, InterruptedException, InterpreterException, XmlPullParserException { | ||
| InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark"); | ||
| sparkInterpreterSetting.setProperty("master", "yarn-cluster"); | ||
| sparkInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can not test user jar case in unit test (MutableURLClassLoader only exist in real spark app which is launched via spark-submit) . So remove it here.