Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ boolean handleStorageException(
String command,
String queryId,
SnowflakeGCSClient gcsClient)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException;
throws SnowflakeSQLException;

void shutdown();
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class GCSAccessStrategyAwsSdk implements GCSAccessStrategy {
private static final SFLogger logger = SFLoggerFactory.getLogger(GCSAccessStrategyAwsSdk.class);
private final AmazonS3 amazonClient;

GCSAccessStrategyAwsSdk(StageInfo stage)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
GCSAccessStrategyAwsSdk(StageInfo stage) throws SnowflakeSQLException {
String accessToken = (String) stage.getCredentials().get("GCS_ACCESS_TOKEN");

Optional<String> oEndpoint = stage.gcsCustomEndpoint();
Expand Down Expand Up @@ -223,7 +222,7 @@ public boolean handleStorageException(
String command,
String queryId,
SnowflakeGCSClient gcsClient)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
if (ex instanceof AmazonClientException) {
logger.debug("GCSAccessStrategyAwsSdk: " + ex.getMessage());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public boolean handleStorageException(
String command,
String queryId,
SnowflakeGCSClient gcsClient)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
if (ex instanceof StorageException) {
// NOTE: this code path only handle Access token based operation,
// presigned URL is not covered. Presigned Url do not raise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/
package net.snowflake.ingest.streaming.internal.fileTransferAgent;

import static net.snowflake.client.core.HttpUtil.setSessionlessProxyForAzure;
import static net.snowflake.ingest.streaming.internal.fileTransferAgent.ErrorCode.CLOUD_STORAGE_CREDENTIALS_EXPIRED;
import static net.snowflake.ingest.streaming.internal.fileTransferAgent.StorageClientUtil.setSessionlessProxyForAzure;
import static net.snowflake.ingest.streaming.internal.fileTransferAgent.StorageClientUtil.systemGetProperty;

import com.fasterxml.jackson.core.JsonFactory;
Expand Down Expand Up @@ -80,8 +80,7 @@ private SnowflakeAzureClient() {}
* required to decrypt/encrypt content in stage
*/
public static SnowflakeAzureClient createSnowflakeAzureClient(
StageInfo stage, RemoteStoreFileEncryptionMaterial encMat)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
StageInfo stage, RemoteStoreFileEncryptionMaterial encMat) throws SnowflakeSQLException {
logger.debug(
"Initializing Snowflake Azure client with encryption: {}",
encMat != null ? "true" : "false");
Expand All @@ -102,9 +101,7 @@ public static SnowflakeAzureClient createSnowflakeAzureClient(
* @throws IllegalArgumentException when invalid credentials are used
*/
private void setupAzureClient(StageInfo stage, RemoteStoreFileEncryptionMaterial encMat)
throws IllegalArgumentException,
SnowflakeSQLException,
net.snowflake.client.jdbc.SnowflakeSQLException {
throws IllegalArgumentException, SnowflakeSQLException {
// Save the client creation parameters so that we can reuse them,
// to reset the Azure client.
this.stageInfo = stage;
Expand Down Expand Up @@ -189,8 +186,7 @@ public int getEncryptionKeySize() {
* @throws SnowflakeSQLException failure to renew the client
*/
@Override
public void renew(Map<?, ?> stageCredentials)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
public void renew(Map<?, ?> stageCredentials) throws SnowflakeSQLException {
logger.debug("Renewing the Azure client");
stageInfo.setCredentials(stageCredentials);
setupAzureClient(stageInfo, encMat);
Expand Down Expand Up @@ -302,7 +298,7 @@ public void download(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
Stopwatch stopwatch = new Stopwatch();
stopwatch.start();
String localFilePath = localLocation + localFileSep + destFileName;
Expand Down Expand Up @@ -416,7 +412,7 @@ public InputStream downloadToStream(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
logger.debug(
"Staring download of file from Azure stage path: {} to input stream", stageFilePath);
Stopwatch stopwatch = new Stopwatch();
Expand Down Expand Up @@ -528,7 +524,7 @@ public void upload(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
logger.info(
StorageHelper.getStartUploadLog(
"Azure", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName));
Expand Down Expand Up @@ -649,7 +645,7 @@ public void upload(
@Override
public void handleStorageException(
Exception ex, int retryCount, String operation, String command, String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
handleAzureException(ex, retryCount, operation, command, this, queryId);
}

Expand Down Expand Up @@ -755,7 +751,7 @@ private static void handleAzureException(
String command,
SnowflakeAzureClient azClient,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {

// no need to retry if it is invalid key exception
if (ex.getCause() instanceof InvalidKeyException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ private SnowflakeGCSClient() {}
* required to decrypt/encrypt content in stage
*/
public static SnowflakeGCSClient createSnowflakeGCSClient(
StageInfo stage, RemoteStoreFileEncryptionMaterial encMat)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
StageInfo stage, RemoteStoreFileEncryptionMaterial encMat) throws SnowflakeSQLException {
logger.debug(
"Initializing Snowflake GCS client with encryption: {}", encMat != null ? "true" : "false");
SnowflakeGCSClient sfGcsClient = new SnowflakeGCSClient();
Expand Down Expand Up @@ -137,8 +136,7 @@ public boolean requirePresignedUrl() {
}

@Override
public void renew(Map<?, ?> stageCredentials)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
public void renew(Map<?, ?> stageCredentials) throws SnowflakeSQLException {
logger.debug("Renewing the Snowflake GCS client");
stageInfo.setCredentials(stageCredentials);
setupGCSClient(stageInfo, encMat);
Expand Down Expand Up @@ -196,7 +194,7 @@ public void download(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
String localFilePath = localLocation + localFileSep + destFileName;
logger.debug(
"Staring download of file from GCS stage path: {} to {}", stageFilePath, localFilePath);
Expand Down Expand Up @@ -364,7 +362,7 @@ public InputStream downloadToStream(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
logger.debug("Staring download of file from GCS stage path: {} to input stream", stageFilePath);
int retryCount = 0;
Stopwatch stopwatch = new Stopwatch();
Expand Down Expand Up @@ -531,7 +529,7 @@ public void uploadWithPresignedUrlWithoutConnection(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
logger.info(
StorageHelper.getStartUploadLog(
"GCS", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName));
Expand Down Expand Up @@ -632,7 +630,7 @@ public void upload(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
logger.info(
StorageHelper.getStartUploadLog(
"GCS", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName));
Expand Down Expand Up @@ -783,7 +781,7 @@ private void uploadWithDownScopedToken(
long contentLength,
InputStream content,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
logger.debug("Uploading file {} to bucket {}", destFileName, remoteStorageLocation);
try {
this.gcsAccessStrategy.uploadWithDownScopedToken(
Expand Down Expand Up @@ -834,7 +832,7 @@ private void uploadWithPresignedUrl(
String presignedUrl,
net.snowflake.client.core.HttpClientSettingsKey ocspAndProxyKey,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
try {
URIBuilder uriBuilder = new URIBuilder(presignedUrl);

Expand Down Expand Up @@ -991,7 +989,7 @@ private SFPair<InputStream, Boolean> createUploadStream(
@Override
public void handleStorageException(
Exception ex, int retryCount, String operation, String command, String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
// no need to retry if it is invalid key exception
if (ex.getCause() instanceof InvalidKeyException) {
// Most likely cause is that the unlimited strength policy files are not installed
Expand Down Expand Up @@ -1126,9 +1124,7 @@ public String getDigestMetadata(StorageObjectMetadata meta) {
* @throws IllegalArgumentException when invalid credentials are used
*/
private void setupGCSClient(StageInfo stage, RemoteStoreFileEncryptionMaterial encMat)
throws IllegalArgumentException,
SnowflakeSQLException,
net.snowflake.client.jdbc.SnowflakeSQLException {
throws IllegalArgumentException, SnowflakeSQLException {
// Save the client creation parameters so that we can reuse them,
// to reset the GCS client.
this.stageInfo = stage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public SnowflakeS3Client(
String stageEndPoint,
boolean isClientSideEncrypted,
boolean useS3RegionalUrl)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
logger.debug(
"Initializing Snowflake S3 client with encryption: {}, client side encrypted: {}",
encMat != null,
Expand All @@ -134,7 +134,7 @@ private void setupSnowflakeS3Client(
String stageRegion,
String stageEndPoint,
boolean isClientSideEncrypted)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
// Save the client creation parameters so that we can reuse them,
// to reset the AWS client. We won't save the awsCredentials since
// we will be refreshing that, every time we reset the AWS client
Expand Down Expand Up @@ -263,8 +263,7 @@ public int getEncryptionKeySize() {
* @throws SnowflakeSQLException if any error occurs
*/
@Override
public void renew(Map<?, ?> stageCredentials)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
public void renew(Map<?, ?> stageCredentials) throws SnowflakeSQLException {
logger.debug("Renewing the Snowflake S3 client");
// We renew the client with fresh credentials and with its original parameters
setupSnowflakeS3Client(
Expand Down Expand Up @@ -324,7 +323,7 @@ public void download(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
Stopwatch stopwatch = new Stopwatch();
stopwatch.start();
String localFilePath = localLocation + localFileSep + destFileName;
Expand Down Expand Up @@ -445,7 +444,7 @@ public InputStream downloadToStream(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
logger.debug("Staring download of file from S3 stage path: {} to input stream", stageFilePath);
Stopwatch stopwatch = new Stopwatch();
stopwatch.start();
Expand Down Expand Up @@ -542,7 +541,7 @@ public void upload(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
logger.info(
StorageHelper.getStartUploadLog(
"S3", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName));
Expand Down Expand Up @@ -763,7 +762,7 @@ private SFPair<InputStream, Boolean> createUploadStream(
@Override
public void handleStorageException(
Exception ex, int retryCount, String operation, String command, String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
handleS3Exception(ex, retryCount, operation, command, this, queryId);
}

Expand All @@ -774,7 +773,7 @@ private static void handleS3Exception(
String command,
SnowflakeS3Client s3Client,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
// no need to retry if it is invalid key exception
if (ex.getCause() instanceof InvalidKeyException) {
// Most likely cause is that the unlimited strength policy files are not installed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ default boolean requirePresignedUrl() {
* @param stageCredentials a Map (as returned by GS) which contains the new credential properties
* @throws SnowflakeSQLException failure to renew the storage client
*/
void renew(Map<?, ?> stageCredentials)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException;
void renew(Map<?, ?> stageCredentials) throws SnowflakeSQLException;

/** shuts down the client */
void shutdown();
Expand Down Expand Up @@ -103,7 +102,7 @@ default void download(
String stageFilePath,
String stageRegion,
String presignedUrl)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
download(
command,
localLocation,
Expand Down Expand Up @@ -140,7 +139,7 @@ void download(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException;
throws SnowflakeSQLException;

/**
* @deprecated
Expand All @@ -153,7 +152,7 @@ default InputStream downloadToStream(
String stageFilePath,
String stageRegion,
String presignedUrl)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
return downloadToStream(
command,
parallelism,
Expand Down Expand Up @@ -185,7 +184,7 @@ InputStream downloadToStream(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException;
throws SnowflakeSQLException;

/**
* @deprecated
Expand All @@ -203,7 +202,7 @@ default void upload(
StorageObjectMetadata meta,
String stageRegion,
String presignedUrl)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
upload(
command,
parallelism,
Expand Down Expand Up @@ -249,7 +248,7 @@ void upload(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException;
throws SnowflakeSQLException;

/**
* @deprecated
Expand All @@ -268,7 +267,7 @@ default void uploadWithPresignedUrlWithoutConnection(
StorageObjectMetadata meta,
String stageRegion,
String presignedUrl)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
uploadWithPresignedUrlWithoutConnection(
networkTimeoutInMilli,
ocspModeAndProxyKey,
Expand Down Expand Up @@ -304,7 +303,7 @@ default void uploadWithPresignedUrlWithoutConnection(
String stageRegion,
String presignedUrl,
String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
throws SnowflakeSQLException {
if (!requirePresignedUrl()) {
throw new SnowflakeSQLLoggedException(
queryId,
Expand All @@ -322,8 +321,7 @@ default void uploadWithPresignedUrlWithoutConnection(
*/
@Deprecated
default void handleStorageException(
Exception ex, int retryCount, String operation, String command)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException {
Exception ex, int retryCount, String operation, String command) throws SnowflakeSQLException {
handleStorageException(ex, retryCount, operation, command, null);
}

Expand All @@ -340,7 +338,7 @@ default void handleStorageException(
*/
void handleStorageException(
Exception ex, int retryCount, String operation, String command, String queryId)
throws SnowflakeSQLException, net.snowflake.client.jdbc.SnowflakeSQLException;
throws SnowflakeSQLException;

/**
* Returns the material descriptor key
Expand Down
Loading
Loading