@Test public void getBucketName() throws Exception { Assert.assertEquals("s3-bucket-name", UnderFileSystemUtils.getBucketName(new AlluxioURI("s3://s3-bucket-name/"))); Assert.assertEquals("s3a_bucket_name", UnderFileSystemUtils.getBucketName(new AlluxioURI("s3a://s3a_bucket_name/"))); Assert.assertEquals("a.b.c", UnderFileSystemUtils.getBucketName(new AlluxioURI("gs://a.b.c/folder/sub-folder/"))); Assert.assertEquals("container&", UnderFileSystemUtils.getBucketName(new AlluxioURI("swift://container&/folder/file"))); Assert.assertEquals("oss", UnderFileSystemUtils.getBucketName(new AlluxioURI("oss://oss/folder/.file"))); } }
/** * Constructs a new instance of {@link OSSUnderFileSystem}. * * @param uri the {@link AlluxioURI} for this UFS * @param conf the configuration for this UFS * @param alluxioConf Alluxio configuration * @return the created {@link OSSUnderFileSystem} instance */ public static OSSUnderFileSystem createInstance(AlluxioURI uri, UnderFileSystemConfiguration conf, AlluxioConfiguration alluxioConf) throws Exception { String bucketName = UnderFileSystemUtils.getBucketName(uri); Preconditions.checkArgument(conf.isSet(PropertyKey.OSS_ACCESS_KEY), "Property %s is required to connect to OSS", PropertyKey.OSS_ACCESS_KEY); Preconditions.checkArgument(conf.isSet(PropertyKey.OSS_SECRET_KEY), "Property %s is required to connect to OSS", PropertyKey.OSS_SECRET_KEY); Preconditions.checkArgument(conf.isSet(PropertyKey.OSS_ENDPOINT_KEY), "Property %s is required to connect to OSS", PropertyKey.OSS_ENDPOINT_KEY); String accessId = conf.get(PropertyKey.OSS_ACCESS_KEY); String accessKey = conf.get(PropertyKey.OSS_SECRET_KEY); String endPoint = conf.get(PropertyKey.OSS_ENDPOINT_KEY); ClientConfiguration ossClientConf = initializeOSSClientConfig(alluxioConf); OSSClient ossClient = new OSSClient(endPoint, accessId, accessKey, ossClientConf); return new OSSUnderFileSystem(uri, ossClient, bucketName, conf, alluxioConf); }
protected static KodoUnderFileSystem creatInstance(AlluxioURI uri, UnderFileSystemConfiguration conf, AlluxioConfiguration alluxioConf) { 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.get(PropertyKey.KODO_ACCESS_KEY); String secretKey = conf.get(PropertyKey.KODO_SECRET_KEY); String endPoint = conf.get(PropertyKey.KODO_ENDPOINT); String souceHost = conf.get(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, alluxioConf); }
/** * Constructs a new instance of {@link COSUnderFileSystem}. * * @param uri the {@link AlluxioURI} for this UFS * @param conf the configuration for this UFS * @param alluxioConf Alluxio configuration * @return the created {@link COSUnderFileSystem} instance */ public static COSUnderFileSystem createInstance(AlluxioURI uri, UnderFileSystemConfiguration conf, AlluxioConfiguration alluxioConf) throws Exception { String bucketName = UnderFileSystemUtils.getBucketName(uri); Preconditions.checkArgument(conf.isSet(PropertyKey.COS_ACCESS_KEY), "Property %s is required to connect to COS", PropertyKey.COS_ACCESS_KEY); Preconditions.checkArgument(conf.isSet(PropertyKey.COS_SECRET_KEY), "Property %s is required to connect to COS", PropertyKey.COS_SECRET_KEY); Preconditions.checkArgument(conf.isSet(PropertyKey.COS_REGION), "Property %s is required to connect to COS", PropertyKey.COS_REGION); Preconditions.checkArgument(conf.isSet(PropertyKey.COS_APP_ID), "Property %s is required to connect to COS", PropertyKey.COS_APP_ID); String accessKey = conf.get(PropertyKey.COS_ACCESS_KEY); String secretKey = conf.get(PropertyKey.COS_SECRET_KEY); String regionName = conf.get(PropertyKey.COS_REGION); String appId = conf.get(PropertyKey.COS_APP_ID); COSCredentials cred = new BasicCOSCredentials(accessKey, secretKey); ClientConfig clientConfig = createCOSClientConfig(regionName, conf); COSClient client = new COSClient(cred, clientConfig); return new COSUnderFileSystem(uri, client, bucketName, appId, conf, alluxioConf); }
AlluxioURI uri, UnderFileSystemConfiguration conf, AlluxioConfiguration alluxioConf) throws ServiceException { String bucketName = UnderFileSystemUtils.getBucketName(uri); Preconditions.checkArgument(conf.isSet(PropertyKey.GCS_ACCESS_KEY), "Property " + PropertyKey.GCS_ACCESS_KEY + " is required to connect to GCS");
throws FileDoesNotExistException { super(uri, conf, alluxioConf); String containerName = UnderFileSystemUtils.getBucketName(uri); LOG.debug("Constructor init: {}", containerName); AccountConfig config = new AccountConfig();
String bucketName = UnderFileSystemUtils.getBucketName(uri);
String bucketName = UnderFileSystemUtils.getBucketName(uri); Preconditions.checkArgument(conf.containsKey(PropertyKey.GCS_ACCESS_KEY), "Property " + PropertyKey.GCS_ACCESS_KEY + " is required to connect to GCS");
throws FileDoesNotExistException { super(uri, conf); String containerName = UnderFileSystemUtils.getBucketName(uri); LOG.debug("Constructor init: {}", containerName); AccountConfig config = new AccountConfig();
String bucketName = UnderFileSystemUtils.getBucketName(uri); Preconditions.checkArgument(conf.containsKey(PropertyKey.S3N_ACCESS_KEY), "Property " + PropertyKey.S3N_ACCESS_KEY + " is required to connect to S3");