Class EncryptionEnforcingFileSystem
- All Implemented Interfaces:
TrinoFileSystem
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateDirectory(Location location) Creates the specified directory and any parent directories that do not exist.createTemporaryDirectory(Location targetPath, String temporaryPrefix, String relativePrefix) Creates a temporary directory for the target path.voiddeleteDirectory(Location location) Deletes all files and directories within the specified directory recursively, and deletes the directory itself.voiddeleteFile(Location location) Deletes the specified file.voiddeleteFiles(Collection<Location> locations) Delete specified files.directoryExists(Location location) Checks if a directory exists at the specified location.encryptedPreSignedUri(Location location, io.airlift.units.Duration ttl, EncryptionKey key) Returns the direct encrypted pre-signed URI location for the given storage location.listDirectories(Location location) Lists all directories that are direct descendants of the specified directory.Lists all files within the specified directory recursively.newEncryptedInputFile(Location location, long length, EncryptionKey key) Creates an encrypted TrinoInputFile with a predeclared length which can be used to read the file encrypted data.newEncryptedInputFile(Location location, long length, Instant lastModified, EncryptionKey key) Creates an encrypted TrinoInputFile with a predeclared length and lastModifiedTime which can be used to read the encrypted file data.newEncryptedInputFile(Location location, EncryptionKey key) Creates an encrypted TrinoInputFile which can be used to read the encrypted file data.newEncryptedOutputFile(Location location, EncryptionKey key) Creates an encrypted TrinoOutputFile which can be used to create or overwrite the file.newInputFile(Location location) Creates a TrinoInputFile which can be used to read the file data.newInputFile(Location location, long length) Creates a TrinoInputFile with a predeclared length which can be used to read the file data.newInputFile(Location location, long length, Instant lastModified) Creates a TrinoInputFile with a predeclared length and lastModifiedTime which can be used to read the file data.newOutputFile(Location location) Creates a TrinoOutputFile which can be used to create or overwrite the file.preSignedUri(Location location, io.airlift.units.Duration ttl) Returns the direct pre-signed URI location for the given storage location.voidrenameDirectory(Location source, Location target) Renames source to target.voidrenameFile(Location source, Location target) Rename source to target without overwriting target.
-
Constructor Details
-
EncryptionEnforcingFileSystem
-
-
Method Details
-
newInputFile
Description copied from interface:TrinoFileSystemCreates a TrinoInputFile which can be used to read the file data. The file location path cannot be empty, and must not end with a slash or whitespace.- Specified by:
newInputFilein interfaceTrinoFileSystem
-
newEncryptedInputFile
Description copied from interface:TrinoFileSystemCreates an encrypted TrinoInputFile which can be used to read the encrypted file data. The file location path cannot be empty, and must not end with a slash or whitespace.- Specified by:
newEncryptedInputFilein interfaceTrinoFileSystem
-
newInputFile
Description copied from interface:TrinoFileSystemCreates a TrinoInputFile with a predeclared length which can be used to read the file data. The length will be returned fromTrinoInputFile.length()and the actual file length will never be checked. The file location path cannot be empty, and must not end with a slash or whitespace.- Specified by:
newInputFilein interfaceTrinoFileSystem
-
newEncryptedInputFile
Description copied from interface:TrinoFileSystemCreates an encrypted TrinoInputFile with a predeclared length which can be used to read the file encrypted data. The length will be returned fromTrinoInputFile.length()and the actual file length will never be checked. The file location path cannot be empty, and must not end with a slash or whitespace.- Specified by:
newEncryptedInputFilein interfaceTrinoFileSystem
-
newInputFile
Description copied from interface:TrinoFileSystemCreates a TrinoInputFile with a predeclared length and lastModifiedTime which can be used to read the file data. The length will be returned fromTrinoInputFile.length()and the actual file length will never be checked. The lastModified will be returned fromTrinoInputFile.lastModified()and the actual file last modified time will never be checked. The file location path cannot be empty, and must not end with a slash or whitespace.- Specified by:
newInputFilein interfaceTrinoFileSystem
-
newEncryptedInputFile
public TrinoInputFile newEncryptedInputFile(Location location, long length, Instant lastModified, EncryptionKey key) Description copied from interface:TrinoFileSystemCreates an encrypted TrinoInputFile with a predeclared length and lastModifiedTime which can be used to read the encrypted file data. The length will be returned fromTrinoInputFile.length()and the actual file length will never be checked. The lastModified will be returned fromTrinoInputFile.lastModified()and the actual file last modified time will never be checked. The file location path cannot be empty, and must not end with a slash or whitespace.- Specified by:
newEncryptedInputFilein interfaceTrinoFileSystem
-
newOutputFile
Description copied from interface:TrinoFileSystemCreates a TrinoOutputFile which can be used to create or overwrite the file. The file location path cannot be empty, and must not end with a slash or whitespace.- Specified by:
newOutputFilein interfaceTrinoFileSystem
-
newEncryptedOutputFile
Description copied from interface:TrinoFileSystemCreates an encrypted TrinoOutputFile which can be used to create or overwrite the file. The file location path cannot be empty, and must not end with a slash or whitespace.- Specified by:
newEncryptedOutputFilein interfaceTrinoFileSystem
-
deleteFile
Description copied from interface:TrinoFileSystemDeletes the specified file. The file location path cannot be empty, and must not end with a slash or whitespace. If the file is a directory, an exception is raised. If the file does not exist, this method is a noop.- Specified by:
deleteFilein interfaceTrinoFileSystem- Throws:
IOException
-
deleteFiles
Description copied from interface:TrinoFileSystemDelete specified files. This operation is not required to be atomic, so if an error occurs, all, some, or, none of the files may be deleted. This operation may be faster than simply looping over the locations as some file systems support batch delete operations natively. If a file does not exist, it is ignored.- Specified by:
deleteFilesin interfaceTrinoFileSystem- Throws:
IOException
-
deleteDirectory
Description copied from interface:TrinoFileSystemDeletes all files and directories within the specified directory recursively, and deletes the directory itself. If the location does not exist, this method is a noop. If the location does not have a path, all files and directories in the file system are deleted.For hierarchical file systems (e.g. HDFS), if the path is not a directory, an exception is raised.
For blob file systems (e.g., S3), if the location does not end with a slash, one is appended, and all blobs that start with that prefix are deleted.
If this operation fails, some, none, or all of the directory contents may have been deleted.
- Specified by:
deleteDirectoryin interfaceTrinoFileSystem- Parameters:
location- the directory to delete- Throws:
IOException
-
renameFile
Description copied from interface:TrinoFileSystemRename source to target without overwriting target. This method is not required to be atomic, but it is required that if an error occurs, the source, target, or both must exist with the data from the source. This operation may or may not preserve the last modified time.For file systems which do not support rename (e.g. S3), this operation fails.
- Specified by:
renameFilein interfaceTrinoFileSystem- Throws:
IOException
-
listFiles
Description copied from interface:TrinoFileSystemLists all files within the specified directory recursively. The location can be empty, listing all files in the file system, otherwise the location must end with a slash. If the location does not exist, an empty iterator is returned.For hierarchical file systems, if the path is not a directory, an exception is raised. For hierarchical file systems, if the path does not reference an existing directory, an empty iterator is returned. For blob file systems, all blobs that start with the location are listed. In the rare case that a blob exists with the exact name of the prefix, it is not included in the results.
The returned FileEntry locations will start with the specified location exactly and are lexicographically sorted (except for local HDFS which has the system-dependant ordering).
- Specified by:
listFilesin interfaceTrinoFileSystem- Parameters:
location- the directory to list- Throws:
IOException
-
directoryExists
Description copied from interface:TrinoFileSystemChecks if a directory exists at the specified location. For all file system types, this returnstrueif the location is empty (the root of the file system) or if any files exist within the directory, as determined byTrinoFileSystem.listFiles(Location). Otherwise:- For hierarchical file systems, this returns
trueif the location is an empty directory, else it returnsfalse. - For non-hierarchical file systems, an
Optional.empty()is returned, indicating that the file system has no concept of an empty directory.
- Specified by:
directoryExistsin interfaceTrinoFileSystem- Parameters:
location- the location to check for a directory- Throws:
IOException
- For hierarchical file systems, this returns
-
createDirectory
Description copied from interface:TrinoFileSystemCreates the specified directory and any parent directories that do not exist. For hierarchical file systems, if the location already exists but is not a directory, or if the directory cannot be created, an exception is raised. This method does nothing for non-hierarchical file systems or if the directory already exists.- Specified by:
createDirectoryin interfaceTrinoFileSystem- Throws:
IOException
-
renameDirectory
Description copied from interface:TrinoFileSystemRenames source to target. An exception is raised if the target already exists, or on non-hierarchical file systems.- Specified by:
renameDirectoryin interfaceTrinoFileSystem- Throws:
IOException
-
listDirectories
Description copied from interface:TrinoFileSystemLists all directories that are direct descendants of the specified directory. If the path is empty, all directories at the root of the file system are returned. Otherwise, the path must end with a slash. If the location does not exist, an empty set is returned.For hierarchical file systems, if the path is not a directory, an exception is raised. For hierarchical file systems, if the path does not reference an existing directory, an empty iterator is returned. For blob file systems, all directories containing blobs that start with the location are listed.
- Specified by:
listDirectoriesin interfaceTrinoFileSystem- Throws:
IOException
-
createTemporaryDirectory
public Optional<Location> createTemporaryDirectory(Location targetPath, String temporaryPrefix, String relativePrefix) throws IOException Description copied from interface:TrinoFileSystemCreates a temporary directory for the target path. The directory will be created using the (possibly absolute) prefix such that the directory can be renamed to the target path. The relative prefix will be used if the target path does not support the temporary prefix (which is typically absolute).The temporary directory is not created for non-hierarchical file systems or for target paths that do not support renaming, and an empty optional is returned.
- Specified by:
createTemporaryDirectoryin interfaceTrinoFileSystem- Throws:
IOException
-
preSignedUri
public Optional<UriLocation> preSignedUri(Location location, io.airlift.units.Duration ttl) throws IOException Description copied from interface:TrinoFileSystemReturns the direct pre-signed URI location for the given storage location. Pre-signed URIs allow for retrieval of the files directly from the storage location. This is useful for large files where the server would be a bottleneck.- Specified by:
preSignedUriin interfaceTrinoFileSystem- Returns:
- the pre-signed URI to the storage location or `Optional.empty()` if pre-signed URI cannot be generated.
- Throws:
IOException
-
encryptedPreSignedUri
public Optional<UriLocation> encryptedPreSignedUri(Location location, io.airlift.units.Duration ttl, EncryptionKey key) throws IOException Description copied from interface:TrinoFileSystemReturns the direct encrypted pre-signed URI location for the given storage location.Pre-signed URIs allow for retrieval of the files directly from the storage location. This is useful for large files where the server would be a bottleneck.
- Specified by:
encryptedPreSignedUriin interfaceTrinoFileSystem- Returns:
- the pre-signed URI to the storage location or `Optional.empty()` if pre-signed URI cannot be generated.
- Throws:
IOException
-
getDelegate
-