ZeppelinHubRepo implements NotebookRepo { String getZeppelinHubUrl(ZeppelinConfiguration conf) { if (conf == null) { LOG.error("Invalid configuration, cannot be null. Using default address {}", DEFAULT_SERVER); return DEFAULT_SERVER; } URI apiRoot; String zeppelinhubUrl; try { String url = conf.getString("ZEPPELINHUB_API_ADDRESS", ZEPPELIN_CONF_PROP_NAME_SERVER, DEFAULT_SERVER); apiRoot = new URI(url); } catch (URISyntaxException e) { LOG.error("Invalid zeppelinhub url, using default address {}", DEFAULT_SERVER, e); return DEFAULT_SERVER; } String scheme = apiRoot.getScheme(); if (scheme == null) { LOG.info("{} is not a valid zeppelinhub server address. proceed with default address {}", apiRoot, DEFAULT_SERVER); zeppelinhubUrl = DEFAULT_SERVER; } else { zeppelinhubUrl = scheme + ": if (apiRoot.getPort() > 0) { zeppelinhubUrl += ":" + apiRoot.getPort(); } } return zeppelinhubUrl; } ZeppelinHubRepo(ZeppelinConfiguration conf); @Override List<NoteInfo> list(AuthenticationInfo subject); @Override Note get(String noteId, AuthenticationInfo subject); @Override void save(Note note, AuthenticationInfo subject); @Override void remove(String noteId, AuthenticationInfo subject); @Override void close(); @Override Revision checkpoint(String noteId, String checkpointMsg, AuthenticationInfo subject); @Override Note get(String noteId, Revision rev, AuthenticationInfo subject); @Override List<Revision> revisionHistory(String noteId, AuthenticationInfo subject); static final String TOKEN_HEADER; }
@Test public void testGetZeppelinhubUrl() { System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, testAddr); ZeppelinConfiguration config = new ZeppelinConfiguration(); ZeppelinHubRepo repository = new ZeppelinHubRepo(config); assertThat(repository.getZeppelinHubUrl(config)).isEqualTo("http: System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "yolow"); config = new ZeppelinConfiguration(); repository = new ZeppelinHubRepo(config); assertThat(repository.getZeppelinHubUrl(config)).isEqualTo("https: System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "http: config = new ZeppelinConfiguration(); repository = new ZeppelinHubRepo(config); assertThat(repository.getZeppelinHubUrl(config)).isEqualTo("http: System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, "http: config = new ZeppelinConfiguration(); repository = new ZeppelinHubRepo(config); assertThat(repository.getZeppelinHubUrl(config)).isEqualTo("http: }