Copilot commented on code in PR #2676:
URL: https://github.com/apache/hugegraph/pull/2676#discussion_r3323542286


##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java:
##########
@@ -172,8 +172,18 @@ public NodeRole selfNodeRole() {
         return this.globalNodeInfo.nodeRole();
     }
 
-    public boolean selfIsMaster() {
-        return this.selfNodeRole() != null && this.selfNodeRole().master();
+    public boolean selfIsMasterOrSingleComputer() {
+        boolean isMaster=this.selfNodeRole() != null && 
this.selfNodeRole().master();
+        boolean isSingleComputer=isStandAloneComputer();
+        return isMaster||isSingleComputer;
+    }
+
+    public boolean selfIsComputer() {
+        return this.selfNodeRole() != null && this.selfNodeRole().computer();
+    }
+
+    public boolean isStandAloneComputer(){
+        return this.onlySingleNode() && this.selfIsComputer();

Review Comment:
   The newly added methods violate the repository's checkstyle whitespace rules 
(the server module runs `maven-checkstyle-plugin` with `failsOnError=true` 
using `style/checkstyle.xml`). Missing spaces around `=`, `||`, and before `{` 
will cause validation to fail.



##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java:
##########
@@ -228,6 +238,32 @@ protected boolean graphIsReady() {
         return !this.closed && this.graph.started() && 
this.graph.initialized();
     }
 
+    protected synchronized void updateIsSingleNode(){
+        Collection<HugeServerInfo> servers=this.allServerInfos();
+        boolean hasWorkerNode = false;
+        long now = DateUtil.now().getTime();
+        int computerNodeCount=0;
+
+        // Iterate servers to find suitable one
+        for (HugeServerInfo server : servers) {
+            if (!server.alive()) {
+                continue;
+            }
+            if (server.role().master()) {
+                continue;
+            }else if (server.role().computer()){
+                computerNodeCount++;
+            }
+            hasWorkerNode = true;
+        }
+
+        boolean singleNode = !hasWorkerNode||computerNodeCount==1;
+        if (singleNode != this.onlySingleNode) {
+            LOG.info("Switch only_single_node 02 to {}", singleNode);
+            this.onlySingleNode = singleNode;
+        }
+    }

Review Comment:
   This sets `onlySingleNode` to true whenever exactly one computer node is 
alive, even if worker nodes are also alive. In a master + worker + 
single-computer deployment, that makes `StandardTaskScheduler.schedule()` treat 
the cluster as single-node and route non-computer tasks to the master instead 
of workers. Compute this flag from the total number of alive servers so it only 
represents an actual single-node deployment.



-- 
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