Skip to content

Commit

Permalink
log
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-bmikaili committed Sep 4, 2024
1 parent 34968af commit 123e9f7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,24 @@ public SnowflakeStreamingIngestChannelInternal<?> openChannel(OpenChannelRequest
this.channelCache.addChannel(channel);

// Add encryption key to the client map for the table
logger.logInfo(
"Encryption key for table={}, key={}, keyId={}",
response.getTableName(),
response.getEncryptionKey(),
response.getEncryptionKeyId());

logger.logInfo(this.encryptionKeysPerTable.toString());

// print all entries in the map if not null
if (this.encryptionKeysPerTable != null) {
for (Map.Entry<FullyQualifiedTableName, EncryptionKey> entry : this.encryptionKeysPerTable.entrySet()) {
logger.logInfo("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}
}

// print the request and response
logger.logInfo("Request: " + request.toString());
logger.logInfo("Response: " + response.toString());
this.encryptionKeysPerTable.put(
new FullyQualifiedTableName(
request.getDBName(), request.getSchemaName(), request.getTableName()),
Expand All @@ -392,6 +410,8 @@ public SnowflakeStreamingIngestChannelInternal<?> openChannel(OpenChannelRequest
response.getEncryptionKey(),
response.getEncryptionKeyId()));

logger.logInfo("after");

return channel;
} catch (IOException | IngestResponseException e) {
throw new SFException(e, ErrorCode.OPEN_CHANNEL_FAILURE, e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,7 @@
import net.snowflake.ingest.streaming.OpenChannelRequest;
import net.snowflake.ingest.streaming.SnowflakeStreamingIngestClient;
import net.snowflake.ingest.streaming.SnowflakeStreamingIngestClientFactory;
import net.snowflake.ingest.utils.Constants;
import net.snowflake.ingest.utils.ErrorCode;
import net.snowflake.ingest.utils.Pair;
import net.snowflake.ingest.utils.ParameterProvider;
import net.snowflake.ingest.utils.SFException;
import net.snowflake.ingest.utils.SnowflakeURL;
import net.snowflake.ingest.utils.Utils;
import net.snowflake.ingest.utils.*;
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
import org.bouncycastle.operator.OperatorCreationException;
Expand Down Expand Up @@ -1629,9 +1623,12 @@ public void testOpenChannelWithEncryptionKey() throws Exception {
.setTableName("table")
.setOnErrorOption(OpenChannelRequest.OnErrorOption.CONTINUE)
.build();
final Logging logger = new Logging(SnowflakeStreamingIngestClientTest.class);
logger.logInfo("before open");
client.openChannel(request);

FullyQualifiedTableName fqn = new FullyQualifiedTableName("db", "schema", "table");
logger.logInfo("fqn: {}", fqn);
Map<FullyQualifiedTableName, EncryptionKey> keys = client.getEncryptionKeysPerTable();
Assert.assertEquals(1, keys.size());
Assert.assertTrue(keys.containsKey(fqn));
Expand Down

0 comments on commit 123e9f7

Please sign in to comment.