public class ADLStoreClient extends Object
ADLStoreClient
class represents a client to Azure Data Lake. It can be used to perform operations on files
and directories.Modifier and Type | Method and Description |
---|---|
boolean |
checkAccess(String path,
String rwx)
checks whether the calling user has the required permissions for the file/directory .
|
boolean |
checkExists(String filename)
Check that a file or directory exists.
|
boolean |
concatenateFiles(String path,
List<String> fileList)
Concatenate the specified list of files into this file.
|
static ADLStoreClient |
createClient(String accountFQDN,
AccessTokenProvider tokenProvider)
gets an
ADLStoreClient object. |
static ADLStoreClient |
createClient(String accountFQDN,
AzureADToken token)
gets an
ADLStoreClient object. |
static ADLStoreClient |
createClient(String accountFQDN,
ClientCredsTokenProvider tokenProvider)
gets an
ADLStoreClient object. |
static ADLStoreClient |
createClient(String accountFQDN,
DeviceCodeTokenProvider tokenProvider)
gets an
ADLStoreClient object. |
static ADLStoreClient |
createClient(String accountFQDN,
MsiTokenProvider tokenProvider)
gets an
ADLStoreClient object. |
static ADLStoreClient |
createClient(String accountFQDN,
RefreshTokenBasedTokenProvider tokenProvider)
gets an
ADLStoreClient object. |
static ADLStoreClient |
createClient(String accountFQDN,
String accessToken)
gets an
ADLStoreClient object. |
static ADLStoreClient |
createClient(String accountFQDN,
UserPasswordTokenProvider tokenProvider)
gets an
ADLStoreClient object. |
boolean |
createDirectory(String path)
creates a directory, and all it's parent directories if they dont already exist.
|
boolean |
createDirectory(String path,
String octalPermission)
creates a directory, and all it's parent directories if they dont already exist.
|
void |
createEmptyFile(String filename)
Creates an empty file.
|
ADLFileOutputStream |
createFile(String path,
IfExists mode)
create a file.
|
ADLFileOutputStream |
createFile(String path,
IfExists mode,
String octalPermission,
boolean createParent)
create a file.
|
boolean |
delete(String path)
delete the file or directory.
|
boolean |
deleteRecursive(String path)
deletes a directory and all it's child directories and files recursively.
|
List<DirectoryEntry> |
enumerateDirectory(String path)
Enumerates the contents of a directory, returning a
List of DirectoryEntry objects,
one per file or directory in the specified directory. |
List<DirectoryEntry> |
enumerateDirectory(String path,
int maxEntriesToRetrieve)
Enumerates the contents of a directory, returning a
List of DirectoryEntry objects,
one per file or directory in the specified directory. |
List<DirectoryEntry> |
enumerateDirectory(String path,
int maxEntriesToRetrieve,
String startAfter)
Enumerates the contents of a directory, returning a
List of DirectoryEntry objects,
one per file or directory in the specified directory. |
List<DirectoryEntry> |
enumerateDirectory(String path,
int maxEntriesToRetrieve,
String startAfter,
String endBefore)
Enumerates the contents of a directory, returning a
List of DirectoryEntry objects,
one per file or directory in the specified directory. |
List<DirectoryEntry> |
enumerateDirectory(String path,
int maxEntriesToRetrieve,
String startAfter,
String endBefore,
UserGroupRepresentation oidOrUpn)
Enumerates the contents of a directory, returning a
List of DirectoryEntry objects,
one per file or directory in the specified directory. |
List<DirectoryEntry> |
enumerateDirectory(String path,
String startAfter)
Enumerates the contents of a directory, returning a
List of DirectoryEntry objects,
one per file or directory in the specified directory. |
List<DirectoryEntry> |
enumerateDirectory(String path,
String startAfter,
String endBefore)
Enumerates the contents of a directory, returning a
List of DirectoryEntry objects,
one per file or directory in the specified directory. |
List<DirectoryEntry> |
enumerateDirectory(String path,
UserGroupRepresentation oidOrUpn)
Enumerates the contents of a directory, returning a
List of DirectoryEntry objects,
one per file or directory in the specified directory. |
AclStatus |
getAclStatus(String path)
Queries the ACLs and permissions for a file or directory.
|
AclStatus |
getAclStatus(String path,
UserGroupRepresentation oidOrUpn)
Queries the ACLs and permissions for a file or directory.
|
ADLFileOutputStream |
getAppendStream(String path)
appends to an existing file.
|
ContentSummary |
getContentSummary(String path)
Gets the content summary of a file or directory.
|
int |
getDefaultTimeout()
gets the default timeout for HTTP calls made by methods in ADLStoreClient objects
|
DirectoryEntry |
getDirectoryEntry(String path)
Gets the directory metadata about this file or directory.
|
DirectoryEntry |
getDirectoryEntry(String path,
UserGroupRepresentation oidOrUpn)
Gets the directory metadata about this file or directory.
|
IOException |
getExceptionFromResponse(OperationResponse resp,
String defaultMessage)
creates an
ADLException from OperationResponse . |
ADLFileInputStream |
getReadStream(String path)
Opens a file for read and returns an
ADLFileInputStream to read the file
contents from. |
SSLSocketFactoryEx.SSLChannelMode |
getSSLChannelMode()
gets the SSL Channel mode for HTTPS calls made by methods in
ADLStoreClient objects
|
void |
modifyAclEntries(String path,
List<AclEntry> aclSpec)
Modify the acl entries for a file or directory.
|
void |
removeAclEntries(String path,
List<AclEntry> aclSpec)
Removes the specified ACL entries from a file or directory.
|
void |
removeAllAcls(String path)
Removes all acl entries from a file or directory.
|
void |
removeDefaultAcls(String path)
removes all default acl entries from a directory.
|
boolean |
rename(String path,
String newName)
rename a file or directory.
|
boolean |
rename(String path,
String newName,
boolean overwrite)
rename a file or directory.
|
void |
setAcl(String path,
List<AclEntry> aclSpec)
Sets the ACLs for a file or directory.
|
void |
setExpiryTime(String path,
ExpiryOption expiryOption,
long expiryTimeMilliseconds)
Sets the expiry time on a file.
|
void |
setOptions(ADLStoreOptions o)
Sets the options to configure the behavior of this client.
|
void |
setOwner(String path,
String owner,
String group)
sets the owning user and group of the file.
|
void |
setPermission(String path,
String octalPermissions)
Sets the permissions of the specified file ro directory.
|
void |
setTimes(String path,
Date atime,
Date mtime)
sets one or both of the times (Modified and Access time) of the file or directory
|
void |
updateToken(AzureADToken token)
update token on existing client.
|
void |
updateToken(String accessToken)
update token on existing client.
|
public static ADLStoreClient createClient(String accountFQDN, AzureADToken token)
ADLStoreClient
object.accountFQDN
- string containing the fully qualified domain name of the account.
e.g., contoso.azuredatalakestore.nettoken
- AzureADToken
object that contains the AAD token to usepublic static ADLStoreClient createClient(String accountFQDN, String accessToken)
ADLStoreClient
object.accountFQDN
- string containing the fully qualified domain name of the account.
e.g., contoso.azuredatalakestore.netaccessToken
- String containing the AAD access token to be usedpublic static ADLStoreClient createClient(String accountFQDN, AccessTokenProvider tokenProvider)
ADLStoreClient
object.accountFQDN
- string containing the fully qualified domain name of the account.
For example, contoso.azuredatalakestore.nettokenProvider
- AccessTokenProvider
that can provide the AAD tokenpublic static ADLStoreClient createClient(String accountFQDN, ClientCredsTokenProvider tokenProvider)
ADLStoreClient
object.accountFQDN
- string containing the fully qualified domain name of the account.
For example, contoso.azuredatalakestore.nettokenProvider
- ClientCredsTokenProvider
that can provide the AAD tokenpublic static ADLStoreClient createClient(String accountFQDN, RefreshTokenBasedTokenProvider tokenProvider)
ADLStoreClient
object.accountFQDN
- string containing the fully qualified domain name of the account.
For example, contoso.azuredatalakestore.nettokenProvider
- RefreshTokenBasedTokenProvider
that can provide the AAD tokenpublic static ADLStoreClient createClient(String accountFQDN, UserPasswordTokenProvider tokenProvider)
ADLStoreClient
object.accountFQDN
- string containing the fully qualified domain name of the account.
For example, contoso.azuredatalakestore.nettokenProvider
- UserPasswordTokenProvider
that can provide the AAD tokenpublic static ADLStoreClient createClient(String accountFQDN, DeviceCodeTokenProvider tokenProvider)
ADLStoreClient
object.accountFQDN
- string containing the fully qualified domain name of the account.
For example, contoso.azuredatalakestore.nettokenProvider
- DeviceCodeTokenProvider
that can provide the AAD tokenpublic static ADLStoreClient createClient(String accountFQDN, MsiTokenProvider tokenProvider)
ADLStoreClient
object.accountFQDN
- string containing the fully qualified domain name of the account.
For example, contoso.azuredatalakestore.nettokenProvider
- DeviceCodeTokenProvider
that can provide the AAD tokenpublic ADLFileOutputStream createFile(String path, IfExists mode) throws IOException
overwriteIfExists
is false and the file already exists,
then an exceptionis thrown.
The call returns an ADLFileOutputStream
that can then be written to.path
- full pathname of file to createmode
- IfExists
enum
specifying whether to overwite or throw
an exception if the file already existsADLFileOutputStream
to write toIOException
- ADLException
is thrown if there is an error in creating the filepublic ADLFileOutputStream createFile(String path, IfExists mode, String octalPermission, boolean createParent) throws IOException
overwriteIfExists
is false and the file already exists,
then an exceptionis thrown.
The call returns an ADLFileOutputStream
that can then be written to.path
- full pathname of file to createmode
- IfExists
enum
specifying whether to overwite or throw
an exception if the file already existsoctalPermission
- permissions for the file, as octal digits (For Example, "755"
)createParent
- if true, then parent directories of the file are created if they are missing.ADLFileOutputStream
to write toIOException
- ADLException
is thrown if there is an error in creating the filepublic ADLFileInputStream getReadStream(String path) throws IOException
ADLFileInputStream
to read the file
contents from.path
- full pathname of file to readADLFileInputStream
to read the file contents from.IOException
- ADLException
is thrown if there is an error in opening the filepublic ADLFileOutputStream getAppendStream(String path) throws IOException
path
- full pathname of file to append toADLFileOutputStream
to write to. The contents written to this stream
will be appended to the file.IOException
- ADLException
is thrown if there is an error in opening the file for appendpublic boolean concatenateFiles(String path, List<String> fileList) throws IOException
path
- full pathname of the destination to concatenate files intofileList
- List
of strings containing full pathnames of the files to concatenate.
Cannot be null or empty.IOException
- ADLException
is thrown if there is an error in concatenating filespublic void setExpiryTime(String path, ExpiryOption expiryOption, long expiryTimeMilliseconds) throws IOException
path
- path of the file to set expiry onexpiryOption
- ExpiryOption
value specifying how to interpret the passed in timeexpiryTimeMilliseconds
- time duration in millisecondsIOException
- if there is an error in setting file expirypublic List<DirectoryEntry> enumerateDirectory(String path) throws IOException
List
of DirectoryEntry
objects,
one per file or directory in the specified directory.path
- full pathname of directory to enumerateList
<DirectoryEntry
> containing the contents of the directoryIOException
- ADLException
is thrown if there is an errorpublic List<DirectoryEntry> enumerateDirectory(String path, UserGroupRepresentation oidOrUpn) throws IOException
List
of DirectoryEntry
objects,
one per file or directory in the specified directory.path
- full pathname of directory to enumerateoidOrUpn
- UserGroupRepresentation
enum specifying whether to return user and group information as
OID or UPNList
<DirectoryEntry
> containing the contents of the directoryIOException
- ADLException
is thrown if there is an errorpublic List<DirectoryEntry> enumerateDirectory(String path, int maxEntriesToRetrieve) throws IOException
List
of DirectoryEntry
objects,
one per file or directory in the specified directory.
To avoid overwhelming the client or the server, the call may return a partial list, in which case
the caller should make the call again with the last entry from the returned list specified as the
startAfter
parameter of the next call.
path
- full pathname of directory to enumeratemaxEntriesToRetrieve
- maximum number of entries to retrieve. Note that server can limit the
number of entries retrieved to a number smaller than the number specified.List
<DirectoryEntry
> containing the contents of the directoryIOException
- ADLException
is thrown if there is an errorpublic List<DirectoryEntry> enumerateDirectory(String path, String startAfter) throws IOException
List
of DirectoryEntry
objects,
one per file or directory in the specified directory.
To avoid overwhelming the client or the server, the call may return a partial list, in which case
the caller should make the call again with the last entry from the returned list specified as the
startAfter
parameter of the next call.
path
- full pathname of directory to enumeratestartAfter
- the filename after which to begin enumerationList
<DirectoryEntry
> containing the contents of the directoryIOException
- ADLException
is thrown if there is an errorpublic List<DirectoryEntry> enumerateDirectory(String path, int maxEntriesToRetrieve, String startAfter) throws IOException
List
of DirectoryEntry
objects,
one per file or directory in the specified directory.
To avoid overwhelming the client or the server, the call may return a partial list, in which case
the caller should make the call again with the last entry from the returned list specified as the
startAfter
parameter of the next call.
path
- full pathname of directory to enumeratemaxEntriesToRetrieve
- maximum number of entries to retrieve. Note that server can limit the
number of entries retrieved to a number smaller than the number specified.startAfter
- the filename after which to begin enumerationList
<DirectoryEntry
> containing the contents of the directoryIOException
- ADLException
is thrown if there is an errorpublic List<DirectoryEntry> enumerateDirectory(String path, String startAfter, String endBefore) throws IOException
List
of DirectoryEntry
objects,
one per file or directory in the specified directory.
To avoid overwhelming the client or the server, the call may return a partial list, in which case
the caller should make the call again with the last entry from the returned list specified as the
startAfter
parameter of the next call.
path
- full pathname of directory to enumeratestartAfter
- the filename after which to begin enumerationendBefore
- the filename before which to end the enumerationList
<DirectoryEntry
> containing the contents of the directoryIOException
- ADLException
is thrown if there is an errorpublic List<DirectoryEntry> enumerateDirectory(String path, int maxEntriesToRetrieve, String startAfter, String endBefore) throws IOException
List
of DirectoryEntry
objects,
one per file or directory in the specified directory.
To avoid overwhelming the client or the server, the call may return a partial list, in which case
the caller should make the call again with the last entry from the returned list specified as the
startAfter
parameter of the next call.
path
- full pathname of directory to enumeratemaxEntriesToRetrieve
- maximum number of entries to retrieve. Note that server can limit the
number of entries retrieved to a number smaller than the number specified.startAfter
- the filename after which to begin enumerationendBefore
- the filename before which to end the enumerationList
<DirectoryEntry
> containing the contents of the directoryIOException
- ADLException
is thrown if there is an errorpublic List<DirectoryEntry> enumerateDirectory(String path, int maxEntriesToRetrieve, String startAfter, String endBefore, UserGroupRepresentation oidOrUpn) throws IOException
List
of DirectoryEntry
objects,
one per file or directory in the specified directory.
To avoid overwhelming the client or the server, the call may return a partial list, in which case
the caller should make the call again with the last entry from the returned list specified as the
startAfter
parameter of the next call.
path
- full pathname of directory to enumeratemaxEntriesToRetrieve
- maximum number of entries to retrieve. Note that server can limit the
number of entries retrieved to a number smaller than the number specified.startAfter
- the filename after which to begin enumerationendBefore
- the filename before which to end the enumerationoidOrUpn
- UserGroupRepresentation
enum specifying whether to return user and group information as
OID or UPNList
<DirectoryEntry
> containing the contents of the directoryIOException
- ADLException
is thrown if there is an errorpublic boolean createDirectory(String path) throws IOException
path
- full pathname of directory to createtrue
if the call succeededIOException
- ADLException
is thrown if there is an errorpublic boolean createDirectory(String path, String octalPermission) throws IOException
path
- full pathname of directory to createoctalPermission
- permissions for the directory, as octal digits (for example, "755"
). Can be null.true
if the call succeededIOException
- ADLException
is thrown if there is an errorpublic boolean deleteRecursive(String path) throws IOException
path
- full pathname of directory to deletetrue
if the call succeededIOException
- ADLException
is thrown if there is an errorpublic void removeDefaultAcls(String path) throws IOException
path
- full pathname of directory to remove default ACLs fromIOException
- ADLException
is thrown if there is an errorpublic boolean rename(String path, String newName) throws IOException
path
- full pathname of file or directory to renamenewName
- the new name of the filetrue
if the call succeededIOException
- ADLException
is thrown if there is an errorpublic boolean rename(String path, String newName, boolean overwrite) throws IOException
path
- full pathname of file or directory to renamenewName
- the new name of the file/directoryoverwrite
- overwrite destination if it already exists. If the
destination is a non-empty directory, then the call
fails rather than overwrite the directory.true
if the call succeededIOException
- ADLException
is thrown if there is an errorpublic boolean delete(String path) throws IOException
path
- full pathname of file or directory to deletetrue
if the call succeededIOException
- ADLException
is thrown if there is an errorpublic DirectoryEntry getDirectoryEntry(String path) throws IOException
path
- full pathname of file or directory to get directory entry forDirectoryEntry
containing the metadata for the file/directoryIOException
- ADLException
is thrown if there is an errorpublic DirectoryEntry getDirectoryEntry(String path, UserGroupRepresentation oidOrUpn) throws IOException
path
- full pathname of file or directory to get directory entry foroidOrUpn
- UserGroupRepresentation
enum specifying whether to return user and group information as
OID or UPNDirectoryEntry
containing the metadata for the file/directoryIOException
- ADLException
is thrown if there is an errorpublic ContentSummary getContentSummary(String path) throws IOException
path
- full pathname of file or directory to queryContentSummary
containing summary of information about the file or directoryIOException
- ADLException
is thrown if there is an errorpublic void setOwner(String path, String owner, String group) throws IOException
null
, then they are not changed.
It is illegal to pass both user and owner as null
.path
- full pathname of file or directory to set owner/group forowner
- the ID of the user, or null
group
- the ID of the group, or null
IOException
- ADLException
is thrown if there is an errorpublic void setTimes(String path, Date atime, Date mtime) throws IOException
path
- full pathname of file or directory to set times foratime
- Access time as a longmtime
- Modified time as a longIOException
- ADLException
is thrown if there is an errorpublic boolean checkExists(String filename) throws IOException
filename
- path to checkIOException
- thrown on errorpublic void createEmptyFile(String filename) throws IOException
filename
- name of file to create.IOException
- thrown on errorpublic void setPermission(String path, String octalPermissions) throws IOException
setAcl
call.path
- full pathname of file or directory to set permissions foroctalPermissions
- the permissions to set, in unix octal form. For example, '644'.IOException
- ADLException
is thrown if there is an errorpublic boolean checkAccess(String path, String rwx) throws IOException
"r-x"
).path
- full pathname of file or directory to check access forrwx
- the permission to check for, in rwx string form. The call returns true if the caller has
all the requested permissions. For example, specifying "r-x"
succeeds if the caller has
read and execute permissions.IOException
- ADLException
is thrown if there is an errorpublic void modifyAclEntries(String path, List<AclEntry> aclSpec) throws IOException
path
- full pathname of file or directory to change ACLs foraclSpec
- List
of AclEntry
s, containing the entries to add or modifyIOException
- ADLException
is thrown if there is an errorpublic void setAcl(String path, List<AclEntry> aclSpec) throws IOException
path
- full pathname of file or directory to set ACLs foraclSpec
- List
of AclEntry
s, containing the entries to setIOException
- ADLException
is thrown if there is an errorpublic void removeAclEntries(String path, List<AclEntry> aclSpec) throws IOException
path
- full pathname of file or directory to remove ACLs foraclSpec
- List
of AclEntry
s to removeIOException
- ADLException
is thrown if there is an errorpublic void removeAllAcls(String path) throws IOException
path
- full pathname of file or directory to remove ACLs forIOException
- ADLException
is thrown if there is an errorpublic AclStatus getAclStatus(String path) throws IOException
path
- full pathname of file or directory to queryAclStatus
object containing the ACL and permission infoIOException
- ADLException
is thrown if there is an errorpublic AclStatus getAclStatus(String path, UserGroupRepresentation oidOrUpn) throws IOException
path
- full pathname of file or directory to queryoidOrUpn
- UserGroupRepresentation
enum specifying whether to return user and group information as
OID or UPNAclStatus
object containing the ACL and permission infoIOException
- ADLException
is thrown if there is an errorpublic void setOptions(ADLStoreOptions o) throws IOException
o
- ADLStoreOptions
object that specifies the options to setIOException
- if there is an error in creating the file path prefix specifiedpublic void updateToken(AzureADToken token)
token
- The OAuth2 Tokenpublic void updateToken(String accessToken)
accessToken
- The AAD Token stringpublic SSLSocketFactoryEx.SSLChannelMode getSSLChannelMode()
public int getDefaultTimeout()
public IOException getExceptionFromResponse(OperationResponse resp, String defaultMessage)
ADLException
from OperationResponse
.resp
- the OperationResponse
to convert to exceptiondefaultMessage
- message to use if the inner exception does not have a text message.ADLException
, or null
if the resp.successful
is true
Copyright © 2019 Microsoft Corporation. All rights reserved.