Search in sources :

Example 1 with ZeppelinWebsocket

use of org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.listener.ZeppelinWebsocket in project zeppelin by apache.

the class ZeppelinClient method openNoteSession.

private Session openNoteSession(String noteId) {
    ClientUpgradeRequest request = new ClientUpgradeRequest();
    ZeppelinWebsocket socket = new ZeppelinWebsocket(noteId);
    Future<Session> future = null;
    Session session = null;
    try {
        future = wsClient.connect(socket, zeppelinWebsocketUrl, request);
        session = future.get();
    } catch (IOException | InterruptedException | ExecutionException e) {
        LOG.error("Couldn't establish websocket connection to Zeppelin ", e);
        return session;
    }
    if (notesConnection.containsKey(noteId)) {
        session.close();
        session = notesConnection.get(noteId);
    } else {
        String getNote = serialize(zeppelinGetNoteMsg(noteId));
        session.getRemote().sendStringByFuture(getNote);
        notesConnection.put(noteId, session);
    }
    return session;
}
Also used : ClientUpgradeRequest(org.eclipse.jetty.websocket.client.ClientUpgradeRequest) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ZeppelinWebsocket(org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.listener.ZeppelinWebsocket) Session(org.eclipse.jetty.websocket.api.Session)

Aggregations

IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ZeppelinWebsocket (org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.listener.ZeppelinWebsocket)1 Session (org.eclipse.jetty.websocket.api.Session)1 ClientUpgradeRequest (org.eclipse.jetty.websocket.client.ClientUpgradeRequest)1