From 07bb41c78c565bb67c5a9e4acd03a48acabf3fad Mon Sep 17 00:00:00 2001 From: jason <2353220944@qq.com> Date: Wed, 27 Nov 2024 19:49:23 +0800 Subject: [PATCH] feat: support incremental configuration synchronization client --- .../config/ConfigServiceWithChangeCache.java | 21 +++++++++++-------- changes/changes-2.4.0.md | 2 ++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/config/ConfigServiceWithChangeCache.java b/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/config/ConfigServiceWithChangeCache.java index f1862e6982a..961b08f3b59 100644 --- a/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/config/ConfigServiceWithChangeCache.java +++ b/apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/config/ConfigServiceWithChangeCache.java @@ -54,7 +54,7 @@ public class ConfigServiceWithChangeCache extends ConfigServiceWithCache { private static final Logger logger = LoggerFactory.getLogger(ConfigServiceWithChangeCache.class); - private static final long DEFAULT_EXPIRED_AFTER_ACCESS_IN_SencondS = 10; + private static final long DEFAULT_EXPIRED_AFTER_ACCESS_IN_SENCONDS = 10; private static final String TRACER_EVENT_CHANGE_CACHE_LOAD_KEY = "ConfigChangeCache.LoadFromDBbyKey"; @@ -83,7 +83,7 @@ public void initialize() { private void buildReleaseCache() { CacheBuilder releasesCacheBuilder = CacheBuilder.newBuilder() - .expireAfterAccess(DEFAULT_EXPIRED_AFTER_ACCESS_IN_SencondS, TimeUnit.SECONDS); + .expireAfterAccess(DEFAULT_EXPIRED_AFTER_ACCESS_IN_SENCONDS, TimeUnit.SECONDS); releasesCache = releasesCacheBuilder.build(new CacheLoader>() { @Override @@ -113,21 +113,24 @@ public void handleMessage(ReleaseMessage message, String channel) { message.getMessage())) { return; } - + String messageKey = message.getMessage(); + if (bizConfig.isConfigServiceCacheKeyIgnoreCase()) { + messageKey = messageKey.toLowerCase(); + } + Transaction transaction = Tracer.newTransaction(TRACER_EVENT_CHANGE_CACHE_LOAD, messageKey); try { - String messageKey = message.getMessage(); - if (bizConfig.isConfigServiceCacheKeyIgnoreCase()) { - messageKey = messageKey.toLowerCase(); - } - Tracer.newTransaction(TRACER_EVENT_CHANGE_CACHE_LOAD, messageKey); - List namespaceInfo = ReleaseMessageKeyGenerator.messageToList(messageKey); Release latestRelease = releaseService.findLatestActiveRelease(namespaceInfo.get(0), namespaceInfo.get(1), namespaceInfo.get(2)); releasesCache.put(latestRelease.getReleaseKey(), Optional.ofNullable(latestRelease)); + + transaction.setStatus(Transaction.SUCCESS); } catch (Throwable ex) { + transaction.setStatus(ex); //ignore + } finally { + transaction.complete(); } } diff --git a/changes/changes-2.4.0.md b/changes/changes-2.4.0.md index 3ebe2e98381..80afb80a4be 100644 --- a/changes/changes-2.4.0.md +++ b/changes/changes-2.4.0.md @@ -9,6 +9,8 @@ Apollo 2.4.0 * [Feature support portal restTemplate Client connection pool config](https://github.com/apolloconfig/apollo/pull/5200) * [Feature added the ability for administrators to globally search for Value](https://github.com/apolloconfig/apollo/pull/5182) * [Feature support the observe status access-key for pre-check and logging only](https://github.com/apolloconfig/apollo/pull/5236) +* [Feature support incremental configuration synchronization client](https://github.com/apolloconfig/apollo/pull/5288) + ------------------ All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/15?closed=1)