YvCeung commented on code in PR #7903:
URL: https://github.com/apache/incubator-seata/pull/7903#discussion_r2668236255


##########
server/src/main/java/org/apache/seata/server/cluster/manager/ClusterWatcherManager.java:
##########
@@ -57,24 +59,35 @@ public class ClusterWatcherManager implements 
ClusterChangeListener {
 
     private static final Map<String, Long> GROUP_UPDATE_TERM = new 
ConcurrentHashMap<>();
 
+    private static final Map<Watcher<HttpContext>, Boolean> HTTP2_HEADERS_SENT 
= new ConcurrentHashMap<>();
+
     private final ScheduledThreadPoolExecutor scheduledThreadPoolExecutor =
             new ScheduledThreadPoolExecutor(1, new 
NamedThreadFactory("long-polling", 1));
 
     @PostConstruct
     public void init() {
-        // Responds to monitors that time out
+        // Periodically check and respond to watchers that have timed out
         scheduledThreadPoolExecutor.scheduleAtFixedRate(
                 () -> {
                     for (String group : WATCHERS.keySet()) {
                         Optional.ofNullable(WATCHERS.remove(group))
                                 .ifPresent(watchers -> 
watchers.parallelStream().forEach(watcher -> {
-                                    if (System.currentTimeMillis() >= 
watcher.getTimeout()) {
-                                        watcher.setDone(true);
-                                        sendWatcherResponse(watcher, 
HttpResponseStatus.NOT_MODIFIED);
-                                    }
-                                    if (!watcher.isDone()) {
-                                        // Re-register
-                                        registryWatcher(watcher);
+                                    HttpContext context = 
watcher.getAsyncContext();
+                                    boolean isHttp2 = context instanceof 
HttpContext && context.isHttp2();
+                                    if (isHttp2) {
+                                        if 
(!context.getContext().channel().isActive()) {
+                                            watcher.setDone(true);
+                                            HTTP2_HEADERS_SENT.remove(watcher);
+                                        } else {
+                                            registryWatcher(watcher);

Review Comment:
   I believe that writing data to the ChannelHandlerContext in a concurrent 
manner does have this possibility, but it does not affect the data push. It's 
just that several lines of data are pushed at once. As long as the data sent at 
one time is complete, it's fine. Because the client parses one line at a time. 
As for the disorder issue of the term, the client can make its own judgment. Of 
course, the server can also make some appropriate optimizations.
   
   
我认为并发往ChannelHandlerContext里面write数据是存在这种可能性,但是不影响数据推送,无非一下子推送了好几行数据,服务端只要确保一次性发出去的数据是完整的就行,因为客户端是一行行解析的。至于term的乱序问题
 客户端可以自己判断,当然服务端也可以适当的做一点优化



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to