Skip to content

Commit 9194218

Browse files
Leemoonsoolresende
authored andcommitted
initialize imain
1 parent cbf84c7 commit 9194218

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

spark/src/main/java/org/apache/zeppelin/spark/SparkInterpreter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,10 @@ public void open() {
557557
interpreter.createInterpreter();
558558

559559
intp = invokeMethod(interpreter, "intp");
560+
invokeMethod(intp, "setContextClassLoader");
561+
invokeMethod(intp, "initializeSynchronous");
560562

561563
if (isScala2_10()) {
562-
invokeMethod(intp, "setContextClassLoader");
563-
invokeMethod(intp, "initializeSynchronous");
564-
565564
if (classOutputDir == null) {
566565
classOutputDir = settings.outputDirs().getSingleOutput().get();
567566
} else {

spark/src/test/java/org/apache/zeppelin/spark/SparkInterpreterTest.java

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,21 @@ public void testListener() {
178178

179179
@Test
180180
public void testSparkSql(){
181-
if (repl.isScala2_10()) {
182-
repl.interpret("case class Person(name:String, age:Int)\n", context);
183-
repl.interpret("val people = sc.parallelize(Seq(Person(\"moon\", 33), Person(\"jobs\", 51), Person(\"gates\", 51), Person(\"park\", 34)))\n", context);
184-
assertEquals(Code.SUCCESS, repl.interpret("people.take(3)", context).code());
185-
186-
187-
if (getSparkVersionNumber() <= 11) { // spark 1.2 or later does not allow create multiple SparkContext in the same jvm by default.
188-
// create new interpreter
189-
Properties p = new Properties();
190-
SparkInterpreter repl2 = new SparkInterpreter(p);
191-
repl2.open();
192-
193-
repl.interpret("case class Man(name:String, age:Int)", context);
194-
repl.interpret("val man = sc.parallelize(Seq(Man(\"moon\", 33), Man(\"jobs\", 51), Man(\"gates\", 51), Man(\"park\", 34)))", context);
195-
assertEquals(Code.SUCCESS, repl.interpret("man.take(3)", context).code());
196-
repl2.getSparkContext().stop();
197-
}
181+
repl.interpret("case class Person(name:String, age:Int)\n", context);
182+
repl.interpret("val people = sc.parallelize(Seq(Person(\"moon\", 33), Person(\"jobs\", 51), Person(\"gates\", 51), Person(\"park\", 34)))\n", context);
183+
assertEquals(Code.SUCCESS, repl.interpret("people.take(3)", context).code());
184+
185+
186+
if (getSparkVersionNumber() <= 11) { // spark 1.2 or later does not allow create multiple SparkContext in the same jvm by default.
187+
// create new interpreter
188+
Properties p = new Properties();
189+
SparkInterpreter repl2 = new SparkInterpreter(p);
190+
repl2.open();
191+
192+
repl.interpret("case class Man(name:String, age:Int)", context);
193+
repl.interpret("val man = sc.parallelize(Seq(Man(\"moon\", 33), Man(\"jobs\", 51), Man(\"gates\", 51), Man(\"park\", 34)))", context);
194+
assertEquals(Code.SUCCESS, repl.interpret("man.take(3)", context).code());
195+
repl2.getSparkContext().stop();
198196
}
199197
}
200198

@@ -221,20 +219,18 @@ public void emptyConfigurationVariablesOnlyForNonSparkProperties() {
221219

222220
@Test
223221
public void shareSingleSparkContext() throws InterruptedException {
224-
if (repl.isScala2_10()) {
225-
// create another SparkInterpreter
226-
SparkInterpreter repl2 = new SparkInterpreter(getSparkTestProperties());
227-
repl2.setInterpreterGroup(intpGroup);
228-
intpGroup.get("note").add(repl2);
229-
repl2.open();
222+
// create another SparkInterpreter
223+
SparkInterpreter repl2 = new SparkInterpreter(getSparkTestProperties());
224+
repl2.setInterpreterGroup(intpGroup);
225+
intpGroup.get("note").add(repl2);
226+
repl2.open();
230227

231-
assertEquals(Code.SUCCESS,
232-
repl.interpret("print(sc.parallelize(1 to 10).count())", context).code());
233-
assertEquals(Code.SUCCESS,
234-
repl2.interpret("print(sc.parallelize(1 to 10).count())", context).code());
228+
assertEquals(Code.SUCCESS,
229+
repl.interpret("print(sc.parallelize(1 to 10).count())", context).code());
230+
assertEquals(Code.SUCCESS,
231+
repl2.interpret("print(sc.parallelize(1 to 10).count())", context).code());
235232

236-
repl2.close();
237-
}
233+
repl2.close();
238234
}
239235

240236
@Test

0 commit comments

Comments
 (0)