use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class MetricsHeartbeatContextTest method testExecutorInitialized.
@Test
public void testExecutorInitialized() {
InstancedConfiguration conf = ConfigurationTestUtils.defaults();
conf.set(PropertyKey.MASTER_HOSTNAME, "localhost");
conf.set(PropertyKey.USER_RPC_RETRY_MAX_DURATION, "1s");
ClientContext ctx = ClientContext.create(conf);
MasterInquireClient client = MasterInquireClient.Factory.create(ctx.getClusterConf(), ctx.getUserState());
// Add and delete a single context, make sure it is non null after adding, and then null after
// removing
MetricsHeartbeatContext.addHeartbeat(ctx, client);
assertNotNull(getInternalExecutor());
MetricsHeartbeatContext.removeHeartbeat(ctx);
assertNull(getInternalExecutor());
// Add a few, then remove and check for the state in between
MetricsHeartbeatContext.addHeartbeat(ctx, client);
MetricsHeartbeatContext.addHeartbeat(ctx, client);
MetricsHeartbeatContext.addHeartbeat(ctx, client);
MetricsHeartbeatContext.addHeartbeat(ctx, client);
assertNotNull(getInternalExecutor());
MetricsHeartbeatContext.removeHeartbeat(ctx);
assertNotNull(getInternalExecutor());
MetricsHeartbeatContext.removeHeartbeat(ctx);
assertNotNull(getInternalExecutor());
MetricsHeartbeatContext.removeHeartbeat(ctx);
assertNotNull(getInternalExecutor());
MetricsHeartbeatContext.removeHeartbeat(ctx);
assertNull(getInternalExecutor());
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class GroupMappingServiceTest method group.
/**
* Tests the {@link GroupMappingService#getGroups(String)} method.
*/
@Test
public void group() throws Throwable {
String userName = "alluxio-user1";
InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
try (Closeable mConfigurationRule = new ConfigurationRule(PropertyKey.SECURITY_GROUP_MAPPING_CLASS, IdentityUserGroupsMapping.class.getName(), conf).toResource()) {
GroupMappingService groups = GroupMappingService.Factory.get(conf);
assertNotNull(groups);
assertNotNull(groups.getGroups(userName));
assertEquals(groups.getGroups(userName).size(), 1);
assertEquals(groups.getGroups(userName).get(0), userName);
}
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class ValidateHdfsMount method main.
/**
* The entrance.
*
* @param args command line arguments
*/
public static void main(String[] args) throws Exception {
CommandLineParser parser = new DefaultParser();
CommandLine cmd = null;
try {
cmd = parser.parse(OPTIONS, args, true);
} catch (ParseException e) {
printHelp(String.format("Failed to parse arguments %s%n", Arrays.toString(args)));
System.exit(1);
}
if (cmd.hasOption(HELP_OPTION.getLongOpt())) {
printHelp("Showing usage for the command");
System.exit(0);
}
args = cmd.getArgs();
if (args.length < 1) {
printHelp("Need at least 1 argument for <hdfsURI>!");
System.exit(1);
}
String ufsPath = args[0];
InstancedConfiguration conf = InstancedConfiguration.defaults();
// Merge options from the command line option
UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(conf);
if (cmd.hasOption(READONLY_OPTION.getLongOpt())) {
ufsConf.setReadOnly(true);
}
if (cmd.hasOption(SHARED_OPTION.getLongOpt())) {
ufsConf.setShared(true);
}
if (cmd.hasOption(OPTION_OPTION.getLongOpt())) {
Properties properties = cmd.getOptionProperties(OPTION_OPTION.getLongOpt());
ufsConf.merge(properties, Source.MOUNT_OPTION);
LOG.debug("Options from cmdline: {}", properties);
}
ValidationToolRegistry registry = new ValidationToolRegistry(new InstancedConfiguration(ConfigurationUtils.defaults()));
// Load hdfs validation tool from alluxio lib directory
registry.refresh();
Map<Object, Object> configMap = new HashMap<>();
configMap.put(ValidationConfig.UFS_PATH, ufsPath);
configMap.put(ValidationConfig.UFS_CONFIG, ufsConf);
ValidationTool tests = registry.create(ValidationConfig.HDFS_TOOL_TYPE, configMap);
String result = ValidationTool.toJson(ValidationTool.convertResults(tests.runAllTests()));
System.out.println(result);
System.exit(0);
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class ValidateConf method main.
/**
* Console program that validates the configuration.
*
* @param args there are no arguments needed
*/
public static void main(String[] args) {
LOG.info("Validating configuration.");
try {
new InstancedConfiguration(ConfigurationUtils.defaults()).validate();
LOG.info("Configuration is valid.");
} catch (IllegalStateException e) {
LOG.error("Configuration is invalid", e);
System.exit(-1);
}
System.exit(0);
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class ConfigurationDocGenerator method generate.
/**
* Generates the configuration docs.
*/
public static void generate() throws IOException {
Collection<? extends PropertyKey> defaultKeys = PropertyKey.defaultKeys();
defaultKeys.removeIf(key -> key.isHidden());
String homeDir = new InstancedConfiguration(ConfigurationUtils.defaults()).getString(PropertyKey.HOME);
// generate CSV files
String filePath = PathUtils.concatPath(homeDir, CSV_FILE_DIR);
writeCSVFile(defaultKeys, filePath);
// generate YML files
filePath = PathUtils.concatPath(homeDir, YML_FILE_DIR);
writeYMLFile(defaultKeys, filePath);
}
Aggregations