Skip to content
Open
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 @@ -23,6 +23,7 @@ public class AccountStatsMySqlConfig {
public static final String ENABLE_REWRITE_BATCHED_STATEMENT = PREFIX + "enable.rewrite.batched.statements";
public static final String CONNECTION_IDLE_TIMEOUT = PREFIX + "connection.idle.timeout.ms";
public static final String LOCAL_BACKUP_FILE_PATH = PREFIX + "local.backup.file.path";
public final SSLConfig sslConfig;

/**
* Serialized json containing the information about all mysql end points. This information should be of the following form:
Expand Down Expand Up @@ -108,5 +109,6 @@ public AccountStatsMySqlConfig(VerifiableProperties verifiableProperties) {
enableRewriteBatchedStatement = verifiableProperties.getBoolean(ENABLE_REWRITE_BATCHED_STATEMENT, false);
connectionIdleTimeoutMs = verifiableProperties.getLong(CONNECTION_IDLE_TIMEOUT, 60 * 1000);
localBackupFilePath = verifiableProperties.getString(LOCAL_BACKUP_FILE_PATH, "");
sslConfig = new SSLConfig(verifiableProperties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class MysqlRepairRequestsDbConfig {
public static final String DB_INFO = PREFIX + "db.info";
public static final String LOCAL_POOL_SIZE = PREFIX + "local.pool.size";
public static final String LIST_MAX_RESULTS = PREFIX + "list.max.results";
public final SSLConfig sslConfig;

/**
* Serialized json array containing the information about all mysql end points.
Expand All @@ -44,5 +45,6 @@ public MysqlRepairRequestsDbConfig(VerifiableProperties verifiableProperties) {
this.dbInfo = verifiableProperties.getString(DB_INFO);
this.localPoolSize = verifiableProperties.getIntInRange(LOCAL_POOL_SIZE, 5, 1, Integer.MAX_VALUE);
this.listMaxResults = verifiableProperties.getIntInRange(LIST_MAX_RESULTS, 100, 1, Integer.MAX_VALUE);
this.sslConfig = new SSLConfig(verifiableProperties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public AccountStatsStore getAccountStatsStore() throws Exception {

private HikariDataSource buildDataSource(DbEndpoint dbEndpoint) {
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl(dbEndpoint.getUrl());
hikariConfig.setJdbcUrl(dbEndpoint.getUrlWithSSL(accountStatsMySqlConfig.sslConfig));
hikariConfig.setUsername(dbEndpoint.getUsername());
hikariConfig.setPassword(dbEndpoint.getPassword());
hikariConfig.setMaximumPoolSize(accountStatsMySqlConfig.poolSize);
Expand Down
16 changes: 16 additions & 0 deletions ambry-mysql/src/main/java/com/github/ambry/mysql/MySqlUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@ public String getUrl() {
return url;
}

/**
* @return Url of the db with SSL info
*/
public String getUrlWithSSL(SSLConfig sslConfig) {
if (sslConfig == null) {
return url;
}
if (sslMode == null) {
return addSslSettingsToUrl(url, sslConfig, SSLMode.VERIFY_CA);
}
else if (sslMode != null && sslMode != SSLMode.NONE) {
return addSslSettingsToUrl(url, sslConfig, sslMode);
}
return url;
}

/**
* @return Data center of the db
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public MysqlRepairRequestsDb getRepairRequestsDb() {
*/
public HikariDataSource buildDataSource(MySqlUtils.DbEndpoint dbEndpoint) {
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl(dbEndpoint.getUrl());
hikariConfig.setJdbcUrl(dbEndpoint.getUrlWithSSL(config.sslConfig));
hikariConfig.setUsername(dbEndpoint.getUsername());
hikariConfig.setPassword(dbEndpoint.getPassword());
hikariConfig.setMaximumPoolSize(config.localPoolSize);
Expand Down
Loading