Search in sources :

Example 11 with AlluxioProperties

use of alluxio.conf.AlluxioProperties 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

AlluxioProperties (alluxio.conf.AlluxioProperties)11 InstancedConfiguration (alluxio.conf.InstancedConfiguration)11 Properties (java.util.Properties)4 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 HashMap (java.util.HashMap)2 AlluxioURI (alluxio.AlluxioURI)1 CommandUtils (alluxio.cli.CommandUtils)1 AbstractFsAdminCommand (alluxio.cli.fsadmin.command.AbstractFsAdminCommand)1 Context (alluxio.cli.fsadmin.command.Context)1 AlluxioBlockStore (alluxio.client.block.AlluxioBlockStore)1 FileSystemContext (alluxio.client.file.FileSystemContext)1 InStreamOptions (alluxio.client.file.options.InStreamOptions)1 PropertyKey (alluxio.conf.PropertyKey)1 PathConfiguration (alluxio.conf.path.PathConfiguration)1 InvalidArgumentException (alluxio.exception.status.InvalidArgumentException)1 ConfigProperty (alluxio.grpc.ConfigProperty)1 GetConfigurationPOptions (alluxio.grpc.GetConfigurationPOptions)1 OpenFilePOptions (alluxio.grpc.OpenFilePOptions)1 UnderFileSystemConfiguration (alluxio.underfs.UnderFileSystemConfiguration)1