use of alluxio.client.meta.RetryHandlingMetaMasterConfigClient in project alluxio by Alluxio.
the class ConfigHashSync method resetMetaMasterConfigClient.
/**
* Resets the internal meta master client based on the new configuration.
*
* @param context the context containing the new configuration
*/
public void resetMetaMasterConfigClient(MasterClientContext context) {
mClient.close();
mClient = new RetryHandlingMetaMasterConfigClient(context);
}
use of alluxio.client.meta.RetryHandlingMetaMasterConfigClient in project alluxio by Alluxio.
the class GetConfTest method getConfFromMasterWithSource.
@Test
public void getConfFromMasterWithSource() throws Exception {
// Prepare mock meta master client
RetryHandlingMetaMasterConfigClient client = Mockito.mock(RetryHandlingMetaMasterConfigClient.class);
Mockito.when(client.getConfiguration(any())).thenReturn(Configuration.fromProto(prepareGetConfigurationResponse()));
assertEquals(0, GetConf.getConfImpl(() -> client, ServerConfiguration.global(), "--master", "--source"));
// CHECKSTYLE.OFF: LineLengthExceed - Much more readable
String expectedOutput = "alluxio.logger.type=MASTER_LOGGER (SYSTEM_PROPERTY)\n" + "alluxio.master.audit.logger.type=MASTER_AUDIT_LOGGER (SYSTEM_PROPERTY)\n" + "alluxio.master.hostname=localhost (SITE_PROPERTY (/alluxio/conf/alluxio-site.properties))\n" + "alluxio.master.mount.table.root.ufs=hdfs://localhost:9000 (SITE_PROPERTY (/alluxio/conf/alluxio-site.properties))\n" + "alluxio.master.rpc.port=19998 (DEFAULT)\n" + "alluxio.master.web.port=19999 (DEFAULT)\n";
// CHECKSTYLE.ON: LineLengthExceed
assertEquals(expectedOutput, mOutputStream.toString());
}
use of alluxio.client.meta.RetryHandlingMetaMasterConfigClient in project alluxio by Alluxio.
the class GetConfTest method getConfFromMaster.
@Test
public void getConfFromMaster() throws Exception {
// Prepare mock meta master client
RetryHandlingMetaMasterConfigClient client = Mockito.mock(RetryHandlingMetaMasterConfigClient.class);
Mockito.when(client.getConfiguration(any())).thenReturn(Configuration.fromProto(prepareGetConfigurationResponse()));
assertEquals(0, GetConf.getConfImpl(() -> client, ServerConfiguration.global(), "--master"));
String expectedOutput = "alluxio.logger.type=MASTER_LOGGER\n" + "alluxio.master.audit.logger.type=MASTER_AUDIT_LOGGER\n" + "alluxio.master.hostname=localhost\n" + "alluxio.master.mount.table.root.ufs=hdfs://localhost:9000\n" + "alluxio.master.rpc.port=19998\n" + "alluxio.master.web.port=19999\n";
assertEquals(expectedOutput, mOutputStream.toString());
}
use of alluxio.client.meta.RetryHandlingMetaMasterConfigClient in project alluxio by Alluxio.
the class FileSystemContextReinitIntegrationTest method updatePathConf.
private void updatePathConf() throws Exception {
MetaMasterConfigClient client = new RetryHandlingMetaMasterConfigClient(MasterClientContext.newBuilder(mContext.getClientContext()).build());
client.setPathConfiguration(PATH_TO_UPDATE, KEY_TO_UPDATE, UPDATED_VALUE);
}
use of alluxio.client.meta.RetryHandlingMetaMasterConfigClient in project alluxio by Alluxio.
the class GetConf method getConfImpl.
/**
* Implements get configuration.
*
* @param clientSupplier a functor to return a config client of meta master
* @param alluxioConf Alluxio configuration
* @param args list of arguments
* @return 0 on success, 1 on failures
*/
@VisibleForTesting
public static int getConfImpl(Supplier<RetryHandlingMetaMasterConfigClient> clientSupplier, AlluxioConfiguration alluxioConf, String... args) {
CommandLineParser parser = new DefaultParser();
CommandLine cmd;
try {
cmd = parser.parse(OPTIONS, args, true);
} catch (ParseException e) {
printHelp("Unable to parse input args: " + e.getMessage());
return 1;
}
args = cmd.getArgs();
Map<String, ConfigProperty> confMap = new HashMap<>();
if (cmd.hasOption(MASTER_OPTION_NAME)) {
// load cluster-wide configuration
try (RetryHandlingMetaMasterConfigClient client = clientSupplier.get()) {
client.getConfiguration(GetConfigurationPOptions.newBuilder().setIgnorePathConf(true).build()).getClusterConf().forEach(prop -> confMap.put(prop.getName(), prop.toProto()));
} catch (IOException e) {
System.out.println("Unable to get master-side configuration: " + e.getMessage());
return -1;
}
} else {
// load local configuration
for (PropertyKey key : alluxioConf.keySet()) {
if (key.isBuiltIn()) {
ConfigProperty.Builder config = ConfigProperty.newBuilder().setName(key.getName()).setSource(alluxioConf.getSource(key).toString());
Object val = alluxioConf.getOrDefault(key, null, ConfigurationValueOptions.defaults().useDisplayValue(true));
if (val != null) {
config.setValue(String.valueOf(val));
}
confMap.put(key.getName(), config.build());
}
}
}
StringBuilder output = new StringBuilder();
switch(args.length) {
case 0:
List<ConfigProperty> properties = new ArrayList<>(confMap.values());
properties.sort(Comparator.comparing(ConfigProperty::getName));
for (ConfigProperty property : properties) {
String value = ConfigurationUtils.valueAsString(property.getValue());
output.append(String.format("%s=%s", property.getName(), value));
if (cmd.hasOption(SOURCE_OPTION_NAME)) {
output.append(String.format(" (%s)", property.getSource()));
}
output.append("\n");
}
System.out.print(output.toString());
break;
case 1:
if (!PropertyKey.isValid(args[0])) {
printHelp(String.format("%s is not a valid configuration key", args[0]));
return 1;
}
// args[0] can be the alias
String key = PropertyKey.fromString(args[0]).getName();
ConfigProperty property = confMap.get(key);
if (property == null) {
printHelp(String.format("%s is not found", key));
return 1;
}
if (property.getValue() == null) {
// value not set
System.out.println("");
} else {
if (cmd.hasOption(SOURCE_OPTION_NAME)) {
System.out.println(property.getSource());
} else if (cmd.hasOption(UNIT_OPTION_NAME)) {
String arg = cmd.getOptionValue(UNIT_OPTION_NAME).toUpperCase();
try {
ByteUnit byteUnit;
byteUnit = ByteUnit.valueOf(arg);
System.out.println(FormatUtils.parseSpaceSize(property.getValue()) / byteUnit.getValue());
break;
} catch (Exception e) {
// try next unit parse
}
try {
TimeUnit timeUnit;
timeUnit = TimeUnit.valueOf(arg);
System.out.println(FormatUtils.parseTimeSize(property.getValue()) / timeUnit.getValue());
break;
} catch (IllegalArgumentException ex) {
// try next unit parse
}
printHelp(String.format("%s is not a valid unit", arg));
return 1;
} else {
System.out.println(property.getValue());
}
}
break;
default:
printHelp(String.format("More arguments than expected. Args: %s", Arrays.toString(args)));
return 1;
}
return 0;
}
Aggregations