Search in sources :

Example 66 with InterpreterGroup

use of org.apache.zeppelin.interpreter.InterpreterGroup in project zeppelin by apache.

the class FlinkInterpreterTest method setUp.

@Before
public void setUp() throws InterpreterException {
    Properties p = new Properties();
    p.setProperty("zeppelin.flink.printREPLOutput", "true");
    p.setProperty("zeppelin.flink.scala.color", "false");
    p.setProperty("flink.execution.mode", "local");
    p.setProperty("local.number-taskmanager", "4");
    interpreter = new FlinkInterpreter(p);
    InterpreterGroup intpGroup = new InterpreterGroup();
    interpreter.setInterpreterGroup(intpGroup);
    interpreter.open();
    angularObjectRegistry = new AngularObjectRegistry("flink", null);
}
Also used : InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) Properties(java.util.Properties) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) Before(org.junit.Before)

Example 67 with InterpreterGroup

use of org.apache.zeppelin.interpreter.InterpreterGroup 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);
}
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) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry)

Example 68 with InterpreterGroup

use of org.apache.zeppelin.interpreter.InterpreterGroup in project zeppelin by apache.

the class IPythonKernelTest method setUp.

@Before
public void setUp() throws InterpreterException {
    Properties properties = new Properties();
    interpreter = new LazyOpenInterpreter(new JupyterInterpreter(properties));
    intpGroup = new InterpreterGroup();
    resourcePool = new LocalResourcePool("local");
    intpGroup.setResourcePool(resourcePool);
    intpGroup.put("session_1", new ArrayList<>());
    intpGroup.get("session_1").add(interpreter);
    interpreter.setInterpreterGroup(intpGroup);
    interpreter.open();
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) LazyOpenInterpreter(org.apache.zeppelin.interpreter.LazyOpenInterpreter) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) Properties(java.util.Properties) Before(org.junit.Before)

Example 69 with InterpreterGroup

use of org.apache.zeppelin.interpreter.InterpreterGroup in project SSM by Intel-bigdata.

the class RemoteInterpreterEventPoller method getResource.

private Object getResource(ResourceId resourceId) {
    InterpreterGroup intpGroup = InterpreterGroup.getByInterpreterGroupId(resourceId.getResourcePoolId());
    if (intpGroup == null) {
        return null;
    }
    RemoteInterpreterProcess remoteInterpreterProcess = intpGroup.getRemoteInterpreterProcess();
    if (remoteInterpreterProcess == null) {
        ResourcePool localPool = intpGroup.getResourcePool();
        if (localPool != null) {
            return localPool.get(resourceId.getName());
        }
    } else if (interpreterProcess.isRunning()) {
        Client client = null;
        boolean broken = false;
        try {
            client = remoteInterpreterProcess.getClient();
            ByteBuffer res = client.resourceGet(resourceId.getNoteId(), resourceId.getParagraphId(), resourceId.getName());
            Object o = Resource.deserializeObject(res);
            return o;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            broken = true;
        } finally {
            if (client != null) {
                intpGroup.getRemoteInterpreterProcess().releaseClient(client, broken);
            }
        }
    }
    return null;
}
Also used : InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) ResourcePool(org.apache.zeppelin.resource.ResourcePool) AngularObject(org.apache.zeppelin.display.AngularObject) Client(org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService.Client) ByteBuffer(java.nio.ByteBuffer) TException(org.apache.thrift.TException)

Example 70 with InterpreterGroup

use of org.apache.zeppelin.interpreter.InterpreterGroup in project SSM by Intel-bigdata.

the class RemoteInterpreterProcessTest method testStartStop.

@Test
public void testStartStop() {
    InterpreterGroup intpGroup = new InterpreterGroup();
    RemoteInterpreterManagedProcess rip = new RemoteInterpreterManagedProcess(INTERPRETER_SCRIPT, "nonexists", "fakeRepo", new HashMap<String, String>(), 10 * 1000, null, null);
    assertFalse(rip.isRunning());
    assertEquals(0, rip.referenceCount());
    assertEquals(1, rip.reference(intpGroup, "anonymous", false));
    assertEquals(2, rip.reference(intpGroup, "anonymous", false));
    assertEquals(true, rip.isRunning());
    assertEquals(1, rip.dereference());
    assertEquals(true, rip.isRunning());
    assertEquals(0, rip.dereference());
    assertEquals(false, rip.isRunning());
}
Also used : InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) 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