Search in sources :

Example 6 with Message

use of org.apache.zeppelin.common.Message in project zeppelin by apache.

the class NotebookServer method getEditorSetting.

private void getEditorSetting(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
    String paragraphId = (String) fromMessage.get("paragraphId");
    String paragraphText = (String) fromMessage.get("paragraphText");
    String noteId = connectionManager.getAssociatedNoteId(conn);
    getNotebookService().getEditorSetting(noteId, paragraphText, context, new WebSocketServiceCallback<Map<String, Object>>(conn) {

        @Override
        public void onSuccess(Map<String, Object> settings, ServiceContext context) throws IOException {
            super.onSuccess(settings, context);
            Message resp = new Message(OP.EDITOR_SETTING);
            resp.put("paragraphId", paragraphId);
            resp.put("editor", settings);
            conn.send(serializeMessage(resp));
        }

        @Override
        public void onFailure(Exception ex, ServiceContext context) {
            LOG.warn(ex.getMessage());
        }
    });
}
Also used : OnMessage(javax.websocket.OnMessage) ClusterMessage(org.apache.zeppelin.cluster.event.ClusterMessage) Message(org.apache.zeppelin.common.Message) ServiceContext(org.apache.zeppelin.service.ServiceContext) ManagedObject(org.eclipse.jetty.util.annotation.ManagedObject) AngularObject(org.apache.zeppelin.display.AngularObject) IOException(java.io.IOException) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) URISyntaxException(java.net.URISyntaxException) ForbiddenException(org.apache.zeppelin.rest.exception.ForbiddenException) TException(org.apache.thrift.TException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ServiceException(org.apache.zeppelin.interpreter.thrift.ServiceException)

Example 7 with Message

use of org.apache.zeppelin.common.Message in project zeppelin by apache.

the class NotebookServer method onStatusChange.

@Override
public void onStatusChange(String noteId, String paragraphId, String appId, String status) {
    Message msg = new Message(OP.APP_STATUS_CHANGE).put("noteId", noteId).put("paragraphId", paragraphId).put("appId", appId).put("status", status);
    connectionManager.broadcast(noteId, msg);
}
Also used : OnMessage(javax.websocket.OnMessage) ClusterMessage(org.apache.zeppelin.cluster.event.ClusterMessage) Message(org.apache.zeppelin.common.Message)

Example 8 with Message

use of org.apache.zeppelin.common.Message in project zeppelin by apache.

the class NotebookServer method sendAllAngularObjects.

private void sendAllAngularObjects(Note note, String user, NotebookSocket conn) throws IOException {
    List<InterpreterSetting> settings = getNotebook().getBindedInterpreterSettings(note.getId());
    if (settings == null || settings.isEmpty()) {
        return;
    }
    for (InterpreterSetting intpSetting : settings) {
        if (intpSetting.getInterpreterGroup(user, note.getId()) == null) {
            continue;
        }
        AngularObjectRegistry registry = intpSetting.getInterpreterGroup(user, note.getId()).getAngularObjectRegistry();
        List<AngularObject> objects = registry.getAllWithGlobal(note.getId());
        for (AngularObject object : objects) {
            conn.send(serializeMessage(new Message(OP.ANGULAR_OBJECT_UPDATE).put("angularObject", object).put("interpreterGroupId", intpSetting.getInterpreterGroup(user, note.getId()).getId()).put("noteId", note.getId()).put("paragraphId", object.getParagraphId())));
        }
    }
}
Also used : OnMessage(javax.websocket.OnMessage) ClusterMessage(org.apache.zeppelin.cluster.event.ClusterMessage) Message(org.apache.zeppelin.common.Message) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) AngularObject(org.apache.zeppelin.display.AngularObject) RemoteAngularObjectRegistry(org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry)

Example 9 with Message

use of org.apache.zeppelin.common.Message in project zeppelin by apache.

the class NotebookServer method permissionError.

void permissionError(NotebookSocket conn, String op, String userName, Set<String> userAndRoles, Set<String> allowed) throws IOException {
    LOG.info("Cannot {}. Connection readers {}. Allowed readers {}", op, userAndRoles, allowed);
    conn.send(serializeMessage(new Message(OP.AUTH_INFO).put("info", "Insufficient privileges to " + op + " note.\n\n" + "Allowed users or roles: " + allowed.toString() + "\n\n" + "But the user " + userName + " belongs to: " + userAndRoles.toString())));
}
Also used : OnMessage(javax.websocket.OnMessage) ClusterMessage(org.apache.zeppelin.cluster.event.ClusterMessage) Message(org.apache.zeppelin.common.Message)

Example 10 with Message

use of org.apache.zeppelin.common.Message in project zeppelin by apache.

the class NotebookServer method getNoteByRevisionForCompare.

private void getNoteByRevisionForCompare(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
    String noteId = (String) fromMessage.get("noteId");
    String revisionId = (String) fromMessage.get("revisionId");
    String position = (String) fromMessage.get("position");
    getNotebookService().getNoteByRevisionForCompare(noteId, revisionId, context, new WebSocketServiceCallback<Note>(conn) {

        @Override
        public void onSuccess(Note note, ServiceContext context) throws IOException {
            super.onSuccess(note, context);
            conn.send(serializeMessage(new Message(OP.NOTE_REVISION_FOR_COMPARE).put("noteId", noteId).put("revisionId", revisionId).put("position", position).put("note", note)));
        }
    });
}
Also used : OnMessage(javax.websocket.OnMessage) ClusterMessage(org.apache.zeppelin.cluster.event.ClusterMessage) Message(org.apache.zeppelin.common.Message) ServiceContext(org.apache.zeppelin.service.ServiceContext) Note(org.apache.zeppelin.notebook.Note) IOException(java.io.IOException)

Aggregations

Message (org.apache.zeppelin.common.Message)49 OnMessage (javax.websocket.OnMessage)31 ClusterMessage (org.apache.zeppelin.cluster.event.ClusterMessage)31 IOException (java.io.IOException)18 ServiceContext (org.apache.zeppelin.service.ServiceContext)18 Paragraph (org.apache.zeppelin.notebook.Paragraph)12 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)11 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 AngularObject (org.apache.zeppelin.display.AngularObject)10 Test (org.junit.Test)10 Mockito.anyString (org.mockito.Mockito.anyString)10 UnknownHostException (java.net.UnknownHostException)8 TException (org.apache.thrift.TException)8 ServiceException (org.apache.zeppelin.interpreter.thrift.ServiceException)8 Note (org.apache.zeppelin.notebook.Note)8 RemoteAngularObjectRegistry (org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry)7 HashMap (java.util.HashMap)6 List (java.util.List)6 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)6