Search in sources :

Example 86 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class CpCommandIntegrationTest method copyAfterWorkersNotAvailableMustCache.

@Test
public void copyAfterWorkersNotAvailableMustCache() throws Exception {
    InstancedConfiguration conf = new InstancedConfiguration(ServerConfiguration.global());
    conf.set(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, "MUST_CACHE");
    try (FileSystemShell fsShell = new FileSystemShell(conf)) {
        File testFile = new File(sLocalAlluxioCluster.getAlluxioHome() + "/testFile");
        testFile.createNewFile();
        FileOutputStream fos = new FileOutputStream(testFile);
        byte[] toWrite = BufferUtils.getIncreasingByteArray(100);
        fos.write(toWrite);
        fos.close();
        fsShell.run("copyFromLocal", testFile.getPath(), "/");
        Assert.assertTrue(sFileSystem.exists(new AlluxioURI("/testFile")));
        sLocalAlluxioCluster.stopWorkers();
        fsShell.run("cp", "/testFile", "/testFile2");
        Assert.assertFalse(sFileSystem.exists(new AlluxioURI("/testFile2")));
    }
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) FileOutputStream(java.io.FileOutputStream) FileSystemShell(alluxio.cli.fs.FileSystemShell) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test) FileSystemShellUtilsTest(alluxio.client.cli.fs.FileSystemShellUtilsTest)

Example 87 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class ConfigurationUtils method getClusterConf.

/**
 * Loads the cluster level configuration from the get configuration response,
 * filters out the configuration for certain scope, and merges it with the existing configuration.
 *
 * @param response the get configuration RPC response
 * @param conf the existing configuration
 * @param scope the target scope
 * @return the merged configuration
 */
public static AlluxioConfiguration getClusterConf(GetConfigurationPResponse response, AlluxioConfiguration conf, Scope scope) {
    String clientVersion = conf.getString(PropertyKey.VERSION);
    LOG.debug("Alluxio {} (version {}) is trying to load cluster level configurations", scope, clientVersion);
    List<alluxio.grpc.ConfigProperty> clusterConfig = response.getClusterConfigsList();
    Properties clusterProps = filterAndLoadProperties(clusterConfig, scope, (key, value) -> String.format("Loading property: %s (%s) -> %s", key, key.getScope(), value));
    // Check version.
    String clusterVersion = clusterProps.get(PropertyKey.VERSION).toString();
    if (!clientVersion.equals(clusterVersion)) {
        LOG.warn("Alluxio {} version ({}) does not match Alluxio cluster version ({})", scope, clientVersion, clusterVersion);
        clusterProps.remove(PropertyKey.VERSION);
    }
    // Merge conf returned by master as the cluster default into conf object
    AlluxioProperties props = conf.copyProperties();
    props.merge(clusterProps, Source.CLUSTER_DEFAULT);
    // Use the constructor to set cluster defaults as being loaded.
    InstancedConfiguration updatedConf = new InstancedConfiguration(props, true);
    updatedConf.validate();
    LOG.debug("Alluxio {} has loaded cluster level configurations", scope);
    return updatedConf;
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) AlluxioProperties(alluxio.conf.AlluxioProperties) ConfigProperty(alluxio.grpc.ConfigProperty) AlluxioProperties(alluxio.conf.AlluxioProperties) Properties(java.util.Properties)

Example 88 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class UnderFileSystemFactoryRegistry method getSupportedVersions.

/**
 * Get a list of supported versions for a particular UFS path.
 *
 * @param path the UFS URI to test
 * @param ufsConf the UFS configuration for the mount
 * @return a list of supported versions. The list will be empty if the particular UFS type does
 *         not support setting a version on the mount.
 */
public static List<String> getSupportedVersions(String path, UnderFileSystemConfiguration ufsConf) {
    // copy properties to not modify the original conf.
    UnderFileSystemConfiguration ufsConfCopy = UnderFileSystemConfiguration.defaults(new InstancedConfiguration(ufsConf.copyProperties()));
    // unset the configuration to make sure any supported factories for the path are returned.
    ufsConfCopy.unset(PropertyKey.UNDERFS_VERSION);
    // Check if any versioned factory supports the default configuration
    List<UnderFileSystemFactory> factories = sRegistryInstance.findAll(path, ufsConfCopy);
    List<String> supportedVersions = new ArrayList<>();
    for (UnderFileSystemFactory factory : factories) {
        if (!factory.getVersion().isEmpty()) {
            supportedVersions.add(factory.getVersion());
        }
    }
    return supportedVersions;
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) ArrayList(java.util.ArrayList)

Example 89 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class StackMain method main.

/**
 * @param args arguments
 */
public static void main(String[] args) {
    if (args.length < 2) {
        System.out.println("Usage: <mountPoint> <sourcePath> <fuseOpts e.g. -obig_writes...>");
        System.exit(1);
    }
    Path root = Paths.get(args[1]);
    Path mountPoint = Paths.get(args[0]);
    StackFS fs = new StackFS(root, mountPoint);
    String[] fuseOpts = new String[args.length - 2];
    System.arraycopy(args, 2, fuseOpts, 0, args.length - 2);
    try {
        AlluxioConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
        CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.CLIENT);
        MetricsSystem.startSinks(conf.getString(PropertyKey.METRICS_CONF_FILE));
        fs.mount(true, false, fuseOpts);
    } catch (Exception e) {
        e.printStackTrace();
        fs.umount(true);
        System.exit(1);
    }
}
Also used : Path(java.nio.file.Path) InstancedConfiguration(alluxio.conf.InstancedConfiguration) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration)

Example 90 with InstancedConfiguration

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

InstancedConfiguration (alluxio.conf.InstancedConfiguration)94 Test (org.junit.Test)35 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)16 AlluxioURI (alluxio.AlluxioURI)14 AlluxioProperties (alluxio.conf.AlluxioProperties)11 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)10 HashMap (java.util.HashMap)9 BaseHubTest (alluxio.hub.test.BaseHubTest)8 InetSocketAddress (java.net.InetSocketAddress)8 FileSystemShell (alluxio.cli.fs.FileSystemShell)6 FileSystemContext (alluxio.client.file.FileSystemContext)6 HealthCheckClient (alluxio.HealthCheckClient)5 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)5 FileSystemShellUtilsTest (alluxio.client.cli.fs.FileSystemShellUtilsTest)5 MasterInquireClient (alluxio.master.MasterInquireClient)5 Properties (java.util.Properties)5 ParseException (org.apache.commons.cli.ParseException)5 ClientContext (alluxio.ClientContext)4 FileSystem (alluxio.client.file.FileSystem)4