Search in sources :

Example 1 with InterpreterSettingsList

use of org.apache.zeppelin.types.InterpreterSettingsList in project zeppelin by apache.

the class NotebookServer method saveInterpreterBindings.

public void saveInterpreterBindings(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
    List<InterpreterSettingsList> settingList = new ArrayList<>();
    String noteId = (String) fromMessage.data.get("noteId");
    // use write lock, because defaultInterpreterGroup is overwritten
    getNotebook().processNote(noteId, note -> {
        if (note != null) {
            List<String> settingIdList = gson.fromJson(String.valueOf(fromMessage.data.get("selectedSettingIds")), new TypeToken<ArrayList<String>>() {
            }.getType());
            if (!settingIdList.isEmpty()) {
                note.setDefaultInterpreterGroup(settingIdList.get(0));
                getNotebook().saveNote(note, context.getAutheInfo());
            }
            List<InterpreterSetting> bindedSettings = note.getBindedInterpreterSettings(new ArrayList<>(context.getUserAndRoles()));
            for (InterpreterSetting setting : bindedSettings) {
                settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), true));
            }
        }
        return null;
    });
    conn.send(serializeMessage(new Message(OP.INTERPRETER_BINDINGS).put("interpreterBindings", settingList)));
}
Also used : OnMessage(javax.websocket.OnMessage) ClusterMessage(org.apache.zeppelin.cluster.event.ClusterMessage) Message(org.apache.zeppelin.common.Message) InterpreterSettingsList(org.apache.zeppelin.types.InterpreterSettingsList) TypeToken(com.google.gson.reflect.TypeToken) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) ArrayList(java.util.ArrayList)

Example 2 with InterpreterSettingsList

use of org.apache.zeppelin.types.InterpreterSettingsList in project SSM by Intel-bigdata.

the class InterpreterBindingUtils method getInterpreterBindings.

public static List<InterpreterSettingsList> getInterpreterBindings(Notebook notebook, String noteId) {
    List<InterpreterSettingsList> settingList = new LinkedList<>();
    List<InterpreterSetting> selectedSettings = notebook.getBindedInterpreterSettings(noteId);
    for (InterpreterSetting setting : selectedSettings) {
        settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), true));
    }
    List<InterpreterSetting> availableSettings = notebook.getInterpreterSettingManager().get();
    for (InterpreterSetting setting : availableSettings) {
        boolean selected = false;
        for (InterpreterSetting selectedSetting : selectedSettings) {
            if (selectedSetting.getId().equals(setting.getId())) {
                selected = true;
                break;
            }
        }
        if (!selected) {
            settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), false));
        }
    }
    return settingList;
}
Also used : InterpreterSettingsList(org.apache.zeppelin.types.InterpreterSettingsList) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) LinkedList(java.util.LinkedList)

Example 3 with InterpreterSettingsList

use of org.apache.zeppelin.types.InterpreterSettingsList in project zeppelin by apache.

the class InterpreterBindingUtils method getInterpreterBindings.

public static List<InterpreterSettingsList> getInterpreterBindings(Notebook notebook, String noteId) {
    List<InterpreterSettingsList> settingList = new LinkedList<>();
    List<InterpreterSetting> selectedSettings = notebook.getBindedInterpreterSettings(noteId);
    for (InterpreterSetting setting : selectedSettings) {
        settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), true));
    }
    List<InterpreterSetting> availableSettings = notebook.getInterpreterSettingManager().get();
    for (InterpreterSetting setting : availableSettings) {
        boolean selected = false;
        for (InterpreterSetting selectedSetting : selectedSettings) {
            if (selectedSetting.getId().equals(setting.getId())) {
                selected = true;
                break;
            }
        }
        if (!selected) {
            settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), false));
        }
    }
    return settingList;
}
Also used : InterpreterSettingsList(org.apache.zeppelin.types.InterpreterSettingsList) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) LinkedList(java.util.LinkedList)

Example 4 with InterpreterSettingsList

use of org.apache.zeppelin.types.InterpreterSettingsList in project zeppelin by apache.

the class NotebookServer method getInterpreterBindings.

public void getInterpreterBindings(NotebookSocket conn, Message fromMessage) throws IOException {
    String noteId = (String) fromMessage.data.get("noteId");
    List<InterpreterSettingsList> settingList = InterpreterBindingUtils.getInterpreterBindings(notebook(), noteId);
    conn.send(serializeMessage(new Message(OP.INTERPRETER_BINDINGS).put("interpreterBindings", settingList)));
}
Also used : InterpreterResultMessage(org.apache.zeppelin.interpreter.InterpreterResultMessage) Message(org.apache.zeppelin.notebook.socket.Message) WatcherMessage(org.apache.zeppelin.notebook.socket.WatcherMessage) InterpreterSettingsList(org.apache.zeppelin.types.InterpreterSettingsList)

Example 5 with InterpreterSettingsList

use of org.apache.zeppelin.types.InterpreterSettingsList in project zeppelin by apache.

the class NotebookServer method getInterpreterBindings.

public void getInterpreterBindings(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
    List<InterpreterSettingsList> settingList = new ArrayList<>();
    String noteId = (String) fromMessage.data.get("noteId");
    getNotebook().processNote(noteId, note -> {
        if (note != null) {
            List<InterpreterSetting> bindedSettings = note.getBindedInterpreterSettings(new ArrayList<>(context.getUserAndRoles()));
            for (InterpreterSetting setting : bindedSettings) {
                settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), true));
            }
        }
        conn.send(serializeMessage(new Message(OP.INTERPRETER_BINDINGS).put("interpreterBindings", settingList)));
        return null;
    });
}
Also used : OnMessage(javax.websocket.OnMessage) ClusterMessage(org.apache.zeppelin.cluster.event.ClusterMessage) Message(org.apache.zeppelin.common.Message) InterpreterSettingsList(org.apache.zeppelin.types.InterpreterSettingsList) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) ArrayList(java.util.ArrayList)

Aggregations

InterpreterSettingsList (org.apache.zeppelin.types.InterpreterSettingsList)5 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)4 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 OnMessage (javax.websocket.OnMessage)2 ClusterMessage (org.apache.zeppelin.cluster.event.ClusterMessage)2 Message (org.apache.zeppelin.common.Message)2 TypeToken (com.google.gson.reflect.TypeToken)1 InterpreterResultMessage (org.apache.zeppelin.interpreter.InterpreterResultMessage)1 Message (org.apache.zeppelin.notebook.socket.Message)1 WatcherMessage (org.apache.zeppelin.notebook.socket.WatcherMessage)1