DefaultConsoleDbConfig extends AbstractConfigBean implements ConsoleDbConfig { @Override public Set<String> sentinelCheckWhiteList(boolean disableCache) { if (!disableCache && null != sentinelCheckWhitelistCache && sentinelCheckWhitelistCache.getValue().compareTo(System.currentTimeMillis()) > 0) { return sentinelCheckWhitelistCache.getKey(); } List<ConfigModel> configModels = configService.getActiveSentinelCheckExcludeConfig(); Set<String> whitelist = configModels.stream().map(ConfigModel::getSubKey).collect(Collectors.toSet()); sentinelCheckWhitelistCache = new Pair<>(whitelist, System.currentTimeMillis() + DEFAULT_CACHE_EXPIRED); return whitelist; }  @PostConstruct void postConstruct(); @Override boolean isSentinelAutoProcess(); @Override boolean isAlertSystemOn(); @Override boolean ignoreMigrationSystemAvailability(); @Override boolean shouldSentinelCheck(String cluster, boolean disableCache); @Override Set<String> sentinelCheckWhiteList(boolean disableCache); static final String KEY_SENTINEL_AUTO_PROCESS; static final String KEY_ALERT_SYSTEM_ON; static final String KEY_IGNORE_MIGRATION_SYSTEM_AVAILABILITY; static final String KEY_SENTINEL_CHECK_EXCLUDE; }
@Test public void testSentinelCheckWhiteList() throws DalException { String key = DefaultConsoleDbConfig.KEY_SENTINEL_CHECK_EXCLUDE; String mockCluster1 = "test-cluster1"; String mockCluster2 = "test-cluster2"; String mockCluster3 = "test-cluster3"; configModel.setKey(key); configModel.setSubKey(mockCluster1); service.stopSentinelCheck(configModel, 1); configModel.setSubKey(mockCluster2); service.stopSentinelCheck(configModel, 5); configModel.setSubKey(mockCluster3); service.startSentinelCheck(configModel); Set<String> whitelist = consoleDbConfig.sentinelCheckWhiteList(true); Assert.assertTrue(whitelist.contains(mockCluster1)); Assert.assertTrue(whitelist.contains(mockCluster2)); Assert.assertFalse(whitelist.contains(mockCluster3)); }