Skip to content

Commit

Permalink
ONECOND-2164-Add AppConfig support in Conductor
Browse files Browse the repository at this point in the history
  • Loading branch information
sangeetanadgir committed Feb 3, 2023
1 parent a20238f commit b114811
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,28 @@ public AppConfig(AppConfigDAO appConfigDAO) {
CacheManager cacheManager = CacheManager.getInstance();
appCache = cacheManager.getCache(APP_CACHE);
this.appConfigDAO = appConfigDAO;
try {
initialize();
} catch (Exception e) {
logger.error("Unable to load App Config ", e);
throw new RuntimeException(e);
}
logger = LogManager.getLogger(AppConfig.class);
logger.info("Initialized AppConfig");
}

/**
* Initialize the cache
*
* @return
* @throws Exception
*/
private void initialize() throws Exception {
synchronized (AppConfig.class){
reloadProperties("");
}
}

/**
* Obtain the value for a specified key. Returns null if not found
*
Expand Down Expand Up @@ -125,7 +143,7 @@ public void removeConfig(String key) throws Exception {
public synchronized void reloadProperties(String testKey) throws SQLException {
if (appCache.get(testKey) == null) {
appCache.invalidate();
logger.info("AppConfig testKey " + testKey + ". Invalidating Cache ");
//logger.info("AppConfig testKey " + testKey + ". Invalidating Cache ");
Map<String, String> configValues = appConfigDAO.getConfigs();
configValues.entrySet().forEach(configValue -> appCache.put(configValue.getKey(), StrSubstitutor.replace(configValue.getValue(), System.getenv()), TTL_SECONDS));
}
Expand Down

0 comments on commit b114811

Please sign in to comment.