Skip to content

Commit

Permalink
add tests, add two-hex-chars on client instead of server, add refresh…
Browse files Browse the repository at this point in the history
…TableInformation call right on registerTable
  • Loading branch information
sfc-gh-hmadan committed Oct 25, 2024
1 parent ca4f534 commit 967d5ae
Show file tree
Hide file tree
Showing 13 changed files with 301 additions and 812 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface IStorageManager {
IStorage getStorage(String fullyQualifiedTableName);

/** Informs the storage manager about a new table that's being ingested into by the client. */
void registerTable(TableRef tableRef, FileLocationInfo locationInfo);
void registerTable(TableRef tableRef);

/**
* Generate a unique blob path and increment the blob sequencer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ class InternalStage implements IStorage {
(SnowflakeFileTransferMetadataWithAge) null,
maxUploadRetries);
Utils.assertStringNotNullOrEmpty("client prefix", clientPrefix);
this.fileLocationInfo = fileLocationInfo;
this.fileTransferMetadataWithAge = createFileTransferMetadataWithAge(fileLocationInfo);
setFileLocationInfo(fileLocationInfo);
}

/**
Expand Down Expand Up @@ -214,8 +213,6 @@ private void putRemote(String fullFilePath, byte[] data, int retryCount)
*/
synchronized SnowflakeFileTransferMetadataWithAge refreshSnowflakeMetadata(boolean force)
throws SnowflakeSQLException, IOException {
logger.logInfo("Refresh Snowflake metadata, client={} force={}", clientName, force);

if (!force
&& fileTransferMetadataWithAge != null
&& fileTransferMetadataWithAge.timestamp.isPresent()
Expand All @@ -224,12 +221,19 @@ synchronized SnowflakeFileTransferMetadataWithAge refreshSnowflakeMetadata(boole
return fileTransferMetadataWithAge;
}

logger.logInfo(
"Refresh Snowflake metadata, client={} force={} tableRef={}", clientName, force, tableRef);

FileLocationInfo location =
this.owningManager.getRefreshedLocation(this.tableRef, Optional.empty());
SnowflakeFileTransferMetadataWithAge metadata = createFileTransferMetadataWithAge(location);
this.fileLocationInfo = location;
this.fileTransferMetadataWithAge = metadata;
return metadata;
setFileLocationInfo(location);
return this.fileTransferMetadataWithAge;
}

private synchronized void setFileLocationInfo(FileLocationInfo fileLocationInfo)
throws SnowflakeSQLException, IOException {
this.fileTransferMetadataWithAge = createFileTransferMetadataWithAge(fileLocationInfo);
this.fileLocationInfo = fileLocationInfo;
}

static SnowflakeFileTransferMetadataWithAge createFileTransferMetadataWithAge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public InternalStage getStorage(String fullyQualifiedTableName) {
* nothing as there's no per-table state yet for FDN tables (that use internal stages).
*/
@Override
public void registerTable(TableRef tableRef, FileLocationInfo locationInfo) {}
public void registerTable(TableRef tableRef) {}

/**
* Gets the latest file location info (with a renewed short-lived access token) for the specified
Expand Down
Loading

0 comments on commit 967d5ae

Please sign in to comment.