Search in sources :

Example 1 with InterpreterOutputListener

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

the class SparkInterpreterTest method getInterpreterContext.

private InterpreterContext getInterpreterContext() {
    output = "";
    InterpreterContext context = InterpreterContext.builder().setInterpreterOut(new InterpreterOutput()).setIntpEventClient(mockRemoteEventClient).setAngularObjectRegistry(new AngularObjectRegistry("spark", null)).build();
    context.out = new InterpreterOutput(new InterpreterOutputListener() {

        @Override
        public void onUpdateAll(InterpreterOutput out) {
        }

        @Override
        public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) {
            try {
                output = out.toInterpreterResultMessage().getData();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onUpdate(int index, InterpreterResultMessageOutput out) {
            messageOutput = out;
        }
    });
    return context;
}
Also used : InterpreterOutputListener(org.apache.zeppelin.interpreter.InterpreterOutputListener) InterpreterResultMessageOutput(org.apache.zeppelin.interpreter.InterpreterResultMessageOutput) InterpreterOutput(org.apache.zeppelin.interpreter.InterpreterOutput) IOException(java.io.IOException) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry)

Example 2 with InterpreterOutputListener

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

the class KotlinInterpreterTest method getInterpreterContext.

private static InterpreterContext getInterpreterContext() {
    output = "";
    InterpreterContext context = InterpreterContext.builder().setInterpreterOut(new InterpreterOutput()).build();
    context.out = new InterpreterOutput(new InterpreterOutputListener() {

        @Override
        public void onUpdateAll(InterpreterOutput out) {
        }

        @Override
        public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) {
            try {
                output = out.toInterpreterResultMessage().getData();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onUpdate(int index, InterpreterResultMessageOutput out) {
        }
    });
    return context;
}
Also used : InterpreterOutputListener(org.apache.zeppelin.interpreter.InterpreterOutputListener) InterpreterResultMessageOutput(org.apache.zeppelin.interpreter.InterpreterResultMessageOutput) InterpreterOutput(org.apache.zeppelin.interpreter.InterpreterOutput) IOException(java.io.IOException) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext)

Example 3 with InterpreterOutputListener

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

the class KotlinSparkInterpreterTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    intpGroup = new InterpreterGroup();
    context = InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").setParagraphTitle("title").setAngularObjectRegistry(new AngularObjectRegistry(intpGroup.getId(), null)).setResourcePool(new LocalResourcePool("id")).setInterpreterOut(new InterpreterOutput()).setIntpEventClient(mock(RemoteInterpreterEventClient.class)).build();
    context.out = new InterpreterOutput(new InterpreterOutputListener() {

        @Override
        public void onUpdateAll(InterpreterOutput out) {
        }

        @Override
        public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) {
            try {
                output = out.toInterpreterResultMessage().getData();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onUpdate(int index, InterpreterResultMessageOutput out) {
        }
    });
    InterpreterContext.set(context);
    intpGroup.put("note", new LinkedList<Interpreter>());
    Properties properties = getSparkTestProperties(tmpDir);
    repl = new SparkInterpreter(properties);
    repl.setInterpreterGroup(intpGroup);
    intpGroup.get("note").add(repl);
    repl.open();
    repl.interpret("sc", context);
    interpreter = new KotlinSparkInterpreter(properties);
    interpreter.setInterpreterGroup(intpGroup);
    intpGroup.get("note").add(interpreter);
    try {
        interpreter.open();
        sparkSupported = true;
    } catch (UnsupportedClassVersionError e) {
        sparkSupported = false;
    }
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) Interpreter(org.apache.zeppelin.interpreter.Interpreter) InterpreterOutputListener(org.apache.zeppelin.interpreter.InterpreterOutputListener) IOException(java.io.IOException) RemoteInterpreterEventClient(org.apache.zeppelin.interpreter.remote.RemoteInterpreterEventClient) Properties(java.util.Properties) InterpreterGroup(org.apache.zeppelin.interpreter.InterpreterGroup) InterpreterResultMessageOutput(org.apache.zeppelin.interpreter.InterpreterResultMessageOutput) InterpreterOutput(org.apache.zeppelin.interpreter.InterpreterOutput) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) BeforeClass(org.junit.BeforeClass)

Aggregations

IOException (java.io.IOException)3 InterpreterOutput (org.apache.zeppelin.interpreter.InterpreterOutput)3 InterpreterOutputListener (org.apache.zeppelin.interpreter.InterpreterOutputListener)3 InterpreterResultMessageOutput (org.apache.zeppelin.interpreter.InterpreterResultMessageOutput)3 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)2 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)2 Properties (java.util.Properties)1 Interpreter (org.apache.zeppelin.interpreter.Interpreter)1 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)1 RemoteInterpreterEventClient (org.apache.zeppelin.interpreter.remote.RemoteInterpreterEventClient)1 LocalResourcePool (org.apache.zeppelin.resource.LocalResourcePool)1 BeforeClass (org.junit.BeforeClass)1