You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "slievrly (via GitHub)" <gi...@apache.org> on 2024/03/14 08:33:59 UTC

[PR] optimize: optimize Configuration Cache [incubator-seata]

slievrly opened a new pull request, #6420:
URL: https://github.com/apache/incubator-seata/pull/6420

   <!-- Please make sure you have read and understood the contributing guidelines -->
   
   - [ ] I have registered the PR [changes](../changes).
   
   ### Ⅰ. Describe what this PR did
   
   optimize Configuration Cache
   
   ### Ⅱ. Does this pull request fix one issue?
   <!-- If that, add "fixes #xxx" below in the next line, for example, fixes #97. -->
   
   
   ### Ⅲ. Why don't you add test cases (unit test/integration test)? 
   
   
   ### Ⅳ. Describe how to verify it
   
   
   ### Ⅴ. Special notes for reviews
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527549315


##########
config/seata-config-core/src/main/java/org/apache/seata/config/CachedConfigurationChangeListener.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.config;
+
+public interface CachedConfigurationChangeListener extends ConfigurationChangeListener {
+
+    ConfigurationCache CONFIGURATION_CACHE = ConfigurationCache.getInstance();
+
+    @Override
+    default void afterEvent(ConfigurationChangeEvent event) {
+        ConfigurationChangeListener listener = (ConfigurationChangeListener)CONFIGURATION_CACHE;
+        listener.onProcessEvent(event);

Review Comment:
   > > Design should not be function-oriented but object-oriented; consider design from the perspective of interactive behavior, not at the level of assembling functions. If ConfigurationCache's before and after are defined to be triggered identically, a logical call stack would be: NacosConfiguration.addConfigListener -> event -> listener.beforeEvent -> listener.onChangeEvent -> listener.afterEvent (ConfigurationCache.beforeEvent -> ConfigurationCache.onChangeEvent -> ConfigurationCache.afterEvent)
   > 
   > 我是认为ConfigurationCache不需要再有beforeEvent的相关逻辑了,如果有的话我认为是否未来可能会出现套娃现象? I was thinking that ConfigurationCache doesn't need to have beforeEvent related logic anymore, and if it does do I think there might be nesting in the future?
   
   This is about extendable design; it's not about whether a feature exists or not. If it doesn't exist, you can maintain an empty implementation, and if there is predefined logic, you can add it as needed. I suggest that you should not judge the design solely based on current functionalities. For example, with cache, aspects like secret computing and storage are points that can be extended both before and after.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527553505


##########
config/seata-config-core/src/main/java/org/apache/seata/config/CachedConfigurationChangeListener.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.config;
+
+public interface CachedConfigurationChangeListener extends ConfigurationChangeListener {
+
+    ConfigurationCache CONFIGURATION_CACHE = ConfigurationCache.getInstance();
+
+    @Override
+    default void afterEvent(ConfigurationChangeEvent event) {
+        ConfigurationChangeListener listener = (ConfigurationChangeListener)CONFIGURATION_CACHE;
+        listener.onProcessEvent(event);

Review Comment:
   > > > > CachedConfigurationChangeListener is an instance that holds state.
   > > > 
   > > > 
   > > > Since we must notify ConfigurationCache, and ConfigurationCache also implements ConfigurationChangeListener, why do we need to use it to make it strong, instead of defining it in a member variable? 既然必定要通知到ConfigurationCache,而且ConfigurationCache 也是实现了ConfigurationChangeListener,为什么要在使用使强壮,而不再成员变量中定义好?
   > > 
   > > 
   > > Sorry, I'm unable to understand the logic expressed here.
   > 
   > Why not define it as a ConfigurationChangeListener afterListener = ConfigurationCache.getInstance(); when the member variable is defined, instead of doing the type conversion in afterEvent? 为什么不在成员变量定义的时候就定义为一个ConfigurationChangeListener afterListener = ConfigurationCache.getInstance(); 而是在afterEvent中再进行类型转换?
   
   I understand what you mean. However, this might be related to my personal habits. It can be replaced with one line syntactically, but in reality, it involves two steps. 
   But from a design perspective, I would like to point out a few things. Member variables are intended for internal use within a class to maintain consistency in the architecture. Once converted into an interface here, it means that other methods can only use methods defined by the interface.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#issuecomment-2022168249

   ## [Codecov](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: Patch coverage is `77.50000%` with `9 lines` in your changes are missing coverage. Please review.
   > Project coverage is 50.81%. Comparing base [(`f7fb1f8`)](https://app.codecov.io/gh/apache/incubator-seata/commit/f7fb1f8c746f53c3e70358f4563ce25dbbf8262e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`153d16b`)](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 6 commits behind head on 2.x.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/incubator-seata/pull/6420/graphs/tree.svg?width=650&height=150&src=pr&token=tbmHt2ZfxO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@             Coverage Diff              @@
   ##                2.x    #6420      +/-   ##
   ============================================
   + Coverage     50.41%   50.81%   +0.40%     
   - Complexity     5252     5286      +34     
   ============================================
     Files           941      942       +1     
     Lines         33279    33270       -9     
     Branches       4035     4030       -5     
   ============================================
   + Hits          16776    16905     +129     
   + Misses        14877    14698     -179     
   - Partials       1626     1667      +41     
   ```
   
   
   | [Files](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...eata/config/CachedConfigurationChangeListener.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29uZmlnL3NlYXRhLWNvbmZpZy1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9jb25maWcvQ2FjaGVkQ29uZmlndXJhdGlvbkNoYW5nZUxpc3RlbmVyLmphdmE=) | `100.00% <100.00%> (ø)` | |
   | [...va/org/apache/seata/config/ConfigurationCache.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29uZmlnL3NlYXRhLWNvbmZpZy1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9jb25maWcvQ29uZmlndXJhdGlvbkNhY2hlLmphdmE=) | `90.47% <100.00%> (+13.33%)` | :arrow_up: |
   | [...ache/seata/config/ConfigurationChangeListener.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29uZmlnL3NlYXRhLWNvbmZpZy1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9jb25maWcvQ29uZmlndXJhdGlvbkNoYW5nZUxpc3RlbmVyLmphdmE=) | `83.33% <100.00%> (+8.33%)` | :arrow_up: |
   | [...ava/org/apache/seata/config/FileConfiguration.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29uZmlnL3NlYXRhLWNvbmZpZy1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9jb25maWcvRmlsZUNvbmZpZ3VyYXRpb24uamF2YQ==) | `47.97% <100.00%> (+1.15%)` | :arrow_up: |
   | [...apache/seata/core/rpc/netty/NettyClientConfig.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvTmV0dHlDbGllbnRDb25maWcuamF2YQ==) | `52.23% <ø> (+2.98%)` | :arrow_up: |
   | [...he/seata/core/rpc/netty/RmNettyRemotingClient.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvUm1OZXR0eVJlbW90aW5nQ2xpZW50LmphdmE=) | `52.59% <100.00%> (+1.10%)` | :arrow_up: |
   | [...he/seata/core/rpc/netty/TmNettyRemotingClient.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9ycGMvbmV0dHkvVG1OZXR0eVJlbW90aW5nQ2xpZW50LmphdmE=) | `71.56% <100.00%> (+0.28%)` | :arrow_up: |
   | [...ache/seata/discovery/registry/RegistryService.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGlzY292ZXJ5L3NlYXRhLWRpc2NvdmVyeS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9kaXNjb3ZlcnkvcmVnaXN0cnkvUmVnaXN0cnlTZXJ2aWNlLmphdmE=) | `0.00% <ø> (ø)` | |
   | [...handler/GlobalTransactionalInterceptorHandler.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW50ZWdyYXRpb24tdHgtYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9pbnRlZ3JhdGlvbi90eC9hcGkvaW50ZXJjZXB0b3IvaGFuZGxlci9HbG9iYWxUcmFuc2FjdGlvbmFsSW50ZXJjZXB0b3JIYW5kbGVyLmphdmE=) | `29.68% <100.00%> (-0.37%)` | :arrow_down: |
   | [...r/parser/GlobalTransactionalInterceptorParser.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW50ZWdyYXRpb24tdHgtYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9pbnRlZ3JhdGlvbi90eC9hcGkvaW50ZXJjZXB0b3IvcGFyc2VyL0dsb2JhbFRyYW5zYWN0aW9uYWxJbnRlcmNlcHRvclBhcnNlci5qYXZh) | `30.55% <100.00%> (ø)` | |
   | ... and [6 more](https://app.codecov.io/gh/apache/incubator-seata/pull/6420?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
   
   ... and [36 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-seata/pull/6420/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527413391


##########
config/seata-config-core/src/test/java/org/apache/seata/config/FileConfigurationTest.java:
##########
@@ -41,13 +41,17 @@ void addConfigListener() throws InterruptedException {
         Configuration fileConfig = ConfigurationFactory.getInstance();
         CountDownLatch countDownLatch = new CountDownLatch(1);
         boolean value = fileConfig.getBoolean("service.disableGlobalTransaction");
-        ConfigurationCache.addConfigListener("service.disableGlobalTransaction", (event) -> {
-            Assertions.assertEquals(Boolean.parseBoolean(event.getNewValue()), !Boolean.parseBoolean(event.getOldValue()));
-            countDownLatch.countDown();
+        fileConfig.addConfigListener("service.disableGlobalTransaction", new CachedConfigurationChangeListener() {
+            @Override
+            public void onChangeEvent(ConfigurationChangeEvent event) {
+                Assertions.assertEquals(Boolean.parseBoolean(event.getNewValue()), !Boolean.parseBoolean(event.getOldValue()));
+                countDownLatch.countDown();
+            }
         });
         System.setProperty("service.disableGlobalTransaction", String.valueOf(!value));
         countDownLatch.await(5, TimeUnit.SECONDS);
         System.setProperty("file.listener.enabled", "false");
+        Thread.sleep(1000);

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527554724


##########
config/seata-config-etcd3/src/main/java/org/apache/seata/config/etcd3/EtcdConfiguration.java:
##########
@@ -394,7 +394,7 @@ public void onNext(WatchResponse watchResponse) {
                         List<KeyValue> keyValues = getResponse.getKvs();
                         if (CollectionUtils.isNotEmpty(keyValues)) {
                             event.setDataId(dataId).setNewValue(keyValues.get(0).getValue().toString(UTF_8));
-                            listener.onChangeEvent(event);
+                            listener.onProcessEvent(event);

Review Comment:
   The original configuration center had two methods of invocation: onChangeEvent and onProcessEvent. Which do you think should be the standard? The current changes have unified all previous onChangeEvent calls to onProcessEvent. What kind of expectations do you think this has for user behavior? For users to extend on their own, it means they need to understand structurally the presence or absence of cache, as well as the difference between synchronous and asynchronous operations.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527537961


##########
config/seata-config-core/src/main/java/org/apache/seata/config/CachedConfigurationChangeListener.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.config;
+
+public interface CachedConfigurationChangeListener extends ConfigurationChangeListener {
+
+    ConfigurationCache CONFIGURATION_CACHE = ConfigurationCache.getInstance();
+
+    @Override
+    default void afterEvent(ConfigurationChangeEvent event) {
+        ConfigurationChangeListener listener = (ConfigurationChangeListener)CONFIGURATION_CACHE;
+        listener.onProcessEvent(event);

Review Comment:
   > Design should not be function-oriented but object-oriented; consider design from the perspective of interactive behavior, not at the level of assembling functions. If ConfigurationCache's before and after are defined to be triggered identically, a logical call stack would be: NacosConfiguration.addConfigListener -> event -> listener.beforeEvent -> listener.onChangeEvent -> listener.afterEvent (ConfigurationCache.beforeEvent -> ConfigurationCache.onChangeEvent -> ConfigurationCache.afterEvent)
   
   我是认为ConfigurationCache不需要再有beforeEvent的相关逻辑了,如果有的话我认为是否未来可能会出现套娃现象?
   I was thinking that ConfigurationCache doesn't need to have beforeEvent related logic anymore, and if it does do I think there might be nesting in the future?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527413833


##########
config/seata-config-core/src/main/java/org/apache/seata/config/ConfigurationCache.java:
##########
@@ -115,6 +76,9 @@ public Configuration proxy(Configuration originalConfiguration) throws Exception
                     }
                     if (null == wrapper
                             || (null != defaultValue && !Objects.equals(defaultValue, wrapper.lastDefaultValue))) {
+                        if (DATA_ID_CACHED.add(rawDataId)) {
+                            originalConfiguration.addConfigListener(rawDataId, this);

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527413697


##########
config/seata-config-core/src/main/java/org/apache/seata/config/CachedConfigurationChangeListener.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.config;
+
+public interface CachedConfigurationChangeListener extends ConfigurationChangeListener {
+
+    ConfigurationCache CONFIGURATION_CACHE = ConfigurationCache.getInstance();
+
+    @Override
+    default void afterEvent(ConfigurationChangeEvent event) {
+        ConfigurationChangeListener listener = (ConfigurationChangeListener)CONFIGURATION_CACHE;
+        listener.onProcessEvent(event);

Review Comment:
   > CachedConfigurationChangeListener is an instance that holds state.
   
   Since we must notify ConfigurationCache, and ConfigurationCache also implements ConfigurationChangeListener, why do we need to use it to make it strong, instead of defining it in a member variable?
   既然必定要通知到ConfigurationCache,而且ConfigurationCache 也是实现了ConfigurationChangeListener,为什么要在使用使强壮,而不再成员变量中定义好?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527194236


##########
config/seata-config-core/src/main/java/org/apache/seata/config/ConfigurationCache.java:
##########
@@ -115,6 +76,9 @@ public Configuration proxy(Configuration originalConfiguration) throws Exception
                     }
                     if (null == wrapper
                             || (null != defaultValue && !Objects.equals(defaultValue, wrapper.lastDefaultValue))) {
+                        if (DATA_ID_CACHED.add(rawDataId)) {
+                            originalConfiguration.addConfigListener(rawDataId, this);

Review Comment:
   The hierarchical structure of the cache is below that of the config; not getting the configuration is meaningless for listening purposes.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527503866


##########
config/seata-config-core/src/main/java/org/apache/seata/config/CachedConfigurationChangeListener.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.config;
+
+public interface CachedConfigurationChangeListener extends ConfigurationChangeListener {
+
+    ConfigurationCache CONFIGURATION_CACHE = ConfigurationCache.getInstance();
+
+    @Override
+    default void afterEvent(ConfigurationChangeEvent event) {
+        ConfigurationChangeListener listener = (ConfigurationChangeListener)CONFIGURATION_CACHE;
+        listener.onProcessEvent(event);

Review Comment:
   > > CachedConfigurationChangeListener is an instance that holds state.
   > 
   > Since we must notify ConfigurationCache, and ConfigurationCache also implements ConfigurationChangeListener, why do we need to use it to make it strong, instead of defining it in a member variable? 既然必定要通知到ConfigurationCache,而且ConfigurationCache 也是实现了ConfigurationChangeListener,为什么要在使用使强壮,而不再成员变量中定义好?
   
   Sorry, I'm unable to understand the logic expressed here.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527537454


##########
config/seata-config-core/src/main/java/org/apache/seata/config/CachedConfigurationChangeListener.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.config;
+
+public interface CachedConfigurationChangeListener extends ConfigurationChangeListener {
+
+    ConfigurationCache CONFIGURATION_CACHE = ConfigurationCache.getInstance();
+
+    @Override
+    default void afterEvent(ConfigurationChangeEvent event) {
+        ConfigurationChangeListener listener = (ConfigurationChangeListener)CONFIGURATION_CACHE;
+        listener.onProcessEvent(event);

Review Comment:
   > > > CachedConfigurationChangeListener is an instance that holds state.
   > > 
   > > 
   > > Since we must notify ConfigurationCache, and ConfigurationCache also implements ConfigurationChangeListener, why do we need to use it to make it strong, instead of defining it in a member variable? 既然必定要通知到ConfigurationCache,而且ConfigurationCache 也是实现了ConfigurationChangeListener,为什么要在使用使强壮,而不再成员变量中定义好?
   > 
   > Sorry, I'm unable to understand the logic expressed here.
   
   Why not define it as a ConfigurationChangeListener afterListener = ConfigurationCache.getInstance(); when the member variable is defined, instead of doing the type conversion in afterEvent?
   为什么不在成员变量定义的时候就定义为一个ConfigurationChangeListener afterListener = ConfigurationCache.getInstance(); 而是在afterEvent中再进行类型转换?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly merged PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527539183


##########
config/seata-config-etcd3/src/main/java/org/apache/seata/config/etcd3/EtcdConfiguration.java:
##########
@@ -394,7 +394,7 @@ public void onNext(WatchResponse watchResponse) {
                         List<KeyValue> keyValues = getResponse.getKvs();
                         if (CollectionUtils.isNotEmpty(keyValues)) {
                             event.setDataId(dataId).setNewValue(keyValues.get(0).getValue().toString(UTF_8));
-                            listener.onChangeEvent(event);
+                            listener.onProcessEvent(event);

Review Comment:
   > What I am defining here is the interface standard, and what users rely on is also the interface, which is the basic polymorphic pattern of object-oriented programming. Is there a good method that would allow us to inversely constrain user implementations?
   
   Perhaps we can keep the behavior of onChangeEvent consistent with that of onProcessEvent and add a new method to replace the behavior of the original onChangeEvent?
   或许我们可以将onChangeEvent的行为保持和onProcessEvent一致,新增一个方法来代替原来的onChangeEvent的行为?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#issuecomment-2002731998

   ![image](https://github.com/apache/incubator-seata/assets/19943636/138fcee2-556f-4d34-b92e-81fe4dbeebfa)
   ![image](https://github.com/apache/incubator-seata/assets/19943636/44d0658f-bd6b-4fe4-921d-67c233bc4d1a)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527752259


##########
config/seata-config-etcd3/src/main/java/org/apache/seata/config/etcd3/EtcdConfiguration.java:
##########
@@ -394,7 +394,7 @@ public void onNext(WatchResponse watchResponse) {
                         List<KeyValue> keyValues = getResponse.getKvs();
                         if (CollectionUtils.isNotEmpty(keyValues)) {
                             event.setDataId(dataId).setNewValue(keyValues.get(0).getValue().toString(UTF_8));
-                            listener.onChangeEvent(event);
+                            listener.onProcessEvent(event);

Review Comment:
   Because the configuration is mainly used by seata, not the user, if this change can't make the user-side implementation behave the same as our implementation, it will affect the question of whether the configuration is effective in seata or not. So this should be a strong constraint setting, all notifications should go onProcessEvent behavior, otherwise the user's extension will lose a lot of functionality without perception
   因为配置主要是由seata使用,并不是用户使用,如果这个改动无法让用户侧的实现跟我们的实现行为一致,这将影响到配置在seata中是否生效的问题。所以这块应该是强约束的设定,所有的通知应该都走onProcessEvent这个行为,否则用户的扩展将在无感知的情况下丧失很多功能



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527194527


##########
config/seata-config-core/src/main/java/org/apache/seata/config/CachedConfigurationChangeListener.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.config;
+
+public interface CachedConfigurationChangeListener extends ConfigurationChangeListener {
+
+    ConfigurationCache CONFIGURATION_CACHE = ConfigurationCache.getInstance();
+
+    @Override
+    default void afterEvent(ConfigurationChangeEvent event) {
+        ConfigurationChangeListener listener = (ConfigurationChangeListener)CONFIGURATION_CACHE;
+        listener.onProcessEvent(event);

Review Comment:
   CachedConfigurationChangeListener is an instance that holds state.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527513085


##########
config/seata-config-etcd3/src/main/java/org/apache/seata/config/etcd3/EtcdConfiguration.java:
##########
@@ -394,7 +394,7 @@ public void onNext(WatchResponse watchResponse) {
                         List<KeyValue> keyValues = getResponse.getKvs();
                         if (CollectionUtils.isNotEmpty(keyValues)) {
                             event.setDataId(dataId).setNewValue(keyValues.get(0).getValue().toString(UTF_8));
-                            listener.onChangeEvent(event);
+                            listener.onProcessEvent(event);

Review Comment:
   What I am defining here is the interface standard, and what users rely on is also the interface, which is the basic polymorphic pattern of object-oriented programming. Is there a good method that would allow us to inversely constrain user implementations?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527413905


##########
config/seata-config-core/src/main/java/org/apache/seata/config/CachedConfigurationChangeListener.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.config;
+
+public interface CachedConfigurationChangeListener extends ConfigurationChangeListener {
+
+    ConfigurationCache CONFIGURATION_CACHE = ConfigurationCache.getInstance();
+
+    @Override
+    default void afterEvent(ConfigurationChangeEvent event) {
+        ConfigurationChangeListener listener = (ConfigurationChangeListener)CONFIGURATION_CACHE;
+        listener.onProcessEvent(event);

Review Comment:
   And then I think since it's an afterlistener, shouldn't it just call onChangeEvent instead of onProcessEvent?
   然后我认为既然是afterlistener,是否应该直接调用onChangeEvent,而不是onProcessEvent?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527194266


##########
config/seata-config-core/src/test/java/org/apache/seata/config/FileConfigurationTest.java:
##########
@@ -41,13 +41,17 @@ void addConfigListener() throws InterruptedException {
         Configuration fileConfig = ConfigurationFactory.getInstance();
         CountDownLatch countDownLatch = new CountDownLatch(1);
         boolean value = fileConfig.getBoolean("service.disableGlobalTransaction");
-        ConfigurationCache.addConfigListener("service.disableGlobalTransaction", (event) -> {
-            Assertions.assertEquals(Boolean.parseBoolean(event.getNewValue()), !Boolean.parseBoolean(event.getOldValue()));
-            countDownLatch.countDown();
+        fileConfig.addConfigListener("service.disableGlobalTransaction", new CachedConfigurationChangeListener() {
+            @Override
+            public void onChangeEvent(ConfigurationChangeEvent event) {
+                Assertions.assertEquals(Boolean.parseBoolean(event.getNewValue()), !Boolean.parseBoolean(event.getOldValue()));
+                countDownLatch.countDown();
+            }
         });
         System.setProperty("service.disableGlobalTransaction", String.valueOf(!value));
         countDownLatch.await(5, TimeUnit.SECONDS);
         System.setProperty("file.listener.enabled", "false");
+        Thread.sleep(1000);

Review Comment:
   For thread safety, the following sleep of 2 seconds is meaningless.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527183731


##########
config/seata-config-core/src/test/java/org/apache/seata/config/FileConfigurationTest.java:
##########
@@ -41,13 +41,17 @@ void addConfigListener() throws InterruptedException {
         Configuration fileConfig = ConfigurationFactory.getInstance();
         CountDownLatch countDownLatch = new CountDownLatch(1);
         boolean value = fileConfig.getBoolean("service.disableGlobalTransaction");
-        ConfigurationCache.addConfigListener("service.disableGlobalTransaction", (event) -> {
-            Assertions.assertEquals(Boolean.parseBoolean(event.getNewValue()), !Boolean.parseBoolean(event.getOldValue()));
-            countDownLatch.countDown();
+        fileConfig.addConfigListener("service.disableGlobalTransaction", new CachedConfigurationChangeListener() {
+            @Override
+            public void onChangeEvent(ConfigurationChangeEvent event) {
+                Assertions.assertEquals(Boolean.parseBoolean(event.getNewValue()), !Boolean.parseBoolean(event.getOldValue()));
+                countDownLatch.countDown();
+            }
         });
         System.setProperty("service.disableGlobalTransaction", String.valueOf(!value));
         countDownLatch.await(5, TimeUnit.SECONDS);
         System.setProperty("file.listener.enabled", "false");
+        Thread.sleep(1000);

Review Comment:
   Why sleep for 1 second?



##########
config/seata-config-etcd3/src/main/java/org/apache/seata/config/etcd3/EtcdConfiguration.java:
##########
@@ -394,7 +394,7 @@ public void onNext(WatchResponse watchResponse) {
                         List<KeyValue> keyValues = getResponse.getKvs();
                         if (CollectionUtils.isNotEmpty(keyValues)) {
                             event.setDataId(dataId).setNewValue(keyValues.get(0).getValue().toString(UTF_8));
-                            listener.onChangeEvent(event);
+                            listener.onProcessEvent(event);

Review Comment:
   I'm worried that the user's extended implementation doesn't call onProcessEvent this way.
   我担心用户的扩展实现里并不会这样去调用onProcessEvent



##########
config/seata-config-core/src/main/java/org/apache/seata/config/ConfigurationCache.java:
##########
@@ -90,12 +53,10 @@ public void onChangeEvent(ConfigurationChangeEvent event) {
                 CONFIG_CACHE.put(event.getDataId(), new ObjectWrapper(event.getNewValue(), null));
             } else {
                 Object newValue = new ObjectWrapper(event.getNewValue(), null).convertData(oldWrapper.getType());
-                if (!Objects.equals(oldWrapper.getData(), newValue)) {
-                    CONFIG_CACHE.put(event.getDataId(), new ObjectWrapper(newValue, oldWrapper.getType(),oldWrapper.getLastDefaultValue()));
-                }
+                CONFIG_CACHE.replace(event.getDataId(), oldWrapper, new ObjectWrapper(newValue, oldWrapper.getType(), oldWrapper.getLastDefaultValue()));

Review Comment:
   If the value remains unchanged, it will result in a meaningless replace.



##########
config/seata-config-core/src/main/java/org/apache/seata/config/CachedConfigurationChangeListener.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.config;
+
+public interface CachedConfigurationChangeListener extends ConfigurationChangeListener {
+
+    ConfigurationCache CONFIGURATION_CACHE = ConfigurationCache.getInstance();
+
+    @Override
+    default void afterEvent(ConfigurationChangeEvent event) {
+        ConfigurationChangeListener listener = (ConfigurationChangeListener)CONFIGURATION_CACHE;
+        listener.onProcessEvent(event);

Review Comment:
   ```suggestion
      ConfigurationChangeListener afterListener = ConfigurationCache.getInstance();
   
       @Override
       default void afterEvent(ConfigurationChangeEvent event) {
           afterListener.onProcessEvent(event);
   ```
   这样写是不是更加合适?
   Is it more appropriate to write this way?



##########
config/seata-config-core/src/main/java/org/apache/seata/config/ConfigurationCache.java:
##########
@@ -115,6 +76,9 @@ public Configuration proxy(Configuration originalConfiguration) throws Exception
                     }
                     if (null == wrapper
                             || (null != defaultValue && !Objects.equals(defaultValue, wrapper.lastDefaultValue))) {
+                        if (DATA_ID_CACHED.add(rawDataId)) {
+                            originalConfiguration.addConfigListener(rawDataId, this);

Review Comment:
   Why do need to listen on every key?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527750740


##########
config/seata-config-core/src/main/java/org/apache/seata/config/CachedConfigurationChangeListener.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.config;
+
+public interface CachedConfigurationChangeListener extends ConfigurationChangeListener {
+
+    ConfigurationCache CONFIGURATION_CACHE = ConfigurationCache.getInstance();
+
+    @Override
+    default void afterEvent(ConfigurationChangeEvent event) {
+        ConfigurationChangeListener listener = (ConfigurationChangeListener)CONFIGURATION_CACHE;
+        listener.onProcessEvent(event);

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] refactor: optimize Configuration Cache [incubator-seata]

Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on code in PR #6420:
URL: https://github.com/apache/incubator-seata/pull/6420#discussion_r1527501066


##########
config/seata-config-core/src/main/java/org/apache/seata/config/CachedConfigurationChangeListener.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.config;
+
+public interface CachedConfigurationChangeListener extends ConfigurationChangeListener {
+
+    ConfigurationCache CONFIGURATION_CACHE = ConfigurationCache.getInstance();
+
+    @Override
+    default void afterEvent(ConfigurationChangeEvent event) {
+        ConfigurationChangeListener listener = (ConfigurationChangeListener)CONFIGURATION_CACHE;
+        listener.onProcessEvent(event);

Review Comment:
   Design should not be function-oriented but object-oriented; consider design from the perspective of interactive behavior, not at the level of assembling functions. If ConfigurationCache's before and after are defined to be triggered identically, a logical call stack would be: NacosConfiguration.addConfigListener -> event -> listener.beforeEvent -> listener.onChangeEvent -> listener.afterEvent (ConfigurationCache.beforeEvent -> ConfigurationCache.onChangeEvent -> ConfigurationCache.afterEvent)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org