Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions livy/src/main/java/org/apache/zeppelin/livy/LivyHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public Integer createSession(InterpreterContext context, String kind) throws Exc
}.getType());
if (jsonMap.get("state").equals("idle")) {
break;
} else if (jsonMap.get("state").equals("error")) {
} else if (jsonMap.get("state").equals("error") || jsonMap.get("state").equals("dead")) {
json = executeHTTP(property.getProperty("zeppelin.livy.url") + "/sessions/" +
sessionId + "/log",
"GET", null,
Expand Down Expand Up @@ -124,7 +124,7 @@ public Integer createSession(InterpreterContext context, String kind) throws Exc

protected void initializeSpark(final InterpreterContext context,
final Map<String, Integer> userSessionMap) throws Exception {
interpret("val sqlContext= new org.apache.spark.sql.SQLContext(sc)\n" +
interpret("val sqlContext = new org.apache.spark.sql.SQLContext(sc)\n" +
"import sqlContext.implicits._", context, userSessionMap);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public InterpreterResult interpret(String line, InterpreterContext interpreterCo
line.replaceAll("\"", "\\\\\"")
.replaceAll("\\n", " ")
+ "\").show(" +
property.get("livy.spark.sql.maxResult") + ")",
property.get("zeppelin.livy.spark.sql.maxResult") + ")",
interpreterContext, userSessionMap);

if (res.code() == InterpreterResult.Code.SUCCESS) {
Expand Down Expand Up @@ -123,6 +123,10 @@ public InterpreterResult interpret(String line, InterpreterContext interpreterCo
}
}

public boolean concurrentSQL() {
return Boolean.parseBoolean(getProperty("zeppelin.livy.concurrentSQL"));
}

@Override
public void cancel(InterpreterContext context) {
livyHelper.cancelHTTP(context.getParagraphId());
Expand All @@ -140,8 +144,19 @@ public int getProgress(InterpreterContext context) {

@Override
public Scheduler getScheduler() {
return SchedulerFactory.singleton().createOrGetFIFOScheduler(
LivySparkInterpreter.class.getName() + this.hashCode());
if (concurrentSQL()) {
int maxConcurrency = 10;
return SchedulerFactory.singleton().createOrGetParallelScheduler(
LivySparkInterpreter.class.getName() + this.hashCode(), maxConcurrency);
} else {
Interpreter intp =
getInterpreterInTheSameSessionByClassName(LivySparkInterpreter.class.getName());
if (intp != null) {
return intp.getScheduler();
} else {
return null;
}
}
}

@Override
Expand Down
5 changes: 5 additions & 0 deletions livy/src/main/resources/interpreter-setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
"propertyName": "zeppelin.livy.spark.sql.maxResult",
"defaultValue": "1000",
"description": "Max number of SparkSQL result to display."
},
"zeppelin.livy.concurrentSQL": {
"propertyName": "zeppelin.livy.concurrentSQL",
"defaultValue": "false",
"description": "Execute multiple SQL concurrently if set true."
}
}
},
Expand Down