Search in sources :

Example 1 with PathConfiguration

use of alluxio.conf.path.PathConfiguration 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;
}
Also used : Configuration(alluxio.wire.Configuration) GetConfigurationPOptions(alluxio.grpc.GetConfigurationPOptions) PathConfiguration(alluxio.conf.path.PathConfiguration) Options(org.apache.commons.cli.Options) CommandUtils(alluxio.cli.CommandUtils) IOException(java.io.IOException) HashMap(java.util.HashMap) PropertyKey(alluxio.conf.PropertyKey) AlluxioProperties(alluxio.conf.AlluxioProperties) ArrayList(java.util.ArrayList) List(java.util.List) Context(alluxio.cli.fsadmin.command.Context) AlluxioURI(alluxio.AlluxioURI) Map(java.util.Map) AbstractFsAdminCommand(alluxio.cli.fsadmin.command.AbstractFsAdminCommand) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) CommandLine(org.apache.commons.cli.CommandLine) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Comparator(java.util.Comparator) InstancedConfiguration(alluxio.conf.InstancedConfiguration) InvalidArgumentException(alluxio.exception.status.InvalidArgumentException) Property(alluxio.wire.Property) Option(org.apache.commons.cli.Option) PathConfiguration(alluxio.conf.path.PathConfiguration) Configuration(alluxio.wire.Configuration) PathConfiguration(alluxio.conf.path.PathConfiguration) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) InstancedConfiguration(alluxio.conf.InstancedConfiguration) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) InstancedConfiguration(alluxio.conf.InstancedConfiguration) AlluxioProperties(alluxio.conf.AlluxioProperties) ArrayList(java.util.ArrayList) List(java.util.List) Property(alluxio.wire.Property) PropertyKey(alluxio.conf.PropertyKey) AlluxioURI(alluxio.AlluxioURI)

Aggregations

AlluxioURI (alluxio.AlluxioURI)1 CommandUtils (alluxio.cli.CommandUtils)1 AbstractFsAdminCommand (alluxio.cli.fsadmin.command.AbstractFsAdminCommand)1 Context (alluxio.cli.fsadmin.command.Context)1 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)1 AlluxioProperties (alluxio.conf.AlluxioProperties)1 InstancedConfiguration (alluxio.conf.InstancedConfiguration)1 PropertyKey (alluxio.conf.PropertyKey)1 PathConfiguration (alluxio.conf.path.PathConfiguration)1 InvalidArgumentException (alluxio.exception.status.InvalidArgumentException)1 GetConfigurationPOptions (alluxio.grpc.GetConfigurationPOptions)1 Configuration (alluxio.wire.Configuration)1 Property (alluxio.wire.Property)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1