Search in sources :

Example 1 with NotebookDTO

use of io.hops.hopsworks.common.jupyter.NotebookDTO in project hopsworks by logicalclocks.

the class NotebookBuilder method buildNotebook.

private void buildNotebook(SearchHit hit, NotebookDTO notebooks) {
    NotebookDTO item = new NotebookDTO();
    Map xattrMap = (Map) hit.getSourceAsMap().get("xattr");
    Long inodeId = Long.parseLong(hit.getId());
    Inode inode = inodeFacade.findById(inodeId);
    if (inode != null) {
        item.setPath(inodeController.getPath(inode));
    }
    Map jupyterConfigMap = (Map) xattrMap.get(Settings.META_NOTEBOOK_JUPYTER_CONFIG_XATTR_NAME);
    if (jupyterConfigMap != null && !jupyterConfigMap.isEmpty()) {
        try {
            String jupyterSettingsStr = jupyterConfigMap.get(Settings.META_NOTEBOOK_JUPYTER_CONFIG_XATTR_NAME).toString();
            item.setJupyterSettings(objectMapper.readValue(jupyterSettingsStr, JupyterSettings.class));
        } catch (IOException e) {
            LOGGER.log(Level.SEVERE, "Could not parse JupyterSettings for notebook at path: " + item.getPath(), e);
        }
        item.setDate(new Date(Long.parseLong(jupyterConfigMap.get(Settings.META_USAGE_TIME).toString())));
    }
    notebooks.addItem(item);
}
Also used : Inode(io.hops.hopsworks.persistence.entity.hdfs.inode.Inode) JupyterSettings(io.hops.hopsworks.persistence.entity.jupyter.JupyterSettings) IOException(java.io.IOException) NotebookDTO(io.hops.hopsworks.common.jupyter.NotebookDTO) Map(java.util.Map) Date(java.util.Date)

Example 2 with NotebookDTO

use of io.hops.hopsworks.common.jupyter.NotebookDTO in project hopsworks by logicalclocks.

the class NotebookBuilder method build.

public NotebookDTO build(UriInfo uriInfo, Project project, int count) throws ElasticException {
    NotebookDTO dto = new NotebookDTO();
    dto.setHref(uri(uriInfo, project, count));
    SearchHit[] elasticHits = elasticController.recentJupyterNotebookSearch(count, project.getId());
    for (SearchHit hit : elasticHits) {
        buildNotebook(hit, dto);
    }
    return dto;
}
Also used : SearchHit(org.elasticsearch.search.SearchHit) NotebookDTO(io.hops.hopsworks.common.jupyter.NotebookDTO)

Aggregations

NotebookDTO (io.hops.hopsworks.common.jupyter.NotebookDTO)2 Inode (io.hops.hopsworks.persistence.entity.hdfs.inode.Inode)1 JupyterSettings (io.hops.hopsworks.persistence.entity.jupyter.JupyterSettings)1 IOException (java.io.IOException)1 Date (java.util.Date)1 Map (java.util.Map)1 SearchHit (org.elasticsearch.search.SearchHit)1