use of org.apache.zeppelin.interpreter.Interpreter in project zeppelin by apache.
the class IPyFlinkInterpreterTest method startInterpreter.
@Override
protected void startInterpreter(Properties properties) throws InterpreterException {
InterpreterContext context = getInterpreterContext();
context.setIntpEventClient(mockIntpEventClient);
InterpreterContext.set(context);
this.flinkInnerInterpreter = new FlinkInterpreter(properties);
this.flinkScalaInterpreter = new LazyOpenInterpreter(flinkInnerInterpreter);
intpGroup = new InterpreterGroup();
intpGroup.put("session_1", new ArrayList<Interpreter>());
intpGroup.get("session_1").add(flinkScalaInterpreter);
flinkScalaInterpreter.setInterpreterGroup(intpGroup);
LazyOpenInterpreter pyFlinkInterpreter = new LazyOpenInterpreter(new PyFlinkInterpreter(properties));
intpGroup.get("session_1").add(pyFlinkInterpreter);
pyFlinkInterpreter.setInterpreterGroup(intpGroup);
interpreter = new LazyOpenInterpreter(new IPyFlinkInterpreter(properties));
intpGroup.get("session_1").add(interpreter);
interpreter.setInterpreterGroup(intpGroup);
interpreter.open();
angularObjectRegistry = new AngularObjectRegistry("flink", null);
}
use of org.apache.zeppelin.interpreter.Interpreter in project zeppelin by apache.
the class FileSystemRecoveryStorageTest method testMultipleInterpreterProcess.
@Test
public void testMultipleInterpreterProcess() throws InterpreterException, IOException {
InterpreterSetting interpreterSetting = interpreterSettingManager.getByName("test");
interpreterSetting.getOption().setPerUser(InterpreterOption.ISOLATED);
Interpreter interpreter1 = interpreterSetting.getDefaultInterpreter("user1", note1Id);
RemoteInterpreter remoteInterpreter1 = (RemoteInterpreter) interpreter1;
InterpreterContext context1 = InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
remoteInterpreter1.interpret("hello", context1);
assertEquals(1, interpreterSettingManager.getRecoveryStorage().restore().size());
Interpreter interpreter2 = interpreterSetting.getDefaultInterpreter("user2", note2Id);
RemoteInterpreter remoteInterpreter2 = (RemoteInterpreter) interpreter2;
InterpreterContext context2 = InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
remoteInterpreter2.interpret("hello", context2);
assertEquals(2, interpreterSettingManager.getRecoveryStorage().restore().size());
interpreterSettingManager.restart(interpreterSetting.getId(), "user1", note1Id);
assertEquals(1, interpreterSettingManager.getRecoveryStorage().restore().size());
interpreterSetting.close();
assertEquals(0, interpreterSettingManager.getRecoveryStorage().restore().size());
}
use of org.apache.zeppelin.interpreter.Interpreter in project zeppelin by apache.
the class RemoteInterpreterTest method testMultiInterpreterSession.
@Test
public void testMultiInterpreterSession() {
interpreterSetting.getOption().setPerUser(InterpreterOption.SCOPED);
Interpreter interpreter1_user1 = interpreterSetting.getInterpreter("user1", note1Id, "sleep");
Interpreter interpreter2_user1 = interpreterSetting.getInterpreter("user1", note1Id, "echo");
assertEquals(interpreter1_user1.getInterpreterGroup(), interpreter2_user1.getInterpreterGroup());
assertEquals(interpreter1_user1.getScheduler(), interpreter2_user1.getScheduler());
Interpreter interpreter1_user2 = interpreterSetting.getInterpreter("user2", note1Id, "sleep");
Interpreter interpreter2_user2 = interpreterSetting.getInterpreter("user2", note1Id, "echo");
assertEquals(interpreter1_user2.getInterpreterGroup(), interpreter2_user2.getInterpreterGroup());
assertEquals(interpreter1_user2.getScheduler(), interpreter2_user2.getScheduler());
// scheduler is shared in session but not across session
assertNotEquals(interpreter1_user1.getScheduler(), interpreter1_user2.getScheduler());
}
use of org.apache.zeppelin.interpreter.Interpreter in project zeppelin by apache.
the class RemoteInterpreterTest method testFailToLaunchInterpreterProcess_ErrorInRunner.
@Test
public void testFailToLaunchInterpreterProcess_ErrorInRunner() {
try {
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_REMOTE_RUNNER.getVarName(), zeppelinHome.getAbsolutePath() + "/zeppelin-zengine/src/test/resources/bin/interpreter_invalid.sh");
final Interpreter interpreter1 = interpreterSetting.getInterpreter("user1", note1Id, "sleep");
final InterpreterContext context1 = createDummyInterpreterContext();
// time overhead of launching the process.
try {
interpreter1.interpret("1", context1);
fail("Should not be able to launch interpreter process");
} catch (InterpreterException e) {
assertTrue(ExceptionUtils.getStackTrace(e).contains("invalid_command:"));
}
} finally {
System.clearProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_REMOTE_RUNNER.getVarName());
}
}
use of org.apache.zeppelin.interpreter.Interpreter in project zeppelin by apache.
the class RemoteInterpreterTest method testFailToLaunchInterpreterProcess_Timeout.
@Test
public void testFailToLaunchInterpreterProcess_Timeout() {
try {
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_REMOTE_RUNNER.getVarName(), zeppelinHome.getAbsolutePath() + "/zeppelin-zengine/src/test/resources/bin/interpreter_timeout.sh");
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName(), "10000");
final Interpreter interpreter1 = interpreterSetting.getInterpreter("user1", note1Id, "sleep");
final InterpreterContext context1 = createDummyInterpreterContext();
// time overhead of launching the process.
try {
interpreter1.interpret("1", context1);
fail("Should not be able to launch interpreter process");
} catch (InterpreterException e) {
assertTrue(ExceptionUtils.getStackTrace(e).contains("Interpreter Process creation is time out"));
}
} finally {
System.clearProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_REMOTE_RUNNER.getVarName());
System.clearProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName());
}
}
Aggregations