public class SnowflakeFileTransferAgent extends Object implements SnowflakeFixedView
| Modifier and Type | Class and Description |
|---|---|
static class |
SnowflakeFileTransferAgent.CommandType |
class |
SnowflakeFileTransferAgent.DownloadCommandEncryptionFacade |
class |
SnowflakeFileTransferAgent.DownloadCommandFacade
A class for encapsulating the columns to return for the download command
|
static class |
SnowflakeFileTransferAgent.ResultStatus
Result status enum
|
static class |
SnowflakeFileTransferAgent.UploadColumns
A class for encapsulating the columns to return for the upload command
|
class |
SnowflakeFileTransferAgent.UploadCommandEncryptionFacade |
class |
SnowflakeFileTransferAgent.UploadCommandFacade |
| Modifier and Type | Field and Description |
|---|---|
static String |
SRC_FILE_NAME_FOR_STREAM |
| Constructor and Description |
|---|
SnowflakeFileTransferAgent(String command,
SFSession session,
SFStatement statement) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel() |
List<SnowflakeColumnMetadata> |
describeColumns(SFSession session)
Describe the metadata of a fixed view.
|
boolean |
execute() |
static net.snowflake.client.jdbc.SnowflakeFileTransferAgent.remoteLocation |
extractLocationAndPath(String stageLocationPath)
A small helper for extracting location name and path from full location path
|
SnowflakeFileTransferAgent.CommandType |
getCommandType() |
static Callable<Void> |
getDownloadFileCallable(StageInfo stage,
String srcFilePath,
String localLocation,
Map<String,net.snowflake.client.jdbc.SnowflakeFileTransferAgent.FileMetadata> fileMetadataMap,
SnowflakeStorageClient client,
SFSession session,
String command,
int parallel,
net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat,
String presignedUrl)
A callable that can be executed in a separate thread using executor service.
|
List<net.snowflake.common.core.RemoteStoreFileEncryptionMaterial> |
getEncryptionMaterial() |
List<SnowflakeFileTransferMetadata> |
getFileTransferMetadatas()
This is API function to retrieve the File Transfer Metadatas.
|
List<Object> |
getNextRow() |
Object |
getResultSet() |
Map<String,net.snowflake.common.core.RemoteStoreFileEncryptionMaterial> |
getSrcToMaterialsMap() |
Map<String,String> |
getSrcToPresignedUrlMap() |
Map<?,?> |
getStageCredentials() |
StageInfo |
getStageInfo() |
String |
getStageLocation() |
int |
getTotalRows() |
static Callable<Void> |
getUploadFileCallable(StageInfo stage,
String srcFilePath,
net.snowflake.client.jdbc.SnowflakeFileTransferAgent.FileMetadata metadata,
SnowflakeStorageClient client,
SFSession session,
String command,
InputStream inputStream,
boolean sourceFromStream,
int parallel,
File srcFile,
net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat)
A callable that can be executed in a separate thread using exeuctor service.
|
static void |
renewExpiredToken(SFSession session,
String command,
SnowflakeStorageClient client)
This static method is called when we are handling an expired token exception It retrieves a
fresh token from GS and then calls .renew() on the storage client to refresh itself with the
new token
|
void |
setCompressSourceFromStream(boolean compressSourceFromStream) |
void |
setDestFileNameForStreamSource(String destFileNameForStreamSource) |
void |
setSourceStream(InputStream sourceStream) |
static void |
throwJCEMissingError(String operation,
Exception ex) |
static void |
uploadWithoutConnection(SnowflakeFileTransferConfig config)
Static API function to upload data without JDBC session.
|
public static final String SRC_FILE_NAME_FOR_STREAM
public SnowflakeFileTransferAgent(String command, SFSession session, SFStatement statement) throws SnowflakeSQLException
SnowflakeSQLExceptionpublic StageInfo getStageInfo()
public Map<?,?> getStageCredentials()
public List<net.snowflake.common.core.RemoteStoreFileEncryptionMaterial> getEncryptionMaterial()
public Map<String,net.snowflake.common.core.RemoteStoreFileEncryptionMaterial> getSrcToMaterialsMap()
public String getStageLocation()
public static Callable<Void> getUploadFileCallable(StageInfo stage, String srcFilePath, net.snowflake.client.jdbc.SnowflakeFileTransferAgent.FileMetadata metadata, SnowflakeStorageClient client, SFSession session, String command, InputStream inputStream, boolean sourceFromStream, int parallel, File srcFile, net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat)
The callable does compression if needed and upload the result to the table's staging area.
stage - information about the stagesrcFilePath - source file pathmetadata - file metadataclient - client object used to communicate with c3session - session objectcommand - command stringinputStream - null if upload source is filesourceFromStream - whether upload source is file or streamparallel - number of threads for parallel uploadingsrcFile - source file nameencMat - not null if encryption is requiredpublic static Callable<Void> getDownloadFileCallable(StageInfo stage, String srcFilePath, String localLocation, Map<String,net.snowflake.client.jdbc.SnowflakeFileTransferAgent.FileMetadata> fileMetadataMap, SnowflakeStorageClient client, SFSession session, String command, int parallel, net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat, String presignedUrl)
The callable download files from a stage location to a local location
stage - stage informationsrcFilePath - path that stores the downloaded filelocalLocation - local locationfileMetadataMap - file metadata mapclient - remote store clientsession - session objectcommand - command stringencMat - remote store encryption materialparallel - number of parallel threads for downloadingpresignedUrl - Presigned URL for file downloadpublic List<SnowflakeFileTransferMetadata> getFileTransferMetadatas() throws SnowflakeSQLException
NOTE: It only supports PUT on S3/AZURE/GCS
SnowflakeSQLException - if any error occurspublic boolean execute()
throws SQLException
SQLExceptionpublic void cancel()
public static void uploadWithoutConnection(SnowflakeFileTransferConfig config) throws Exception
NOTE: This function is developed based on getUploadFileCallable().
config - Configuration to upload a file to cloud storageException - if error occurs while data upload.public static void renewExpiredToken(SFSession session, String command, SnowflakeStorageClient client) throws SnowflakeSQLException
session - a session objectcommand - a command to be retriedclient - a Snowflake Storage client objectSnowflakeSQLException - if any error occurspublic static net.snowflake.client.jdbc.SnowflakeFileTransferAgent.remoteLocation extractLocationAndPath(String stageLocationPath)
stageLocationPath - stage locationpublic List<SnowflakeColumnMetadata> describeColumns(SFSession session) throws Exception
describeColumns in interface SnowflakeFixedViewException - failed to construct listpublic List<Object> getNextRow() throws Exception
getNextRow in interface SnowflakeFixedViewExceptionpublic Object getResultSet() throws SnowflakeSQLException
SnowflakeSQLExceptionpublic SnowflakeFileTransferAgent.CommandType getCommandType()
public void setSourceStream(InputStream sourceStream)
public void setDestFileNameForStreamSource(String destFileNameForStreamSource)
public void setCompressSourceFromStream(boolean compressSourceFromStream)
public static void throwJCEMissingError(String operation, Exception ex) throws SnowflakeSQLException
SnowflakeSQLExceptionpublic int getTotalRows()
getTotalRows in interface SnowflakeFixedViewCopyright © 2020. All rights reserved.