use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class Format method main.
/**
* Formats the Alluxio file system.
*
* @param args either {@code MASTER} or {@code WORKER}
*/
public static void main(String[] args) {
if (args.length != 1) {
LOG.info(USAGE);
System.exit(-1);
}
AlluxioConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
// Set the process type as "MASTER" since format needs to access the journal like the master.
CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.MASTER);
Mode mode = null;
try {
mode = Mode.valueOf(args[0].toUpperCase());
} catch (IllegalArgumentException e) {
LOG.error("Unrecognized format mode: {}", args[0]);
LOG.error("Usage: {}", USAGE);
System.exit(-1);
}
try {
format(mode, conf);
} catch (Exception e) {
LOG.error("Failed to format", e);
System.exit(-1);
}
LOG.info("Formatting complete");
System.exit(0);
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class ConfigurationUtils method merge.
/**
* Merges the current configuration properties with new properties. If a property exists
* both in the new and current configuration, the one from the new configuration wins if
* its priority is higher or equal than the existing one.
*
* @param conf the base configuration
* @param properties the source {@link Properties} to be merged
* @param source the source of the the properties (e.g., system property, default and etc)
* @return a new configuration representing the merged properties
*/
public static AlluxioConfiguration merge(AlluxioConfiguration conf, Map<?, ?> properties, Source source) {
AlluxioProperties props = conf.copyProperties();
props.merge(properties, source);
return new InstancedConfiguration(props);
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class ConfigurationUtils method getPathConf.
/**
* Loads the path level configuration from the get configuration response.
*
* Only client scope properties will be loaded.
*
* @param response the get configuration RPC response
* @param clusterConf cluster level configuration
* @return the loaded path level configuration
*/
public static PathConfiguration getPathConf(GetConfigurationPResponse response, AlluxioConfiguration clusterConf) {
String clientVersion = clusterConf.getString(PropertyKey.VERSION);
LOG.debug("Alluxio client (version {}) is trying to load path level configurations", clientVersion);
Map<String, AlluxioConfiguration> pathConfs = new HashMap<>();
response.getPathConfigsMap().forEach((path, conf) -> {
Properties props = filterAndLoadProperties(conf.getPropertiesList(), Scope.CLIENT, (key, value) -> String.format("Loading property: %s (%s) -> %s for path %s", key, key.getScope(), value, path));
AlluxioProperties properties = new AlluxioProperties();
properties.merge(props, Source.PATH_DEFAULT);
pathConfs.put(path, new InstancedConfiguration(properties, true));
});
LOG.debug("Alluxio client has loaded path level configurations");
return PathConfiguration.create(pathConfs);
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class ConfigurationUtils method reloadProperties.
/**
* Reloads site properties from disk.
*/
public static void reloadProperties() {
synchronized (DEFAULT_PROPERTIES_LOCK) {
// Step1: bootstrap the configuration. This is necessary because we need to resolve alluxio
// .home (likely to be in system properties) to locate the conf dir to search for the site
// property file.
AlluxioProperties properties = new AlluxioProperties();
InstancedConfiguration conf = new InstancedConfiguration(properties);
// Can't directly pass System.getProperties() because it is not thread-safe
// This can cause a ConcurrentModificationException when merging.
Properties sysProps = new Properties();
System.getProperties().stringPropertyNames().forEach(key -> sysProps.setProperty(key, System.getProperty(key)));
properties.merge(sysProps, Source.SYSTEM_PROPERTY);
// whether in test mode by default properties and system properties (via getBoolean).
if (conf.getBoolean(PropertyKey.TEST_MODE)) {
conf.validate();
sDefaultProperties = properties;
return;
}
// we are not in test mode, load site properties
String confPaths = conf.getString(PropertyKey.SITE_CONF_DIR);
String[] confPathList = confPaths.split(",");
String sitePropertyFile = ConfigurationUtils.searchPropertiesFile(Constants.SITE_PROPERTIES, confPathList);
Properties siteProps = null;
if (sitePropertyFile != null) {
siteProps = loadPropertiesFromFile(sitePropertyFile);
sSourcePropertyFile = sitePropertyFile;
} else {
URL resource = ConfigurationUtils.class.getClassLoader().getResource(Constants.SITE_PROPERTIES);
if (resource != null) {
siteProps = loadPropertiesFromResource(resource);
if (siteProps != null) {
sSourcePropertyFile = resource.getPath();
}
}
}
properties.merge(siteProps, Source.siteProperty(sSourcePropertyFile));
conf.validate();
sDefaultProperties = properties;
}
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class AuthenticatedClientUserResourceTest method userRestored.
@Test
public void userRestored() throws Exception {
InstancedConfiguration conf = ConfigurationTestUtils.defaults();
AuthenticatedClientUser.set(ORIGINAL_USER);
User original = AuthenticatedClientUser.get(conf);
new AuthenticatedClientUserResource(TESTCASE_USER, conf).close();
assertSame(original, AuthenticatedClientUser.get(conf));
}
Aggregations