use of org.apache.zeppelin.interpreter.InterpreterGroup in project zeppelin by apache.
the class Note method removeAllAngularObjectInParagraph.
private void removeAllAngularObjectInParagraph(String user, String paragraphId) {
angularObjects = new HashMap<>();
List<InterpreterSetting> settings = getBindedInterpreterSettings(Arrays.asList(user));
if (settings == null || settings.isEmpty()) {
return;
}
for (InterpreterSetting setting : settings) {
if (setting.getInterpreterGroup(getExecutionContext()) == null) {
continue;
}
InterpreterGroup intpGroup = setting.getInterpreterGroup(getExecutionContext());
AngularObjectRegistry registry = intpGroup.getAngularObjectRegistry();
if (registry instanceof RemoteAngularObjectRegistry) {
// remove paragraph scope object
((RemoteAngularObjectRegistry) registry).removeAllAndNotifyRemoteProcess(id, paragraphId);
// remove app scope object
List<ApplicationState> appStates = getParagraph(paragraphId).getAllApplicationStates();
if (appStates != null) {
for (ApplicationState app : appStates) {
((RemoteAngularObjectRegistry) registry).removeAllAndNotifyRemoteProcess(id, app.getId());
}
}
} else {
registry.removeAll(id, paragraphId);
// remove app scope object
List<ApplicationState> appStates = getParagraph(paragraphId).getAllApplicationStates();
if (appStates != null) {
for (ApplicationState app : appStates) {
registry.removeAll(id, app.getId());
}
}
}
}
}
use of org.apache.zeppelin.interpreter.InterpreterGroup in project zeppelin by apache.
the class NotebookTest method testResourceRemovealOnParagraphNoteRemove.
@Test
public void testResourceRemovealOnParagraphNoteRemove() throws Exception {
String noteId = notebook.createNote("note1", anonymous);
notebook.processNote(noteId, note -> {
Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
p1.setText("%mock1 hello");
Paragraph p2 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
p2.setText("%mock2 world");
for (InterpreterGroup intpGroup : interpreterSettingManager.getAllInterpreterGroup()) {
intpGroup.setResourcePool(new LocalResourcePool(intpGroup.getId()));
}
try {
note.runAll(anonymous, true, false, new HashMap<>());
} catch (Exception e) {
fail();
}
assertEquals(2, interpreterSettingManager.getAllResources().size());
// remove a paragraph
note.removeParagraph(anonymous.getUser(), p1.getId());
assertEquals(1, interpreterSettingManager.getAllResources().size());
return null;
});
// remove note
notebook.removeNote(noteId, anonymous);
assertEquals(0, interpreterSettingManager.getAllResources().size());
}
use of org.apache.zeppelin.interpreter.InterpreterGroup in project zeppelin by apache.
the class IPySparkInterpreterTest method startInterpreter.
@Override
protected void startInterpreter(Properties properties) throws InterpreterException {
InterpreterContext context = getInterpreterContext();
context.setIntpEventClient(mockIntpEventClient);
InterpreterContext.set(context);
LazyOpenInterpreter sparkInterpreter = new LazyOpenInterpreter(new SparkInterpreter(properties));
intpGroup = new InterpreterGroup();
intpGroup.put("session_1", new ArrayList<Interpreter>());
intpGroup.get("session_1").add(sparkInterpreter);
sparkInterpreter.setInterpreterGroup(intpGroup);
LazyOpenInterpreter pySparkInterpreter = new LazyOpenInterpreter(new PySparkInterpreter(properties));
intpGroup.get("session_1").add(pySparkInterpreter);
pySparkInterpreter.setInterpreterGroup(intpGroup);
interpreter = new LazyOpenInterpreter(new IPySparkInterpreter(properties));
intpGroup.get("session_1").add(interpreter);
interpreter.setInterpreterGroup(intpGroup);
pySparkInterpreter.open();
interpreter.open();
}
use of org.apache.zeppelin.interpreter.InterpreterGroup in project zeppelin by apache.
the class PySparkInterpreterMatplotlibTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
intpGroup = new InterpreterGroup();
intpGroup.put("note", new LinkedList<Interpreter>());
context = InterpreterContext.builder().setNoteId("note").setInterpreterOut(new InterpreterOutput()).setIntpEventClient(mock(RemoteInterpreterEventClient.class)).setAngularObjectRegistry(new AngularObjectRegistry(intpGroup.getId(), null)).build();
InterpreterContext.set(context);
sparkInterpreter = new SparkInterpreter(getPySparkTestProperties());
intpGroup.get("note").add(sparkInterpreter);
sparkInterpreter.setInterpreterGroup(intpGroup);
sparkInterpreter.open();
pyspark = new AltPySparkInterpreter(getPySparkTestProperties());
intpGroup.get("note").add(pyspark);
pyspark.setInterpreterGroup(intpGroup);
pyspark.open();
}
use of org.apache.zeppelin.interpreter.InterpreterGroup in project zeppelin by apache.
the class SparkRInterpreterTest method testInvalidR.
@Test
public void testInvalidR() throws InterpreterException {
tearDown();
Properties properties = new Properties();
properties.setProperty("zeppelin.R.cmd", "invalid_r");
properties.setProperty(SparkStringConstants.MASTER_PROP_NAME, "local");
properties.setProperty(SparkStringConstants.APP_NAME_PROP_NAME, "test");
InterpreterGroup interpreterGroup = new InterpreterGroup();
Interpreter sparkRInterpreter = new LazyOpenInterpreter(new SparkRInterpreter(properties));
Interpreter sparkInterpreter = new LazyOpenInterpreter(new SparkInterpreter(properties));
interpreterGroup.addInterpreterToSession(sparkRInterpreter, "session_1");
interpreterGroup.addInterpreterToSession(sparkInterpreter, "session_1");
sparkRInterpreter.setInterpreterGroup(interpreterGroup);
sparkInterpreter.setInterpreterGroup(interpreterGroup);
InterpreterContext context = getInterpreterContext();
InterpreterContext.set(context);
try {
sparkRInterpreter.interpret("1+1", getInterpreterContext());
fail("Should fail to open SparkRInterpreter");
} catch (InterpreterException e) {
String stacktrace = ExceptionUtils.getStackTrace(e);
assertTrue(stacktrace, stacktrace.contains("No such file or directory"));
}
}
Aggregations