From 68350440150318efdc61498f9d1af8f2143c29df Mon Sep 17 00:00:00 2001 From: sopguo Date: Thu, 23 May 2024 09:29:58 -0700 Subject: [PATCH] Remove redundant config after mysql migration (#2791) Co-authored-by: Sophie Guo --- .../MySqlAccountServiceIntegrationTest.java | 5 +---- .../ambry/account/MySqlAccountService.java | 2 +- .../account/mysql/MySqlAccountStoreFactory.java | 2 +- .../ambry/account/MySqlAccountServiceTest.java | 2 -- .../ambry/config/MySqlAccountServiceConfig.java | 16 ---------------- 5 files changed, 3 insertions(+), 24 deletions(-) diff --git a/ambry-account/src/integration-test/java/com/github/ambry/account/MySqlAccountServiceIntegrationTest.java b/ambry-account/src/integration-test/java/com/github/ambry/account/MySqlAccountServiceIntegrationTest.java index 789c23c30b..fdc269c851 100644 --- a/ambry-account/src/integration-test/java/com/github/ambry/account/MySqlAccountServiceIntegrationTest.java +++ b/ambry-account/src/integration-test/java/com/github/ambry/account/MySqlAccountServiceIntegrationTest.java @@ -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; @@ -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); @@ -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()); diff --git a/ambry-account/src/main/java/com/github/ambry/account/MySqlAccountService.java b/ambry-account/src/main/java/com/github/ambry/account/MySqlAccountService.java index 022202df45..201cf63867 100644 --- a/ambry-account/src/main/java/com/github/ambry/account/MySqlAccountService.java +++ b/ambry-account/src/main/java/com/github/ambry/account/MySqlAccountService.java @@ -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); } /** diff --git a/ambry-account/src/main/java/com/github/ambry/account/mysql/MySqlAccountStoreFactory.java b/ambry-account/src/main/java/com/github/ambry/account/mysql/MySqlAccountStoreFactory.java index b1bc5633b1..fe444720e4 100644 --- a/ambry-account/src/main/java/com/github/ambry/account/mysql/MySqlAccountStoreFactory.java +++ b/ambry-account/src/main/java/com/github/ambry/account/mysql/MySqlAccountStoreFactory.java @@ -58,7 +58,7 @@ public MySqlAccountStoreFactory(VerifiableProperties verifiableProperties, Metri * @throws SQLException */ public MySqlAccountStore getMySqlAccountStore() throws SQLException { - Map> dcToMySqlDBEndpoints = getDbEndpointsPerDC(config.dbInfoNew); + Map> dcToMySqlDBEndpoints = getDbEndpointsPerDC(config.dbInfo); // Flatten to List (TODO: does utility method need to return map?) List dbEndpoints = new ArrayList<>(); dcToMySqlDBEndpoints.values().forEach(dbEndpoints::addAll); diff --git a/ambry-account/src/test/java/com/github/ambry/account/MySqlAccountServiceTest.java b/ambry-account/src/test/java/com/github/ambry/account/MySqlAccountServiceTest.java index ec9c028083..b07a2d9d61 100644 --- a/ambry-account/src/test/java/com/github/ambry/account/MySqlAccountServiceTest.java +++ b/ambry-account/src/test/java/com/github/ambry/account/MySqlAccountServiceTest.java @@ -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); @@ -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; diff --git a/ambry-api/src/main/java/com/github/ambry/config/MySqlAccountServiceConfig.java b/ambry-api/src/main/java/com/github/ambry/config/MySqlAccountServiceConfig.java index a911fb220e..744755d13f 100644 --- a/ambry-api/src/main/java/com/github/ambry/config/MySqlAccountServiceConfig.java +++ b/ambry-api/src/main/java/com/github/ambry/config/MySqlAccountServiceConfig.java @@ -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"; @@ -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. @@ -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. @@ -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);