Skip to content

Commit

Permalink
Allow user to set serverless properties useful for NLB case
Browse files Browse the repository at this point in the history
  • Loading branch information
iggarish committed Jun 3, 2022
1 parent e080dd6 commit 3e71874
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/amazon/redshift/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@ public static Properties parseURL(String url, Properties defaults) {
if(awsRegion == null || awsRegion.length() == 0)
urlProps.setProperty(RedshiftProperty.AWS_REGION.getName(), region);

urlProps.setProperty(RedshiftConnectionImpl.IS_SERVERLESS,"true");
urlProps.setProperty(RedshiftConnectionImpl.SERVERLESS_ACCT_ID,acctId);
urlProps.setProperty(RedshiftProperty.IS_SERVERLESS.getName(),"true");
urlProps.setProperty(RedshiftProperty.SERVERLESS_ACCT_ID.getName(),acctId);
}

}
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/com/amazon/redshift/RedshiftProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,27 @@ public enum RedshiftProperty {
null,
"The name of the Redshift Native Auth Provider"),

/**
* Set true when end point host is for serverless.
* Driver auto detect from the given host.
* For NLB, it won't so user can set explicitly.
* Default value is false.
*/
IS_SERVERLESS("isServerless",
"false",
"Redshift end-point is serverless or provisional."),

/**
* The account ID of the serverless.
* Driver auto detect from the given host.
* For NLB, it won't so user can set explicitly.
* Default value is null.
*
*/
SERVERLESS_ACCT_ID("serverlessAcctId",
null,
"The account ID of the serverless"),

;

private final String name;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/amazon/redshift/core/IamHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ public static Properties setIAMProperties(Properties info, RedshiftJDBCSettings

String authProfile = RedshiftConnectionImpl.getOptionalConnSetting(RedshiftProperty.AUTH_PROFILE.getName(), info);

String isServerless = RedshiftConnectionImpl.getOptionalConnSetting(RedshiftConnectionImpl.IS_SERVERLESS, info);
String isServerless = RedshiftConnectionImpl.getOptionalConnSetting(RedshiftProperty.IS_SERVERLESS.getName(), info);
settings.m_isServerless = isServerless == null ? false : Boolean.valueOf(isServerless);

String clusterId = (!settings.m_isServerless)
? RedshiftConnectionImpl.getRequiredConnSetting(RedshiftProperty.CLUSTER_IDENTIFIER.getName(), info) : null;
String acctId = (settings.m_isServerless)
? RedshiftConnectionImpl.getOptionalConnSetting(RedshiftConnectionImpl.SERVERLESS_ACCT_ID, info) : null;
? RedshiftConnectionImpl.getOptionalConnSetting(RedshiftProperty.SERVERLESS_ACCT_ID.getName(), info) : null;
String awsRegion = RedshiftConnectionImpl.getOptionalConnSetting(RedshiftProperty.AWS_REGION.getName(), info);
String endpointUrl = RedshiftConnectionImpl.getOptionalConnSetting(RedshiftProperty.ENDPOINT_URL.getName(), info);
String stsEndpointUrl = RedshiftConnectionImpl.getOptionalConnSetting(RedshiftProperty.STS_ENDPOINT_URL.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ public class RedshiftConnectionImpl implements BaseConnection {
private static final SQLPermission SQL_PERMISSION_NETWORK_TIMEOUT = new SQLPermission("setNetworkTimeout");

// Internal properties
public static final String IS_SERVERLESS = "isServerless";
public static final String SERVERLESS_ACCT_ID = "serverlessAcctId";

private enum ReadOnlyBehavior {
ignore,
Expand Down

0 comments on commit 3e71874

Please sign in to comment.