Search in sources :

Example 11 with UnderFileSystemConfiguration

use of alluxio.underfs.UnderFileSystemConfiguration in project alluxio by Alluxio.

the class UfsJournalConfTest method nonEmptyConfiguration.

@Test
public void nonEmptyConfiguration() throws Exception {
    PropertyKey key = PropertyKey.Template.MASTER_JOURNAL_UFS_OPTION_PROPERTY.format(PropertyKey.UNDERFS_LISTING_LENGTH.toString());
    String value = "10000";
    ServerConfiguration.set(key, value);
    UnderFileSystemConfiguration conf = UfsJournal.getJournalUfsConf();
    Assert.assertEquals(value, conf.get(PropertyKey.UNDERFS_LISTING_LENGTH));
    Assert.assertEquals(1, conf.getMountSpecificConf().size());
}
Also used : UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) PropertyKey(alluxio.conf.PropertyKey) Test(org.junit.Test)

Example 12 with UnderFileSystemConfiguration

use of alluxio.underfs.UnderFileSystemConfiguration in project alluxio by Alluxio.

the class UfsIOBench method cleanUp.

private void cleanUp() throws IOException {
    UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(mConf).createMountSpecificConf(mParameters.mConf);
    UnderFileSystem ufs = UnderFileSystem.Factory.create(mDataDir, ufsConf);
    for (int i = 0; i < mParameters.mThreads; i++) {
        ufs.deleteFile(getFilePath(i));
    }
}
Also used : UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) UnderFileSystem(alluxio.underfs.UnderFileSystem)

Example 13 with UnderFileSystemConfiguration

use of alluxio.underfs.UnderFileSystemConfiguration in project alluxio by Alluxio.

the class S3AUnderFileSystemTest method createCredentialsFromConf.

@Test
public void createCredentialsFromConf() throws Exception {
    Map<PropertyKey, Object> conf = new HashMap<>();
    conf.put(PropertyKey.S3A_ACCESS_KEY, "key1");
    conf.put(PropertyKey.S3A_SECRET_KEY, "key2");
    try (Closeable c = new ConfigurationRule(conf, sConf).toResource()) {
        UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(sConf);
        AWSCredentialsProvider credentialsProvider = S3AUnderFileSystem.createAwsCredentialsProvider(ufsConf);
        Assert.assertEquals("key1", credentialsProvider.getCredentials().getAWSAccessKeyId());
        Assert.assertEquals("key2", credentialsProvider.getCredentials().getAWSSecretKey());
        Assert.assertTrue(credentialsProvider instanceof AWSStaticCredentialsProvider);
    }
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) HashMap(java.util.HashMap) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Closeable(java.io.Closeable) ConfigurationRule(alluxio.ConfigurationRule) PropertyKey(alluxio.conf.PropertyKey) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Example 14 with UnderFileSystemConfiguration

use of alluxio.underfs.UnderFileSystemConfiguration in project alluxio by Alluxio.

the class S3AUnderFileSystemTest method createCredentialsFromDefault.

@Test
public void createCredentialsFromDefault() throws Exception {
    // Unset AWS properties if present
    Map<PropertyKey, Object> conf = new HashMap<>();
    conf.put(PropertyKey.S3A_ACCESS_KEY, null);
    conf.put(PropertyKey.S3A_SECRET_KEY, null);
    try (Closeable c = new ConfigurationRule(conf, sConf).toResource()) {
        UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(sConf);
        AWSCredentialsProvider credentialsProvider = S3AUnderFileSystem.createAwsCredentialsProvider(ufsConf);
        Assert.assertTrue(credentialsProvider instanceof DefaultAWSCredentialsProviderChain);
    }
}
Also used : DefaultAWSCredentialsProviderChain(com.amazonaws.auth.DefaultAWSCredentialsProviderChain) HashMap(java.util.HashMap) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Closeable(java.io.Closeable) ConfigurationRule(alluxio.ConfigurationRule) PropertyKey(alluxio.conf.PropertyKey) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Example 15 with UnderFileSystemConfiguration

use of alluxio.underfs.UnderFileSystemConfiguration in project alluxio by Alluxio.

the class S3AUnderFileSystemTest method getPermissionsWithMapping.

@Test
public void getPermissionsWithMapping() throws Exception {
    Map<PropertyKey, Object> conf = new HashMap<>();
    conf.put(PropertyKey.UNDERFS_S3_OWNER_ID_TO_USERNAME_MAPPING, "111=altname");
    try (Closeable c = new ConfigurationRule(conf, sConf).toResource()) {
        UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(sConf);
        mS3UnderFileSystem = new S3AUnderFileSystem(new AlluxioURI("s3a://" + BUCKET_NAME), mClient, BUCKET_NAME, mExecutor, mManager, UnderFileSystemConfiguration.defaults(sConf), false);
    }
    Mockito.when(mClient.getS3AccountOwner()).thenReturn(new Owner("111", "test"));
    Mockito.when(mClient.getBucketAcl(Mockito.anyString())).thenReturn(new AccessControlList());
    ObjectUnderFileSystem.ObjectPermissions permissions = mS3UnderFileSystem.getPermissions();
    Assert.assertEquals("altname", permissions.getOwner());
    Assert.assertEquals("altname", permissions.getGroup());
    Assert.assertEquals(0, permissions.getMode());
}
Also used : AccessControlList(com.amazonaws.services.s3.model.AccessControlList) Owner(com.amazonaws.services.s3.model.Owner) HashMap(java.util.HashMap) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Closeable(java.io.Closeable) ObjectUnderFileSystem(alluxio.underfs.ObjectUnderFileSystem) ConfigurationRule(alluxio.ConfigurationRule) PropertyKey(alluxio.conf.PropertyKey) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

UnderFileSystemConfiguration (alluxio.underfs.UnderFileSystemConfiguration)24 Test (org.junit.Test)8 AlluxioURI (alluxio.AlluxioURI)5 PropertyKey (alluxio.conf.PropertyKey)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ConfigurationRule (alluxio.ConfigurationRule)4 InstancedConfiguration (alluxio.conf.InstancedConfiguration)4 UnderFileSystem (alluxio.underfs.UnderFileSystem)4 Closeable (java.io.Closeable)4 IOException (java.io.IOException)3 Configuration (org.apache.hadoop.conf.Configuration)3 ValidationUtils (alluxio.cli.ValidationUtils)2 IOTaskResult (alluxio.stress.worker.IOTaskResult)2 UfsIOParameters (alluxio.stress.worker.UfsIOParameters)2 ObjectUnderFileSystem (alluxio.underfs.ObjectUnderFileSystem)2 UnderFileSystemFactory (alluxio.underfs.UnderFileSystemFactory)2 CommonUtils (alluxio.util.CommonUtils)2 FormatUtils (alluxio.util.FormatUtils)2 ExecutorServiceFactories (alluxio.util.executor.ExecutorServiceFactories)2