public final class AliyunOSSUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
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 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 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 © 2008–2020 Apache Software Foundation. All rights reserved.