public class SnowflakeGCSClient extends Object implements SnowflakeStorageClient
Modifier and Type | Method and Description |
---|---|
void |
addDigestMetadata(StorageObjectMetadata meta,
String digest)
Adds digest metadata to the StorageObjectMetadata object
|
void |
addEncryptionMetadata(StorageObjectMetadata meta,
MatDesc matDesc,
byte[] ivData,
byte[] encKeK,
long contentLength)
Adds encryption metadata to the StorageObjectMetadata object
|
static SnowflakeGCSClient |
createSnowflakeGCSClient(StageInfo stage,
net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat,
SFSession session) |
void |
download(SFSession session,
String command,
String localLocation,
String destFileName,
int parallelism,
String remoteStorageLocation,
String stageFilePath,
String stageRegion,
String presignedUrl)
Download a file from remote storage.
|
InputStream |
downloadToStream(SFSession session,
String command,
int parallelism,
String remoteStorageLocation,
String stageFilePath,
String stageRegion,
String presignedUrl)
Download a file from remote storage
|
String |
getDigestMetadata(StorageObjectMetadata meta)
Gets digest metadata to the StorageObjectMetadata object
|
int |
getEncryptionKeySize() |
String |
getMatdescKey()
Returns the material descriptor key
|
int |
getMaxRetries() |
StorageObjectMetadata |
getObjectMetadata(String remoteStorageLocation,
String prefix)
Returns the metadata properties for a remote storage object
|
int |
getRetryBackoffMaxExponent()
Returns the max exponent for multiplying backoff with the power of 2, the value of 4 will give
us 16secs as the max number of time to sleep before retry
|
int |
getRetryBackoffMin() |
void |
handleStorageException(Exception ex,
int retryCount,
String operation,
SFSession session,
String command)
Handles exceptions thrown by the remote storage provider
|
boolean |
isEncrypting() |
StorageObjectSummaryCollection |
listObjects(String remoteStorageLocation,
String prefix)
listObjects gets all the objects in a path
|
void |
renew(Map<?,?> stageCredentials)
Re-creates the encapsulated storage client with a fresh access token
|
boolean |
requirePresignedUrl() |
void |
shutdown()
shuts down the client
|
void |
upload(SFSession session,
String command,
int parallelism,
boolean uploadFromStream,
String remoteStorageLocation,
File srcFile,
String destFileName,
InputStream inputStream,
FileBackedOutputStream fileBackedOutputStream,
StorageObjectMetadata meta,
String stageRegion,
String presignedUrl)
Upload a file/stream to remote storage
|
void |
uploadWithPresignedUrlWithoutConnection(int networkTimeoutInMilli,
HttpClientSettingsKey ocspModeAndProxyKey,
int parallelism,
boolean uploadFromStream,
String remoteStorageLocation,
File srcFile,
String destFileName,
InputStream inputStream,
FileBackedOutputStream fileBackedOutputStream,
StorageObjectMetadata meta,
String stageRegion,
String presignedUrl)
Upload a file (-stream) to remote storage with Pre-signed URL without JDBC session.
|
public static SnowflakeGCSClient createSnowflakeGCSClient(StageInfo stage, net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat, SFSession session) throws SnowflakeSQLException
SnowflakeSQLException
public int getMaxRetries()
getMaxRetries
in interface SnowflakeStorageClient
public int getRetryBackoffMaxExponent()
SnowflakeStorageClient
getRetryBackoffMaxExponent
in interface SnowflakeStorageClient
public int getRetryBackoffMin()
getRetryBackoffMin
in interface SnowflakeStorageClient
public boolean isEncrypting()
isEncrypting
in interface SnowflakeStorageClient
public int getEncryptionKeySize()
getEncryptionKeySize
in interface SnowflakeStorageClient
public boolean requirePresignedUrl()
requirePresignedUrl
in interface SnowflakeStorageClient
public void renew(Map<?,?> stageCredentials) throws SnowflakeSQLException
SnowflakeStorageClient
renew
in interface SnowflakeStorageClient
stageCredentials
- a Map (as returned by GS) which contains the new credential propertiesSnowflakeSQLException
- failure to renew the storage clientpublic void shutdown()
SnowflakeStorageClient
shutdown
in interface SnowflakeStorageClient
public StorageObjectSummaryCollection listObjects(String remoteStorageLocation, String prefix) throws StorageProviderException
listObjects
in interface SnowflakeStorageClient
remoteStorageLocation
- bucket nameprefix
- PathStorageProviderException
public StorageObjectMetadata getObjectMetadata(String remoteStorageLocation, String prefix) throws StorageProviderException
SnowflakeStorageClient
getObjectMetadata
in interface SnowflakeStorageClient
remoteStorageLocation
- location, i.e. bucket for S3prefix
- the prefix/path of the object to retrieveStorageProviderException
- cloud storage provider errorpublic void download(SFSession session, String command, String localLocation, String destFileName, int parallelism, String remoteStorageLocation, String stageFilePath, String stageRegion, String presignedUrl) throws SnowflakeSQLException
download
in interface SnowflakeStorageClient
session
- session objectcommand
- command to download filelocalLocation
- local file pathdestFileName
- destination file nameparallelism
- [ not used by the GCP implementation ]remoteStorageLocation
- remote storage location, i.e. bucket for S3stageFilePath
- stage file pathstageRegion
- region name where the stage persistspresignedUrl
- Credential to use for downloadSnowflakeSQLException
- download failurepublic InputStream downloadToStream(SFSession session, String command, int parallelism, String remoteStorageLocation, String stageFilePath, String stageRegion, String presignedUrl) throws SnowflakeSQLException
downloadToStream
in interface SnowflakeStorageClient
session
- session objectcommand
- command to download fileparallelism
- number of threads for parallel downloadingremoteStorageLocation
- remote storage location, i.e. bucket for s3stageFilePath
- stage file pathstageRegion
- region name where the stage persistspresignedUrl
- Signed credential for downloadSnowflakeSQLException
- when download failurepublic void uploadWithPresignedUrlWithoutConnection(int networkTimeoutInMilli, HttpClientSettingsKey ocspModeAndProxyKey, int parallelism, boolean uploadFromStream, String remoteStorageLocation, File srcFile, String destFileName, InputStream inputStream, FileBackedOutputStream fileBackedOutputStream, StorageObjectMetadata meta, String stageRegion, String presignedUrl) throws SnowflakeSQLException
uploadWithPresignedUrlWithoutConnection
in interface SnowflakeStorageClient
networkTimeoutInMilli
- Network timeout for the uploadocspModeAndProxyKey
- OCSP mode and proxy settings for the upload.parallelism
- number of threads do parallel uploadinguploadFromStream
- true if upload source is streamremoteStorageLocation
- s3 bucket namesrcFile
- source file if not uploading from a streamdestFileName
- file name on remote storage after uploadinputStream
- stream used for uploading if fileBackedOutputStream is nullfileBackedOutputStream
- stream used for uploading if not nullmeta
- object meta datastageRegion
- region name where the stage persistspresignedUrl
- presigned URL for upload. Used by GCP.SnowflakeSQLException
- if upload failedpublic void upload(SFSession session, String command, int parallelism, boolean uploadFromStream, String remoteStorageLocation, File srcFile, String destFileName, InputStream inputStream, FileBackedOutputStream fileBackedOutputStream, StorageObjectMetadata meta, String stageRegion, String presignedUrl) throws SnowflakeSQLException
upload
in interface SnowflakeStorageClient
session
- session objectcommand
- upload commandparallelism
- [ not used by the GCP implementation ]uploadFromStream
- true if upload source is streamremoteStorageLocation
- storage container namesrcFile
- source file if not uploading from a streamdestFileName
- file name on remote storage after uploadinputStream
- stream used for uploading if fileBackedOutputStream is nullfileBackedOutputStream
- stream used for uploading if not nullmeta
- object meta datastageRegion
- region name where the stage persistspresignedUrl
- Credential used for upload of a fileSnowflakeSQLException
- if upload failed even after retrypublic void handleStorageException(Exception ex, int retryCount, String operation, SFSession session, String command) throws SnowflakeSQLException
SnowflakeStorageClient
handleStorageException
in interface SnowflakeStorageClient
ex
- the exception to handleretryCount
- current number of retries, incremented by the caller before each calloperation
- string that indicates the function/operation that was taking place, when the
exception was raised, for example "upload"session
- the current SFSession object used by the clientcommand
- the command attempted at the time of the exceptionSnowflakeSQLException
- exceptions that were not handled, or retried past what the retry
policy allows, are propagatedpublic String getMatdescKey()
getMatdescKey
in interface SnowflakeStorageClient
public void addEncryptionMetadata(StorageObjectMetadata meta, MatDesc matDesc, byte[] ivData, byte[] encKeK, long contentLength)
addEncryptionMetadata
in interface SnowflakeStorageClient
meta
- the storage metadata object to add the encyption info tomatDesc
- the material decriptorivData
- the initialization vectorencKeK
- the key encryption keycontentLength
- the length of the encrypted contentpublic void addDigestMetadata(StorageObjectMetadata meta, String digest)
addDigestMetadata
in interface SnowflakeStorageClient
meta
- the storage metadata object to add the digest todigest
- the digest metadata to addpublic String getDigestMetadata(StorageObjectMetadata meta)
getDigestMetadata
in interface SnowflakeStorageClient
meta
- the metadata object to extract the digest metadata fromCopyright © 2021. All rights reserved.