Search in sources :

Example 56 with InterpreterGroup

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());
                }
            }
        }
    }
}
Also used : InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) ManagedInterpreterGroup(org.apache.zeppelin.interpreter.ManagedInterpreterGroup) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) RemoteAngularObjectRegistry(org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) RemoteAngularObjectRegistry(org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry)

Example 57 with InterpreterGroup

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());
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) InterpreterNotFoundException(org.apache.zeppelin.interpreter.InterpreterNotFoundException) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException) RepositoryException(org.eclipse.aether.RepositoryException) AbstractInterpreterTest(org.apache.zeppelin.interpreter.AbstractInterpreterTest) Test(org.junit.Test)

Example 58 with InterpreterGroup

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();
}
Also used : LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) Interpreter(org.apache.zeppelin.interpreter.Interpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext)

Example 59 with InterpreterGroup

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();
}
Also used : Interpreter(org.apache.zeppelin.interpreter.Interpreter) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterOutput(org.apache.zeppelin.interpreter.InterpreterOutput) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) BeforeClass(org.junit.BeforeClass)

Example 60 with InterpreterGroup

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"));
    }
}
Also used : LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) Interpreter(org.apache.zeppelin.interpreter.Interpreter) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) Properties(java.util.Properties) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) Test(org.junit.Test)

Aggregations

InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)74 Properties (java.util.Properties)30 Interpreter (org.apache.zeppelin.interpreter.Interpreter)27 Test (org.junit.Test)26 LazyOpenInterpreter (org.apache.zeppelin.interpreter.LazyOpenInterpreter)23 Before (org.junit.Before)19 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)18 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)17 RemoteAngularObjectRegistry (org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry)14 IOException (java.io.IOException)12 TException (org.apache.thrift.TException)12 AngularObject (org.apache.zeppelin.display.AngularObject)12 List (java.util.List)10 InterpreterOutput (org.apache.zeppelin.interpreter.InterpreterOutput)10 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)10 Note (org.apache.zeppelin.notebook.Note)9 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)8 Paragraph (org.apache.zeppelin.notebook.Paragraph)8 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)7 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)7