Search in sources :

Example 1 with NotebookRepoSettingsInfo

use of org.apache.zeppelin.notebook.repo.NotebookRepoSettingsInfo in project zeppelin by apache.

the class ZeppelinHubRepo method getSettings.

@Override
public List<NotebookRepoSettingsInfo> getSettings(AuthenticationInfo subject) {
    if (!isSubjectValid(subject)) {
        return Collections.emptyList();
    }
    List<NotebookRepoSettingsInfo> settings = Lists.newArrayList();
    String user = subject.getUser();
    String zeppelinHubUserSession = UserSessionContainer.instance.getSession(user);
    String userToken = getUserToken(user);
    List<Instance> instances;
    List<Map<String, String>> values = Lists.newLinkedList();
    try {
        instances = getUserInstances(zeppelinHubUserSession);
    } catch (IOException e) {
        LOG.warn("Couldnt find instances for the session {}, returning empty collection", zeppelinHubUserSession);
        // user not logged
        //TODO(xxx): handle this case.
        instances = Collections.emptyList();
    }
    NotebookRepoSettingsInfo repoSetting = NotebookRepoSettingsInfo.newInstance();
    repoSetting.type = NotebookRepoSettingsInfo.Type.DROPDOWN;
    for (Instance instance : instances) {
        if (instance.token.equals(userToken)) {
            repoSetting.selected = Integer.toString(instance.id);
        }
        values.add(ImmutableMap.of("name", instance.name, "value", Integer.toString(instance.id)));
    }
    repoSetting.value = values;
    repoSetting.name = "Instance";
    settings.add(repoSetting);
    return settings;
}
Also used : Instance(org.apache.zeppelin.notebook.repo.zeppelinhub.model.Instance) IOException(java.io.IOException) NotebookRepoSettingsInfo(org.apache.zeppelin.notebook.repo.NotebookRepoSettingsInfo) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 2 with NotebookRepoSettingsInfo

use of org.apache.zeppelin.notebook.repo.NotebookRepoSettingsInfo in project SSM by Intel-bigdata.

the class ZeppelinHubRepo method getSettings.

@Override
public List<NotebookRepoSettingsInfo> getSettings(AuthenticationInfo subject) {
    if (!isSubjectValid(subject)) {
        return Collections.emptyList();
    }
    List<NotebookRepoSettingsInfo> settings = Lists.newArrayList();
    String user = subject.getUser();
    String zeppelinHubUserSession = UserSessionContainer.instance.getSession(user);
    String userToken = getUserToken(user);
    List<Instance> instances;
    List<Map<String, String>> values = Lists.newLinkedList();
    try {
        instances = tokenManager.getUserInstances(zeppelinHubUserSession);
    } catch (IOException e) {
        LOG.warn("Couldnt find instances for the session {}, returning empty collection", zeppelinHubUserSession);
        // user not logged
        // TODO(xxx): handle this case.
        instances = Collections.emptyList();
    }
    NotebookRepoSettingsInfo repoSetting = NotebookRepoSettingsInfo.newInstance();
    repoSetting.type = NotebookRepoSettingsInfo.Type.DROPDOWN;
    for (Instance instance : instances) {
        if (instance.token.equals(userToken)) {
            repoSetting.selected = Integer.toString(instance.id);
        }
        values.add(ImmutableMap.of("name", instance.name, "value", Integer.toString(instance.id)));
    }
    repoSetting.value = values;
    repoSetting.name = "Instance";
    settings.add(repoSetting);
    return settings;
}
Also used : Instance(org.apache.zeppelin.notebook.repo.zeppelinhub.model.Instance) IOException(java.io.IOException) NotebookRepoSettingsInfo(org.apache.zeppelin.notebook.repo.NotebookRepoSettingsInfo) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)2 IOException (java.io.IOException)2 Map (java.util.Map)2 NotebookRepoSettingsInfo (org.apache.zeppelin.notebook.repo.NotebookRepoSettingsInfo)2 Instance (org.apache.zeppelin.notebook.repo.zeppelinhub.model.Instance)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1