use of alluxio.wire.Configuration in project alluxio by Alluxio.
the class DefaultBlockWorker method getConfiguration.
@Override
public Configuration getConfiguration(GetConfigurationPOptions options) {
// NOTE(cc): there is no guarantee that the returned cluster and path configurations are
// consistent snapshot of the system's state at a certain time, the path configuration might
// be in a newer state. But it's guaranteed that the hashes are respectively correspondent to
// the properties.
Configuration.Builder builder = Configuration.newBuilder();
if (!options.getIgnoreClusterConf()) {
Set<PropertyKey> keys = ServerConfiguration.keySet();
for (PropertyKey key : ServerConfiguration.keySet()) {
if (key.isBuiltIn()) {
Source source = ServerConfiguration.getSource(key);
Object value = ServerConfiguration.getOrDefault(key, null, ConfigurationValueOptions.defaults().useDisplayValue(true).useRawValue(options.getRawValue()));
builder.addClusterProperty(key.getName(), value, source);
}
}
// NOTE(cc): assumes that ServerConfiguration is read-only when master is running, otherwise,
// the following hash might not correspond to the above cluster configuration.
builder.setClusterConfHash(ServerConfiguration.hash());
}
return builder.build();
}
use of alluxio.wire.Configuration in project alluxio by Alluxio.
the class DefaultMetaMaster method getConfiguration.
@Override
public Configuration getConfiguration(GetConfigurationPOptions options) {
// NOTE(cc): there is no guarantee that the returned cluster and path configurations are
// consistent snapshot of the system's state at a certain time, the path configuration might
// be in a newer state. But it's guaranteed that the hashes are respectively correspondent to
// the properties.
Configuration.Builder builder = Configuration.newBuilder();
if (!options.getIgnoreClusterConf()) {
for (PropertyKey key : ServerConfiguration.keySet()) {
if (key.isBuiltIn()) {
Source source = ServerConfiguration.getSource(key);
Object value = ServerConfiguration.getOrDefault(key, null, ConfigurationValueOptions.defaults().useDisplayValue(true).useRawValue(options.getRawValue()));
builder.addClusterProperty(key.getName(), value, source);
}
}
// NOTE(cc): assumes that ServerConfiguration is read-only when master is running, otherwise,
// the following hash might not correspond to the above cluster configuration.
builder.setClusterConfHash(ServerConfiguration.hash());
}
if (!options.getIgnorePathConf()) {
PathPropertiesView pathProperties = mPathProperties.snapshot();
pathProperties.getProperties().forEach((path, properties) -> properties.forEach((key, value) -> builder.addPathProperty(path, key, value)));
builder.setPathConfHash(pathProperties.getHash());
}
return builder.build();
}
use of alluxio.wire.Configuration in project alluxio by Alluxio.
the class ShowCommand method run.
@Override
public int run(CommandLine cl) throws IOException {
String targetPath = cl.getArgs()[0];
Configuration configuration = mMetaConfigClient.getConfiguration(GetConfigurationPOptions.getDefaultInstance());
if (cl.hasOption(ALL_OPTION_NAME)) {
Map<String, AlluxioConfiguration> pathConfMap = new HashMap<>();
configuration.getPathConf().forEach((path, conf) -> {
AlluxioProperties properties = new AlluxioProperties();
conf.forEach(property -> {
PropertyKey key = PropertyKey.fromString(property.getName());
properties.set(key, property.getValue());
});
pathConfMap.put(path, new InstancedConfiguration(properties));
});
PathConfiguration pathConf = PathConfiguration.create(pathConfMap);
AlluxioURI targetUri = new AlluxioURI(targetPath);
List<PropertyKey> propertyKeys = new ArrayList<>(pathConf.getPropertyKeys(targetUri));
propertyKeys.sort(Comparator.comparing(PropertyKey::getName));
propertyKeys.forEach(key -> {
pathConf.getConfiguration(targetUri, key).ifPresent(conf -> {
mPrintStream.println(format(key.getName(), conf.get(key)));
});
});
} else if (configuration.getPathConf().containsKey(targetPath)) {
List<Property> properties = configuration.getPathConf().get(targetPath);
properties.sort(Comparator.comparing(Property::getName));
properties.forEach(property -> {
mPrintStream.println(format(property.getName(), property.getValue()));
});
}
return 0;
}
use of alluxio.wire.Configuration in project alluxio by Alluxio.
the class ListCommand method run.
@Override
public int run(CommandLine cl) throws AlluxioException, IOException {
Configuration conf = mMetaConfigClient.getConfiguration(GetConfigurationPOptions.newBuilder().setIgnoreClusterConf(true).build());
List<String> paths = new ArrayList<>(conf.getPathConf().keySet());
Collections.sort(paths);
for (String path : paths) {
mPrintStream.println(path);
}
return 0;
}
Aggregations