public final class AliyunOSSUtils extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static long |
calculatePartSize(long contentLength,
long minPartSize)
Calculate a proper size of multipart piece.
|
static File |
createTmpFileForWrite(String path,
long size,
org.apache.hadoop.conf.Configuration conf)
Demand create the directory allocator, then create a temporary file.
|
static org.apache.hadoop.conf.Configuration |
excludeIncompatibleCredentialProviders(org.apache.hadoop.conf.Configuration config,
Class<? extends org.apache.hadoop.fs.FileSystem> fileSystemClass)
Note: This function is copied from
ProviderUtils
There are certain integrations of the credential provider API in
which a recursive dependency between the provider and the hadoop
filesystem abstraction causes a problem. |
static com.aliyun.oss.common.auth.CredentialsProvider |
getCredentialsProvider(URI uri,
org.apache.hadoop.conf.Configuration conf)
Create credential provider specified by configuration, or create default
credential provider if not specified.
|
static long |
getMultipartSizeProperty(org.apache.hadoop.conf.Configuration conf,
String property,
long defVal)
Get a size property from the configuration: this property must
be at least equal to
Constants.MULTIPART_MIN_SIZE. |
static String |
getValueWithKey(org.apache.hadoop.conf.Configuration conf,
String key)
Used to get password from configuration.
|
static int |
intPositiveOption(org.apache.hadoop.conf.Configuration conf,
String key,
int defVal) |
static String |
maybeAddTrailingSlash(String key)
Turns a path (relative or otherwise) into an OSS key, adding a trailing
"/" if the path is not the root and does not already have a "/"
at the end.
|
static boolean |
objectRepresentsDirectory(String name,
long size)
Check if OSS object represents a directory.
|
public static int intPositiveOption(org.apache.hadoop.conf.Configuration conf,
String key,
int defVal)
public static String getValueWithKey(org.apache.hadoop.conf.Configuration conf, String key) throws IOException
conf - configuration that contains password informationkey - the key of the passwordIOException - if failed to get password from configurationpublic static long calculatePartSize(long contentLength,
long minPartSize)
minPartSize
is too small, the number of multipart pieces may exceed the limit of
Constants.MULTIPART_UPLOAD_PART_NUM_LIMIT.contentLength - the size of file.minPartSize - the minimum size of multipart piece.public static org.apache.hadoop.conf.Configuration excludeIncompatibleCredentialProviders(org.apache.hadoop.conf.Configuration config,
Class<? extends org.apache.hadoop.fs.FileSystem> fileSystemClass)
throws IOException
ProviderUtils
There are certain integrations of the credential provider API in
which a recursive dependency between the provider and the hadoop
filesystem abstraction causes a problem. These integration points
need to leverage this utility method to remove problematic provider
types from the existing provider path within the configuration.config - the existing configuration with provider pathfileSystemClass - the class which providers must be compatibleIOExceptionpublic static com.aliyun.oss.common.auth.CredentialsProvider getCredentialsProvider(URI uri, org.apache.hadoop.conf.Configuration conf) throws IOException
uri - uri passed by callerconf - configurationIOException - on any problem. Class construction issues may be
nested inside the IOE.public static String maybeAddTrailingSlash(String key)
key - OSS key or ""public static boolean objectRepresentsDirectory(String name, long size)
name - object keysize - object content lengthpublic static File createTmpFileForWrite(String path, long size, org.apache.hadoop.conf.Configuration conf) throws IOException
path - prefix for the temporary filesize - the size of the file that is going to be writtenconf - the Configuration objectIOException - IO problemspublic static long getMultipartSizeProperty(org.apache.hadoop.conf.Configuration conf,
String property,
long defVal)
Constants.MULTIPART_MIN_SIZE.
If it is too small, it is rounded up to that minimum, and a warning
printed.conf - configurationproperty - property namedefVal - default valueCopyright © 2021 Apache Software Foundation. All Rights Reserved.