/** * Returns an instance of {@link AlluxioConfiguration} with the defaults and values from * alluxio-site properties. * * @return the set of Alluxio properties loaded from the site-properties file */ public static AlluxioProperties defaults() { if (sDefaultProperties == null) { synchronized (DEFAULT_PROPERTIES_LOCK) { // We don't want multiple threads to reload // properties at the same time. // Check if properties are still null so we don't reload a second time. if (sDefaultProperties == null) { reloadProperties(); } } } return sDefaultProperties.copy(); }
/** * Resets the {@link AlluxioConfiguration} back the defaults and values from * alluxio-site properties. */ public static void reset() { ConfigurationUtils.reloadProperties(); sConf = new InstancedConfiguration(ConfigurationUtils.defaults()); }
@AfterClass public static void after() { ConfigurationUtils.reloadProperties(); }
public void resetConf() { ConfigurationUtils.reloadProperties(); mConfiguration = ConfigurationTestUtils.defaults(); }
@Test public void initializeWithZookeeperSystemProperties() throws Exception { HashMap<String, String> sysProps = new HashMap<>(); sysProps.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), "true"); sysProps.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), "zkHost:2181"); try (Closeable p = new SystemPropertyRule(sysProps).toResource()) { ConfigurationUtils.reloadProperties(); URI uri = URI.create("alluxio:///"); FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); assertTrue(fs.mFsContext.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); assertEquals("zkHost:2181", fs.mFsContext.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); } }
@Test public void initializeWithZookeeperUriAndSystemProperty() throws Exception { // When URI and system property both have Zookeeper configuration, // those in the URI has the highest priority. try (Closeable p = new SystemPropertyRule( PropertyKey.ZOOKEEPER_ENABLED.getName(), "false").toResource()) { ConfigurationUtils.reloadProperties(); URI uri = URI.create("alluxio://zk@zkHost:2181"); FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); assertTrue(fs.mFsContext.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); assertEquals("zkHost:2181", fs.mFsContext.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); fs.close(); } HashMap<String, String> sysProps = new HashMap<>(); sysProps.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), "true"); sysProps.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), "zkHost1:2181"); try (Closeable p = new SystemPropertyRule(sysProps).toResource()) { ConfigurationUtils.reloadProperties(); URI uri = URI.create("alluxio://zk@zkHost2:2181"); FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); assertTrue(fs.mFsContext.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); assertEquals("zkHost2:2181", fs.mFsContext.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); fs.close(); } ConfigurationUtils.reloadProperties(); }