Skip to content

Commit

Permalink
Remove redundant config after mysql migration (linkedin#2791)
Browse files Browse the repository at this point in the history
Co-authored-by: Sophie Guo <sopguo@sopguo-mn2.linkedin.biz>
  • Loading branch information
SophieGuo410 and Sophie Guo authored May 23, 2024
1 parent 3436c0b commit 6835044
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public void testBadCredentials() throws Exception {
public void testInitCacheFromDisk() throws Exception {
Path accountBackupDir = Paths.get(TestUtils.getTempDir("account-backup")).toAbsolutePath();
mySqlConfigProps.setProperty(BACKUP_DIRECTORY_KEY, accountBackupDir.toString());
mySqlConfigProps.setProperty(BACKUP_DIRECTORY_KEY_NEW, accountBackupDir.toString());

// write test account to backup file
long lastModifiedTime = 100;
Expand Down Expand Up @@ -206,8 +205,7 @@ public void testUpdateAccounts() throws Exception {

@Test
public void testFailover() throws Exception {
String dbInfoJsonString = mySqlConfigProps.getProperty(DB_INFO_NEW);
String dbInfoJsonStringOld = mySqlConfigProps.getProperty(DB_INFO);
String dbInfoJsonString = mySqlConfigProps.getProperty(DB_INFO);
JSONArray dbInfo = new JSONArray(dbInfoJsonString);
JSONObject entry = dbInfo.getJSONObject(0);
DbEndpoint origEndpoint = DbEndpoint.fromJson(entry);
Expand All @@ -220,7 +218,6 @@ public void testFailover() throws Exception {
new DbEndpoint(badUrl, remoteDc, true, origEndpoint.getUsername(), origEndpoint.getPassword());
JSONArray endpointsJson = new JSONArray().put(localGoodEndpoint.toJson()).put(remoteBadEndpoint.toJson());
mySqlConfigProps.setProperty(DB_INFO, endpointsJson.toString());
mySqlConfigProps.setProperty(DB_INFO_NEW, endpointsJson.toString());
mySqlConfigProps.setProperty(ClusterMapConfig.CLUSTERMAP_DATACENTER_NAME, localDc);
mySqlAccountStore = spy(new MySqlAccountStoreFactory(new VerifiableProperties(mySqlConfigProps),
new MetricRegistry()).getMySqlAccountStore());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public MySqlAccountService(AccountServiceMetricsWrapper accountServiceMetricsWra
}
cachedAccountService = new CachedAccountService(mySqlAccountStore,
callSupplierWithException(mySqlAccountStoreFactory::getMySqlAccountStore),
accountServiceMetricsWrapper.getAccountServiceMetrics(), config, notifier, config.backupDirNew, scheduler);
accountServiceMetricsWrapper.getAccountServiceMetrics(), config, notifier, config.backupDir, scheduler);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public MySqlAccountStoreFactory(VerifiableProperties verifiableProperties, Metri
* @throws SQLException
*/
public MySqlAccountStore getMySqlAccountStore() throws SQLException {
Map<String, List<DbEndpoint>> dcToMySqlDBEndpoints = getDbEndpointsPerDC(config.dbInfoNew);
Map<String, List<DbEndpoint>> dcToMySqlDBEndpoints = getDbEndpointsPerDC(config.dbInfo);
// Flatten to List (TODO: does utility method need to return map?)
List<DbEndpoint> dbEndpoints = new ArrayList<>();
dcToMySqlDBEndpoints.values().forEach(dbEndpoints::addAll);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class MySqlAccountServiceTest {

public MySqlAccountServiceTest() throws Exception {
mySqlConfigProps.setProperty(DB_INFO, "");
mySqlConfigProps.setProperty(DB_INFO_NEW, "");
mySqlConfigProps.setProperty(UPDATER_POLLING_INTERVAL_SECONDS, "0");
mySqlConfigProps.setProperty(UPDATE_DISABLED, "false");
mockMySqlAccountStoreFactory = mock(MySqlAccountStoreFactory.class);
Expand All @@ -81,7 +80,6 @@ private MySqlAccountService getAccountService() throws IOException, SQLException
public void testInitCacheFromDisk() throws IOException, SQLException {
Path accountBackupDir = Paths.get(TestUtils.getTempDir("account-backup")).toAbsolutePath();
mySqlConfigProps.setProperty(BACKUP_DIRECTORY_KEY, accountBackupDir.toString());
mySqlConfigProps.setProperty(BACKUP_DIRECTORY_KEY_NEW, accountBackupDir.toString());

// write test account to backup file
long lastModifiedTime = 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@
public class MySqlAccountServiceConfig extends AccountServiceConfig {
public static final String MYSQL_ACCOUNT_SERVICE_PREFIX = "mysql.account.service.";
public static final String DB_INFO = MYSQL_ACCOUNT_SERVICE_PREFIX + "db.info";
public static final String DB_INFO_NEW = MYSQL_ACCOUNT_SERVICE_PREFIX + "db.info.new";
public static final String UPDATER_POLLING_INTERVAL_SECONDS =
MYSQL_ACCOUNT_SERVICE_PREFIX + "updater.polling.interval.seconds";
public static final String UPDATER_SHUT_DOWN_TIMEOUT_MINUTES =
MYSQL_ACCOUNT_SERVICE_PREFIX + "updater.shut.down.timeout.minutes";
public static final String BACKUP_DIRECTORY_KEY = MYSQL_ACCOUNT_SERVICE_PREFIX + "backup.dir";
public static final String BACKUP_DIRECTORY_KEY_NEW = MYSQL_ACCOUNT_SERVICE_PREFIX + "backup.dir.new";
public static final String UPDATE_DISABLED = MYSQL_ACCOUNT_SERVICE_PREFIX + "update.disabled";
private static final String MAX_BACKUP_FILE_COUNT = MYSQL_ACCOUNT_SERVICE_PREFIX + "max.backup.file.count";
public static final String DB_EXECUTE_BATCH_SIZE = MYSQL_ACCOUNT_SERVICE_PREFIX + "db.execute.batch.size";
Expand Down Expand Up @@ -75,10 +73,6 @@ public class MySqlAccountServiceConfig extends AccountServiceConfig {
@Default("")
public final String dbInfo;

@Config(DB_INFO_NEW)
@Default("")
public final String dbInfoNew;

/**
* The time interval in seconds between two consecutive account polling for the background account updater of
* {@code MySqlAccountService}. Setting to 0 will disable it. Default value is 60 seconds.
Expand All @@ -102,14 +96,6 @@ public class MySqlAccountServiceConfig extends AccountServiceConfig {
@Default("")
public final String backupDir;

/**
* The directory on the local machine where account data backups will be stored before updating accounts.
* If this string is empty, backups will be disabled.
*/
@Config(BACKUP_DIRECTORY_KEY_NEW)
@Default("")
public final String backupDirNew;

/**
* The maximum number of local backup files kept in disk. When account service exceeds this count, every time it creates
* a new backup file, it will remove the oldest one.
Expand Down Expand Up @@ -180,8 +166,6 @@ public MySqlAccountServiceConfig(VerifiableProperties verifiableProperties) {
updaterShutDownTimeoutMinutes =
verifiableProperties.getIntInRange(UPDATER_SHUT_DOWN_TIMEOUT_MINUTES, 2, 1, Integer.MAX_VALUE);
backupDir = verifiableProperties.getString(BACKUP_DIRECTORY_KEY, "");
dbInfoNew = verifiableProperties.getString(DB_INFO_NEW);
backupDirNew = verifiableProperties.getString(BACKUP_DIRECTORY_KEY_NEW, "");
updateDisabled = verifiableProperties.getBoolean(UPDATE_DISABLED, false);
maxBackupFileCount = verifiableProperties.getIntInRange(MAX_BACKUP_FILE_COUNT, 10, 1, Integer.MAX_VALUE);
dbExecuteBatchSize = verifiableProperties.getIntInRange(DB_EXECUTE_BATCH_SIZE, 50, 1, Integer.MAX_VALUE);
Expand Down

0 comments on commit 6835044

Please sign in to comment.