weizhouapache commented on code in PR #13635:
URL: https://github.com/apache/cloudstack/pull/13635#discussion_r3822712488


##########
engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java:
##########
@@ -1261,4 +1262,17 @@ public int getVmCountByOfferingNotInDomain(Long 
serviceOfferingId, List<Long> do
         List<Integer> count = customSearch(sc, null);
         return count.get(0);
     }
+
+    @Override
+    public List<VMInstanceVO> listByIds(List<Long> ids) {
+        if (CollectionUtils.isEmpty(ids)) {
+            return Collections.emptyList();
+        }
+        SearchBuilder<VMInstanceVO> sb = createSearchBuilder();

Review Comment:
   create a static SearchBuilder ?



##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -2452,33 +2453,53 @@ public String getName() {
     public boolean start() {
         _executor.scheduleWithFixedDelay(new ExpungeTask(), _expungeInterval, 
_expungeInterval, TimeUnit.SECONDS);
         _vmIpFetchExecutor.scheduleWithFixedDelay(new VmIpFetchTask(), 
VmIpFetchWaitInterval.value(), VmIpFetchWaitInterval.value(), TimeUnit.SECONDS);
-        loadVmDetailsInMapForExternalDhcpIp();
+        _vmIpFetchExecutor.submit(this::loadVmDetailsInMapForExternalDhcpIp);
         return true;
     }
 
-    private void loadVmDetailsInMapForExternalDhcpIp() {
+    protected void loadVmDetailsInMapForExternalDhcpIp() {
+        try {
+            Profiler profiler = new Profiler();
+            profiler.start();
+
+            List<NetworkVO> networks = 
_networkDao.listByGuestType(Network.GuestType.Shared);
+            Map<Long, Boolean> offeringWithoutServices = new HashMap<>();
+            int networksScanned = 0;
+            int nicsAdded = 0;
+
+            for (NetworkVO network : networks) {
+                boolean withoutServices = 
offeringWithoutServices.computeIfAbsent(network.getNetworkOfferingId(),
+                        offeringId -> 
_networkModel.listNetworkOfferingServices(offeringId).isEmpty());
+                if (!withoutServices) {
+                    continue;
+                }
+                networksScanned++;

Review Comment:
   seems valid concern



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

Reply via email to