Search in sources :

Example 1 with JupyterContentsManager

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

the class JupyterConfigFilesGenerator method createJupyterNotebookConfig.

public void createJupyterNotebookConfig(Writer out, Project project, int port, JupyterSettings js, String hdfsUser, String certsDir, String allowOrigin) throws IOException, ServiceException, ServiceDiscoveryException {
    Service namenode = serviceDiscoveryController.getAnyAddressOfServiceWithDNS(ServiceDiscoveryController.HopsworksService.RPC_NAMENODE);
    String hopsworksRestEndpoint = "https://" + serviceDiscoveryController.constructServiceFQDNWithPort(ServiceDiscoveryController.HopsworksService.HOPSWORKS_APP);
    JupyterContentsManager jcm = JupyterContentsManager.HDFS_CONTENTS_MANAGER;
    JupyterNotebookConfigTemplate template = JupyterNotebookConfigTemplateBuilder.newBuilder().setProject(project).setNamenodeIp(namenode.getAddress()).setNamenodePort(String.valueOf(namenode.getPort())).setContentsManager(jcm.getClassName()).setHopsworksEndpoint(hopsworksRestEndpoint).setElasticEndpoint(settings.getOpenSearchEndpoint()).setPort(port).setBaseDirectory(js.getBaseDir()).setHdfsUser(hdfsUser).setWhiteListedKernels("'" + pythonKernelName(project.getPythonEnvironment().getPythonVersion()) + "', 'pysparkkernel', 'sparkkernel', 'sparkrkernel'").setHadoopHome(settings.getHadoopSymbolicLinkDir()).setJupyterCertsDirectory(certsDir).setSecretDirectory(settings.getStagingDir() + Settings.PRIVATE_DIRS + js.getSecret()).setAllowOrigin(allowOrigin).setWsPingInterval(settings.getJupyterWSPingInterval()).setHadoopClasspathGlob(settings.getHadoopClasspathGlob().trim()).setRequestsVerify(settings.getRequestsVerify()).setDomainCATruststore(Paths.get(certsDir, hdfsUser + Settings.TRUSTSTORE_SUFFIX).toString()).setServiceDiscoveryDomain(settings.getServiceDiscoveryDomain()).setKafkaBrokers(kafkaBrokers.getKafkaBrokersString()).setHopsworksPublicHost(settings.getHopsworksPublicHost()).build();
    Map<String, Object> dataModel = new HashMap<>(1);
    dataModel.put("conf", template);
    try {
        templateEngine.template(JupyterNotebookConfigTemplate.TEMPLATE_NAME, dataModel, out);
    } catch (TemplateException ex) {
        throw new IOException(ex);
    }
}
Also used : JupyterNotebookConfigTemplate(io.hops.hopsworks.common.util.templates.jupyter.JupyterNotebookConfigTemplate) HashMap(java.util.HashMap) TemplateException(freemarker.template.TemplateException) JupyterContentsManager(io.hops.hopsworks.common.jupyter.JupyterContentsManager) Service(com.logicalclocks.servicediscoverclient.service.Service) IOException(java.io.IOException)

Aggregations

Service (com.logicalclocks.servicediscoverclient.service.Service)1 TemplateException (freemarker.template.TemplateException)1 JupyterContentsManager (io.hops.hopsworks.common.jupyter.JupyterContentsManager)1 JupyterNotebookConfigTemplate (io.hops.hopsworks.common.util.templates.jupyter.JupyterNotebookConfigTemplate)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1