Search in sources :

Example 16 with UnderFileSystemConfiguration

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

the class S3AUnderFileSystemTest method getPermissionsNoMapping.

@Test
public void getPermissionsNoMapping() throws Exception {
    Map<PropertyKey, Object> conf = new HashMap<>();
    conf.put(PropertyKey.UNDERFS_S3_OWNER_ID_TO_USERNAME_MAPPING, "111=userid");
    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("0", "test"));
    Mockito.when(mClient.getBucketAcl(Mockito.anyString())).thenReturn(new AccessControlList());
    ObjectUnderFileSystem.ObjectPermissions permissions = mS3UnderFileSystem.getPermissions();
    Assert.assertEquals("test", permissions.getOwner());
    Assert.assertEquals("test", 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)

Example 17 with UnderFileSystemConfiguration

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

the class HdfsUnderFileSystemTest method prepareConfiguration.

/**
 * Tests the {@link HdfsUnderFileSystem#createConfiguration} method.
 *
 * Checks the hdfs implements class and alluxio underfs config setting
 */
@Test
public void prepareConfiguration() throws Exception {
    UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(ConfigurationTestUtils.defaults());
    org.apache.hadoop.conf.Configuration conf = HdfsUnderFileSystem.createConfiguration(ufsConf);
    Assert.assertEquals(ufsConf.get(PropertyKey.UNDERFS_HDFS_IMPL), conf.get("fs.hdfs.impl"));
    Assert.assertTrue(conf.getBoolean("fs.hdfs.impl.disable.cache", false));
}
Also used : UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Test(org.junit.Test)

Example 18 with UnderFileSystemConfiguration

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

the class KodoUnderFileSystem method creatInstance.

protected static KodoUnderFileSystem creatInstance(AlluxioURI uri, UnderFileSystemConfiguration conf) {
    String bucketName = UnderFileSystemUtils.getBucketName(uri);
    Preconditions.checkArgument(conf.isSet(PropertyKey.KODO_ACCESS_KEY), "Property %s is required to connect to Kodo", PropertyKey.KODO_ACCESS_KEY);
    Preconditions.checkArgument(conf.isSet(PropertyKey.KODO_SECRET_KEY), "Property %s is required to connect to Kodo", PropertyKey.KODO_SECRET_KEY);
    Preconditions.checkArgument(conf.isSet(PropertyKey.KODO_DOWNLOAD_HOST), "Property %s is required to connect to Kodo", PropertyKey.KODO_DOWNLOAD_HOST);
    Preconditions.checkArgument(conf.isSet(PropertyKey.KODO_ENDPOINT), "Property %s is required to connect to Kodo", PropertyKey.KODO_ENDPOINT);
    String accessKey = conf.getString(PropertyKey.KODO_ACCESS_KEY);
    String secretKey = conf.getString(PropertyKey.KODO_SECRET_KEY);
    String endPoint = conf.getString(PropertyKey.KODO_ENDPOINT);
    String souceHost = conf.getString(PropertyKey.KODO_DOWNLOAD_HOST);
    Auth auth = Auth.create(accessKey, secretKey);
    Configuration configuration = new Configuration();
    OkHttpClient.Builder okHttpBuilder = initializeKodoClientConfig(conf);
    OkHttpClient okHttpClient = okHttpBuilder.build();
    KodoClient kodoClient = new KodoClient(auth, bucketName, souceHost, endPoint, configuration, okHttpClient);
    return new KodoUnderFileSystem(uri, kodoClient, conf);
}
Also used : Builder(okhttp3.OkHttpClient.Builder) OkHttpClient(okhttp3.OkHttpClient) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Configuration(com.qiniu.storage.Configuration) Auth(com.qiniu.util.Auth)

Example 19 with UnderFileSystemConfiguration

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

the class AdlUnderFileSystem method createConfiguration.

/**
 * Prepares the configuration for this Adl as an HDFS configuration.
 *
 * @param conf the configuration for this UFS
 * @return the created configuration
 */
public static Configuration createConfiguration(UnderFileSystemConfiguration conf) {
    Configuration adlConf = HdfsUnderFileSystem.createConfiguration(conf);
    for (Map.Entry<String, Object> entry : conf.toMap().entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
        if (PropertyKey.Template.UNDERFS_AZURE_CLIENT_ID.matches(key)) {
            adlConf.set(key, (String) value);
        }
        if (PropertyKey.Template.UNDERFS_AZURE_CLIENT_SECRET.matches(key)) {
            adlConf.set(key, (String) value);
        }
        if (PropertyKey.Template.UNDERFS_AZURE_REFRESH_URL.matches(key)) {
            adlConf.set(key, (String) value);
        }
    }
    LOG.info(adlConf.toString());
    adlConf.set("fs.adl.oauth2.access.token.provider.type", "ClientCredential");
    return adlConf;
}
Also used : UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Configuration(org.apache.hadoop.conf.Configuration) Map(java.util.Map)

Example 20 with UnderFileSystemConfiguration

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

the class UfsConfigurationJournalTest method testOptionsPersisted.

@Test
public void testOptionsPersisted() throws Exception {
    // Set ufs specific options and other mount flags
    AlluxioURI mountPoint = new AlluxioURI("/mnt");
    ImmutableMap<String, String> options = ImmutableMap.of("k1", "v1", "k2", "v2");
    mFs.mount(mountPoint, new AlluxioURI(LOCAL_UFS_PATH), MountPOptions.newBuilder().putAllProperties(options).setReadOnly(true).setShared(true).build());
    // Get mount id
    MountTable mountTable = Whitebox.getInternalState(mLocalAlluxioClusterResource.get().getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class), "mMountTable");
    long mountId = mountTable.resolve(mountPoint).getMountId();
    // Restart masters
    mLocalAlluxioClusterResource.get().restartMasters();
    // Checks all options and flags are persisted after restart
    UfsManager ufsManager = Whitebox.getInternalState(mLocalAlluxioClusterResource.get().getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class), "mUfsManager");
    try (CloseableResource<UnderFileSystem> resource = ufsManager.get(mountId).acquireUfsResource()) {
        UnderFileSystemConfiguration ufsConf = Whitebox.getInternalState(resource.get(), "mConf");
        assertEquals(ufsConf.getMountSpecificConf().size(), options.size());
        for (Map.Entry<String, String> entry : options.entrySet()) {
            assertEquals(entry.getValue(), ufsConf.getMountSpecificConf().get(entry.getKey()));
        }
        assertTrue(ufsConf.isReadOnly());
        assertTrue(ufsConf.isShared());
    }
}
Also used : UfsManager(alluxio.underfs.UfsManager) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) FileSystemMaster(alluxio.master.file.FileSystemMaster) MountTable(alluxio.master.file.meta.MountTable) UnderFileSystem(alluxio.underfs.UnderFileSystem) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) 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