exceptionfactory commented on code in PR #7422:
URL: https://github.com/apache/nifi/pull/7422#discussion_r1238472832
##########
nifi-nar-bundles/nifi-snowflake-bundle/nifi-snowflake-services/src/main/java/org/apache/nifi/snowflake/service/StandardSnowflakeIngestManagerProviderService.java:
##########
@@ -161,17 +188,44 @@ public void onEnabled(final ConfigurationContext context)
throws InitializationE
.getValue();
final String pipe =
context.getProperty(PIPE).evaluateAttributeExpressions().getValue();
fullyQualifiedPipeName = database + "." + schema + "." + pipe;
- final PrivateKeyService privateKeyService =
context.getProperty(PRIVATE_KEY_SERVICE)
- .asControllerService(PrivateKeyService.class);
- final PrivateKey privateKey = privateKeyService.getPrivateKey();
-
- final AccountIdentifierFormat accountIdentifierFormat =
AccountIdentifierFormat.forName(context.getProperty(ACCOUNT_IDENTIFIER_FORMAT)
- .getValue());
- final AccountIdentifierFormatParameters parameters =
getAccountIdentifierFormatParameters(context);
- final String account = accountIdentifierFormat.getAccount(parameters);
- final String host = accountIdentifierFormat.getHostname(parameters);
+
+ final String user;
+ final PrivateKey privateKey;
+ final String account;
+ final String accountUrl;
+
+ final SnowflakeConfigurationService configurationService =
context.getProperty(SNOWFLAKE_CONFIGURATION_SERVICE).asControllerService(SnowflakeConfigurationService.class);
+ if (configurationService != null) {
+ final SnowflakeConfiguration configuration =
configurationService.getConfiguration();
+ user = configuration.getUsername();
+ privateKey = configuration.getPrivateKey();
+ account = configuration.getAccount();
+ accountUrl = configuration.getAccountUrl();
+ } else {
+ user =
context.getProperty(USER_NAME).evaluateAttributeExpressions().getValue();
+
+ final PrivateKeyService privateKeyService =
context.getProperty(PRIVATE_KEY_SERVICE).asControllerService(PrivateKeyService.class);
+ privateKey = privateKeyService.getPrivateKey();
+
+ final AccountIdentifierFormat accountIdentifierFormat =
AccountIdentifierFormat.forName(context.getProperty(ACCOUNT_IDENTIFIER_FORMAT).getValue());
+ final AccountIdentifierFormatParameters parameters =
getAccountIdentifierFormatParameters(context);
+ account = accountIdentifierFormat.getAccount(parameters);
+ accountUrl = accountIdentifierFormat.getAccountUrl(parameters);
+ }
+
+ URL url = null;
+ try {
+ url = new URL(accountUrl);
+ } catch (MalformedURLException e) {
+ // url parse failure => handle accountUrl as hostname only
Review Comment:
Perhaps this should be logged at the debug level for potential
troubleshooting?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]