Package io.trino.plugin.hive.s3
Class TrinoS3FileSystem
- java.lang.Object
-
- org.apache.hadoop.conf.Configured
-
- org.apache.hadoop.fs.FileSystem
-
- io.trino.plugin.hive.s3.TrinoS3FileSystem
-
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.conf.Configurable,org.apache.hadoop.security.token.DelegationTokenIssuer
public class TrinoS3FileSystem extends org.apache.hadoop.fs.FileSystem
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TrinoS3FileSystem()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.hadoop.fs.FSDataOutputStreamappend(org.apache.hadoop.fs.Path f, int bufferSize, org.apache.hadoop.util.Progressable progress)voidclose()org.apache.hadoop.fs.FSDataOutputStreamcreate(org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.permission.FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, org.apache.hadoop.util.Progressable progress)booleandelete(org.apache.hadoop.fs.Path path, boolean recursive)static StringextractBucketName(URI uri)Helper function used to work around the fact that if you use an S3 bucket with an '_' that java.net.URI behaves differently and sets the host value to null whereas S3 buckets without '_' have a properly set host field.protected StringgetBucketName(URI uri)org.apache.hadoop.fs.FileStatusgetFileStatus(org.apache.hadoop.fs.Path path)static TrinoS3FileSystemStatsgetFileSystemStats()URIgetUri()org.apache.hadoop.fs.PathgetWorkingDirectory()voidinitialize(URI uri, org.apache.hadoop.conf.Configuration conf)static StringkeyFromPath(org.apache.hadoop.fs.Path path)org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus>listFiles(org.apache.hadoop.fs.Path path, boolean recursive)org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus>listFilesByPrefix(org.apache.hadoop.fs.Path prefix, boolean recursive)org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus>listLocatedStatus(org.apache.hadoop.fs.Path path)org.apache.hadoop.fs.FileStatus[]listStatus(org.apache.hadoop.fs.Path path)booleanmkdirs(org.apache.hadoop.fs.Path f, org.apache.hadoop.fs.permission.FsPermission permission)org.apache.hadoop.fs.FSDataInputStreamopen(org.apache.hadoop.fs.Path path, int bufferSize)booleanrename(org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.Path dst)voidsetWorkingDirectory(org.apache.hadoop.fs.Path path)-
Methods inherited from class org.apache.hadoop.fs.FileSystem
access, append, append, appendFile, areSymlinksEnabled, cancelDeleteOnExit, canonicalizeUri, checkPath, clearStatistics, closeAll, closeAllForUGI, completeLocalOutput, concat, copyFromLocalFile, copyFromLocalFile, copyFromLocalFile, copyFromLocalFile, copyToLocalFile, copyToLocalFile, copyToLocalFile, create, create, create, create, create, create, create, create, create, create, create, create, createFile, createNewFile, createNonRecursive, createNonRecursive, createNonRecursive, createPathHandle, createSnapshot, createSnapshot, createSymlink, delete, deleteOnExit, deleteSnapshot, enableSymlinks, exists, fixRelativePart, get, get, get, getAclStatus, getAdditionalTokenIssuers, getAllStatistics, getAllStoragePolicies, getBlockSize, getCanonicalServiceName, getCanonicalUri, getChildFileSystems, getContentSummary, getDefaultBlockSize, getDefaultBlockSize, getDefaultPort, getDefaultReplication, getDefaultReplication, getDefaultUri, getDelegationToken, getFileBlockLocations, getFileBlockLocations, getFileChecksum, getFileChecksum, getFileLinkStatus, getFileSystemClass, getFSofPath, getGlobalStorageStatistics, getHomeDirectory, getInitialWorkingDirectory, getLength, getLinkTarget, getLocal, getName, getNamed, getPathHandle, getQuotaUsage, getReplication, getScheme, getServerDefaults, getServerDefaults, getStatistics, getStatistics, getStatus, getStatus, getStoragePolicy, getStorageStatistics, getTrashRoot, getTrashRoots, getUsed, getUsed, getXAttr, getXAttrs, getXAttrs, globStatus, globStatus, isDirectory, isFile, listCorruptFileBlocks, listLocatedStatus, listStatus, listStatus, listStatus, listStatusBatch, listStatusIterator, listXAttrs, makeQualified, mkdirs, mkdirs, modifyAclEntries, moveFromLocalFile, moveFromLocalFile, moveToLocalFile, newInstance, newInstance, newInstance, newInstanceLocal, open, open, open, primitiveCreate, primitiveMkdir, primitiveMkdir, printStatistics, processDeleteOnExit, removeAcl, removeAclEntries, removeDefaultAcl, removeXAttr, rename, renameSnapshot, resolveLink, resolvePath, setAcl, setDefaultUri, setDefaultUri, setOwner, setPermission, setReplication, setStoragePolicy, setTimes, setVerifyChecksum, setWriteChecksum, setXAttr, setXAttr, startLocalOutput, supportsSymlinks, truncate, unsetStoragePolicy
-
-
-
-
Field Detail
-
S3_USER_AGENT_PREFIX
public static final String S3_USER_AGENT_PREFIX
- See Also:
- Constant Field Values
-
S3_CREDENTIALS_PROVIDER
public static final String S3_CREDENTIALS_PROVIDER
- See Also:
- Constant Field Values
-
S3_SSE_TYPE
public static final String S3_SSE_TYPE
- See Also:
- Constant Field Values
-
S3_SSE_ENABLED
public static final String S3_SSE_ENABLED
- See Also:
- Constant Field Values
-
S3_SSE_KMS_KEY_ID
public static final String S3_SSE_KMS_KEY_ID
- See Also:
- Constant Field Values
-
S3_KMS_KEY_ID
public static final String S3_KMS_KEY_ID
- See Also:
- Constant Field Values
-
S3_ENCRYPTION_MATERIALS_PROVIDER
public static final String S3_ENCRYPTION_MATERIALS_PROVIDER
- See Also:
- Constant Field Values
-
S3_PIN_CLIENT_TO_CURRENT_REGION
public static final String S3_PIN_CLIENT_TO_CURRENT_REGION
- See Also:
- Constant Field Values
-
S3_MULTIPART_MIN_PART_SIZE
public static final String S3_MULTIPART_MIN_PART_SIZE
- See Also:
- Constant Field Values
-
S3_MULTIPART_MIN_FILE_SIZE
public static final String S3_MULTIPART_MIN_FILE_SIZE
- See Also:
- Constant Field Values
-
S3_STAGING_DIRECTORY
public static final String S3_STAGING_DIRECTORY
- See Also:
- Constant Field Values
-
S3_MAX_CONNECTIONS
public static final String S3_MAX_CONNECTIONS
- See Also:
- Constant Field Values
-
S3_SOCKET_TIMEOUT
public static final String S3_SOCKET_TIMEOUT
- See Also:
- Constant Field Values
-
S3_CONNECT_TIMEOUT
public static final String S3_CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
S3_MAX_RETRY_TIME
public static final String S3_MAX_RETRY_TIME
- See Also:
- Constant Field Values
-
S3_MAX_BACKOFF_TIME
public static final String S3_MAX_BACKOFF_TIME
- See Also:
- Constant Field Values
-
S3_MAX_CLIENT_RETRIES
public static final String S3_MAX_CLIENT_RETRIES
- See Also:
- Constant Field Values
-
S3_MAX_ERROR_RETRIES
public static final String S3_MAX_ERROR_RETRIES
- See Also:
- Constant Field Values
-
S3_SSL_ENABLED
public static final String S3_SSL_ENABLED
- See Also:
- Constant Field Values
-
S3_PATH_STYLE_ACCESS
public static final String S3_PATH_STYLE_ACCESS
- See Also:
- Constant Field Values
-
S3_SIGNER_TYPE
public static final String S3_SIGNER_TYPE
- See Also:
- Constant Field Values
-
S3_SIGNER_CLASS
public static final String S3_SIGNER_CLASS
- See Also:
- Constant Field Values
-
S3_ENDPOINT
public static final String S3_ENDPOINT
- See Also:
- Constant Field Values
-
S3_SECRET_KEY
public static final String S3_SECRET_KEY
- See Also:
- Constant Field Values
-
S3_ACCESS_KEY
public static final String S3_ACCESS_KEY
- See Also:
- Constant Field Values
-
S3_SESSION_TOKEN
public static final String S3_SESSION_TOKEN
- See Also:
- Constant Field Values
-
S3_IAM_ROLE
public static final String S3_IAM_ROLE
- See Also:
- Constant Field Values
-
S3_EXTERNAL_ID
public static final String S3_EXTERNAL_ID
- See Also:
- Constant Field Values
-
S3_ACL_TYPE
public static final String S3_ACL_TYPE
- See Also:
- Constant Field Values
-
S3_SKIP_GLACIER_OBJECTS
public static final String S3_SKIP_GLACIER_OBJECTS
- See Also:
- Constant Field Values
-
S3_REQUESTER_PAYS_ENABLED
public static final String S3_REQUESTER_PAYS_ENABLED
- See Also:
- Constant Field Values
-
S3_STREAMING_UPLOAD_ENABLED
public static final String S3_STREAMING_UPLOAD_ENABLED
- See Also:
- Constant Field Values
-
S3_STREAMING_UPLOAD_PART_SIZE
public static final String S3_STREAMING_UPLOAD_PART_SIZE
- See Also:
- Constant Field Values
-
S3_STORAGE_CLASS
public static final String S3_STORAGE_CLASS
- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
public void initialize(URI uri, org.apache.hadoop.conf.Configuration conf) throws IOException
- Overrides:
initializein classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
getUri
public URI getUri()
- Specified by:
getUriin classorg.apache.hadoop.fs.FileSystem
-
getWorkingDirectory
public org.apache.hadoop.fs.Path getWorkingDirectory()
- Specified by:
getWorkingDirectoryin classorg.apache.hadoop.fs.FileSystem
-
setWorkingDirectory
public void setWorkingDirectory(org.apache.hadoop.fs.Path path)
- Specified by:
setWorkingDirectoryin classorg.apache.hadoop.fs.FileSystem
-
listStatus
public org.apache.hadoop.fs.FileStatus[] listStatus(org.apache.hadoop.fs.Path path) throws IOException- Specified by:
listStatusin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
listFiles
public org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus> listFiles(org.apache.hadoop.fs.Path path, boolean recursive)- Overrides:
listFilesin classorg.apache.hadoop.fs.FileSystem
-
listFilesByPrefix
public org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus> listFilesByPrefix(org.apache.hadoop.fs.Path prefix, boolean recursive)
-
listLocatedStatus
public org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus> listLocatedStatus(org.apache.hadoop.fs.Path path)
- Overrides:
listLocatedStatusin classorg.apache.hadoop.fs.FileSystem
-
getFileStatus
public org.apache.hadoop.fs.FileStatus getFileStatus(org.apache.hadoop.fs.Path path) throws IOException- Specified by:
getFileStatusin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
open
public org.apache.hadoop.fs.FSDataInputStream open(org.apache.hadoop.fs.Path path, int bufferSize)- Specified by:
openin classorg.apache.hadoop.fs.FileSystem
-
create
public org.apache.hadoop.fs.FSDataOutputStream create(org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.permission.FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, org.apache.hadoop.util.Progressable progress) throws IOException- Specified by:
createin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
append
public org.apache.hadoop.fs.FSDataOutputStream append(org.apache.hadoop.fs.Path f, int bufferSize, org.apache.hadoop.util.Progressable progress)- Specified by:
appendin classorg.apache.hadoop.fs.FileSystem
-
rename
public boolean rename(org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.Path dst) throws IOException- Specified by:
renamein classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
delete
public boolean delete(org.apache.hadoop.fs.Path path, boolean recursive) throws IOException- Specified by:
deletein classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
mkdirs
public boolean mkdirs(org.apache.hadoop.fs.Path f, org.apache.hadoop.fs.permission.FsPermission permission)- Specified by:
mkdirsin classorg.apache.hadoop.fs.FileSystem
-
keyFromPath
public static String keyFromPath(org.apache.hadoop.fs.Path path)
-
extractBucketName
public static String extractBucketName(URI uri)
Helper function used to work around the fact that if you use an S3 bucket with an '_' that java.net.URI behaves differently and sets the host value to null whereas S3 buckets without '_' have a properly set host field. '_' is only allowed in S3 bucket names in us-east-1.- Parameters:
uri- The URI from which to extract a host value.- Returns:
- The host value where uri.getAuthority() is used when uri.getHost() returns null as long as no UserInfo is present.
- Throws:
IllegalArgumentException- If the bucket cannot be determined from the URI.
-
getFileSystemStats
public static TrinoS3FileSystemStats getFileSystemStats()
-
-