HeliumOnlineRegistry extends HeliumRegistry { @Override public synchronized List<HeliumPackage> getAll() throws IOException { HttpClient client = HttpClientBuilder.create() .setUserAgent("ApacheZeppelin/" + Util.getVersion()) .setProxy(getProxy(uri())) .build(); HttpGet get = new HttpGet(uri()); HttpResponse response; try { ZeppelinConfiguration cfg = ZeppelinConfiguration.create(); if ((get.getURI().getHost().equals(cfg.getS3Endpoint()))) { if (cfg.getS3Timeout() != null) { int timeout = Integer.valueOf(cfg.getS3Timeout()); RequestConfig requestCfg = RequestConfig.custom() .setConnectTimeout(timeout) .setSocketTimeout(timeout) .build(); get.setConfig(requestCfg); } } response = client.execute(get); } catch (Exception e) { logger.error(e.getMessage()); return readFromCache(); } if (response.getStatusLine().getStatusCode() != 200) { logger.error(uri() + " returned " + response.getStatusLine().toString()); return readFromCache(); } else { List<HeliumPackage> packageList = new LinkedList<>(); BufferedReader reader; reader = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); List<Map<String, Map<String, HeliumPackage>>> packages = gson.fromJson( reader, new TypeToken<List<Map<String, Map<String, HeliumPackage>>>>() { }.getType()); reader.close(); for (Map<String, Map<String, HeliumPackage>> pkg : packages) { for (Map<String, HeliumPackage> versions : pkg.values()) { packageList.addAll(versions.values()); } } writeToCache(packageList); return packageList; } } HeliumOnlineRegistry(String name, String uri, File registryCacheDir); @Override synchronized List<HeliumPackage> getAll();  }
@Test public void zeppelinNotebookS3TimeoutPropertyTest() throws IOException { System.setProperty( ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_S3_TIMEOUT.getVarName(), TIMEOUT ); System.setProperty( ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_S3_ENDPOINT.getVarName(), IP ); HeliumOnlineRegistry heliumOnlineRegistry = new HeliumOnlineRegistry( "https: "https: tmpDir ); long start = System.currentTimeMillis(); heliumOnlineRegistry.getAll(); long processTime = System.currentTimeMillis() - start; long basicTimeout = Long.valueOf( ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_S3_TIMEOUT.getStringValue() ); assertTrue( String.format( "Wrong timeout during connection: expected %s, actual is about %d", TIMEOUT, processTime ), basicTimeout > processTime ); }