Search in sources :

Example 1 with RemoteInterpreterEvent

use of org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent in project zeppelin by apache.

the class RemoteInterpreterEventClient method onAppOutputAppend.

public void onAppOutputAppend(String noteId, String paragraphId, int index, String appId, String output) {
    Map<String, Object> appendOutput = new HashMap<>();
    appendOutput.put("noteId", noteId);
    appendOutput.put("paragraphId", paragraphId);
    appendOutput.put("index", Integer.toString(index));
    appendOutput.put("appId", appId);
    appendOutput.put("data", output);
    sendEvent(new RemoteInterpreterEvent(RemoteInterpreterEventType.OUTPUT_APPEND, gson.toJson(appendOutput)));
}
Also used : HashMap(java.util.HashMap) RemoteInterpreterEvent(org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent) AngularObject(org.apache.zeppelin.display.AngularObject)

Example 2 with RemoteInterpreterEvent

use of org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent in project zeppelin by apache.

the class RemoteInterpreterEventClient method angularObjectRemove.

/**
   * notify angularObject removal
   */
public void angularObjectRemove(String name, String noteId, String paragraphId) {
    Map<String, String> removeObject = new HashMap<>();
    removeObject.put("name", name);
    removeObject.put("noteId", noteId);
    removeObject.put("paragraphId", paragraphId);
    sendEvent(new RemoteInterpreterEvent(RemoteInterpreterEventType.ANGULAR_OBJECT_REMOVE, gson.toJson(removeObject)));
}
Also used : HashMap(java.util.HashMap) RemoteInterpreterEvent(org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent)

Example 3 with RemoteInterpreterEvent

use of org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent in project zeppelin by apache.

the class RemoteInterpreterEventClient method getZeppelinServerNoteRunner.

/**
   * Run paragraph
   * @param runner
   */
public void getZeppelinServerNoteRunner(String eventOwnerKey, ZeppelinServerResourceParagraphRunner runner) {
    RemoteZeppelinServerResource eventBody = new RemoteZeppelinServerResource();
    eventBody.setResourceType(RemoteZeppelinServerResource.Type.PARAGRAPH_RUNNERS);
    eventBody.setOwnerKey(eventOwnerKey);
    eventBody.setData(runner);
    sendEvent(new RemoteInterpreterEvent(RemoteInterpreterEventType.REMOTE_ZEPPELIN_SERVER_RESOURCE, gson.toJson(eventBody)));
}
Also used : RemoteInterpreterEvent(org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent) RemoteZeppelinServerResource(org.apache.zeppelin.interpreter.RemoteZeppelinServerResource)

Example 4 with RemoteInterpreterEvent

use of org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent in project zeppelin by apache.

the class RemoteInterpreterEventClient method pollEvent.

/**
   * Supposed to call from RemoteInterpreterEventPoller
   * @return next available event
   */
public RemoteInterpreterEvent pollEvent() {
    synchronized (eventQueue) {
        if (eventQueue.isEmpty()) {
            try {
                eventQueue.wait(1000);
            } catch (InterruptedException e) {
            }
        }
        if (eventQueue.isEmpty()) {
            return new RemoteInterpreterEvent(RemoteInterpreterEventType.NO_OP, "");
        } else {
            RemoteInterpreterEvent event = eventQueue.remove(0);
            logger.debug("Send event {}", event.getType());
            return event;
        }
    }
}
Also used : RemoteInterpreterEvent(org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent)

Example 5 with RemoteInterpreterEvent

use of org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent in project zeppelin by apache.

the class RemoteInterpreterEventClient method onAppOutputUpdate.

public void onAppOutputUpdate(String noteId, String paragraphId, int index, String appId, InterpreterResult.Type type, String output) {
    Map<String, Object> appendOutput = new HashMap<>();
    appendOutput.put("noteId", noteId);
    appendOutput.put("paragraphId", paragraphId);
    appendOutput.put("index", Integer.toString(index));
    appendOutput.put("appId", appId);
    appendOutput.put("type", type);
    appendOutput.put("data", output);
    logger.info("onAppoutputUpdate = {}", output);
    sendEvent(new RemoteInterpreterEvent(RemoteInterpreterEventType.OUTPUT_UPDATE, gson.toJson(appendOutput)));
}
Also used : HashMap(java.util.HashMap) RemoteInterpreterEvent(org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent) AngularObject(org.apache.zeppelin.display.AngularObject)

Aggregations

RemoteInterpreterEvent (org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEvent)12 HashMap (java.util.HashMap)7 AngularObject (org.apache.zeppelin.display.AngularObject)6 Gson (com.google.gson.Gson)2 RemoteZeppelinServerResource (org.apache.zeppelin.interpreter.RemoteZeppelinServerResource)2 TypeToken (com.google.gson.reflect.TypeToken)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 TException (org.apache.thrift.TException)1 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)1 InterpreterContextRunner (org.apache.zeppelin.interpreter.InterpreterContextRunner)1 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)1 RemoteInterpreterEventType (org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEventType)1 Client (org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService.Client)1 ResourceId (org.apache.zeppelin.resource.ResourceId)1 ResourceSet (org.apache.zeppelin.resource.ResourceSet)1