@Test(timeout=120000) public void testOsSecureRandomSetConf() throws IOException { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); OsSecureRandom random = new OsSecureRandom(); for(int n = 0; n < 10; ++n) { random.setConf(new Configuration()); String[] scmd = new String[] {"/bin/sh", "-c", "lsof | wc -l"}; ShellCommandExecutor sce = new ShellCommandExecutor(scmd); sce.execute(); System.out.println("==lsof result " + n + ":"); System.out.println(sce.getOutput()); } }
@Override synchronized public void setConf(Configuration conf) { this.conf = conf; this.randomDevPath = conf.get( HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_KEY, HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_DEFAULT); File randomDevFile = new File(randomDevPath); try { close(); this.stream = new FileInputStream(randomDevFile); } catch (IOException e) { throw new RuntimeException(e); } try { fillReservoir(0); } catch (RuntimeException e) { close(); throw e; } }
OsSecureRandom extends Random implements Closeable, Configurable { @Override synchronized public void setConf(Configuration conf) { this.conf = conf; this.randomDevPath = conf.get( HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_KEY, HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_DEFAULT); File randomDevFile = new File(randomDevPath); try { close(); this.stream = new FileInputStream(randomDevFile); } catch (IOException e) { throw new RuntimeException(e); } try { fillReservoir(0); } catch (RuntimeException e) { close(); throw e; } } }
OsSecureRandom extends Random implements Closeable, Configurable { @Override synchronized public void setConf(Configuration conf) { this.conf = conf; this.randomDevPath = conf.get( HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_KEY, HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_DEFAULT); File randomDevFile = new File(randomDevPath); try { close(); this.stream = new FileInputStream(randomDevFile); } catch (IOException e) { throw new RuntimeException(e); } try { fillReservoir(0); } catch (RuntimeException e) { close(); throw e; } } OsSecureRandom(); }
OsSecureRandom extends Random implements Closeable, Configurable { @Override synchronized public void setConf(Configuration conf) { this.conf = conf; this.randomDevPath = conf.get( HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_KEY, HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_DEFAULT); File randomDevFile = new File(randomDevPath); try { close(); this.stream = new FileInputStream(randomDevFile); } catch (IOException e) { throw new RuntimeException(e); } try { fillReservoir(0); } catch (RuntimeException e) { close(); throw e; } } OsSecureRandom(); @Override synchronized void setConf(Configuration conf); @Override synchronized Configuration getConf(); @Override synchronized void nextBytes(byte[] bytes); @Override synchronized void close(); }
OsSecureRandom extends Random implements Closeable, Configurable { @Override synchronized public void setConf(Configuration conf) { this.conf = conf; this.randomDevPath = conf.get( HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_KEY, HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_DEFAULT); File randomDevFile = new File(randomDevPath); try { close(); this.stream = new FileInputStream(randomDevFile); } catch (IOException e) { throw new RuntimeException(e); } try { fillReservoir(0); } catch (RuntimeException e) { close(); throw e; } } OsSecureRandom(); @Override synchronized void setConf(Configuration conf); @Override synchronized Configuration getConf(); @Override synchronized void nextBytes(byte[] bytes); @Override synchronized void close(); static final Log LOG; }