gavinchou commented on code in PR #42865:
URL: https://github.com/apache/doris/pull/42865#discussion_r1821229318


##########
fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java:
##########
@@ -363,7 +371,19 @@ public List<Long> getAllBackendIds() {
     public int getBackendsNumber(boolean needAlive) {
         int beNumber = 
ConnectContext.get().getSessionVariable().getBeNumberForTest();
         if (beNumber < 0) {
-            beNumber = getAllBackendIds(needAlive).size();
+            try {
+                beNumber = (int) getBackendsByCurrentCluster()
+                    .values().stream().filter(be -> {
+                        if (needAlive) {
+                            return be.isAlive();
+                        } else {
+                            // not filter, return all
+                            return true;
+                        }
+                    }).count();

Review Comment:
   ```suggestion
                           return needAlive ? be.isAlive() : true;
                       }).count();
   ```
   ```suggestion
                       .values().stream().filter(be -> {  return needAlive ? 
be.isAlive() : true; }).count();
   ```



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