SparkSqlInterpreter extends AbstractInterpreter { public boolean concurrentSQL() { return Boolean.parseBoolean(getProperty("zeppelin.spark.concurrentSQL")); } SparkSqlInterpreter(Properties property); @Override void open(); boolean concurrentSQL(); @Override void close(); @Override ZeppelinContext getZeppelinContext(); @Override InterpreterResult internalInterpret(String st, InterpreterContext context); @Override void cancel(InterpreterContext context); @Override FormType getFormType(); @Override int getProgress(InterpreterContext context); @Override Scheduler getScheduler(); @Override List<InterpreterCompletion> completion(String buf, int cursor,
      InterpreterContext interpreterContext);  }
@Test public void testConcurrentSQL() throws InterpreterException, InterruptedException { if (!sparkInterpreter.getSparkVersion().isSpark1()) { sparkInterpreter.interpret("spark.udf.register(\"sleep\", (e:Int) => {Thread.sleep(e*1000); e})", context); } else { sparkInterpreter.interpret("sqlContext.udf.register(\"sleep\", (e:Int) => {Thread.sleep(e*1000); e})", context); } Thread thread1 = new Thread() { @Override public void run() { try { InterpreterResult result = sqlInterpreter.interpret("select sleep(10)", context); assertEquals(InterpreterResult.Code.SUCCESS, result.code()); } catch (InterpreterException e) { e.printStackTrace(); } } }; Thread thread2 = new Thread() { @Override public void run() { try { InterpreterResult result = sqlInterpreter.interpret("select sleep(10)", context); assertEquals(InterpreterResult.Code.SUCCESS, result.code()); } catch (InterpreterException e) { e.printStackTrace(); } } }; long start = System.currentTimeMillis(); thread1.start(); thread2.start(); thread1.join(); thread2.join(); long end = System.currentTimeMillis(); assertTrue("running time must be less than 20 seconds", ((end - start)/1000) < 20); }