You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2020/05/08 09:09:54 UTC

[GitHub] [cloudstack] Pearl1594 commented on a change in pull request #4053: Secondary Storage Usage Improvements

Pearl1594 commented on a change in pull request #4053:
URL: https://github.com/apache/cloudstack/pull/4053#discussion_r422035093



##########
File path: engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java
##########
@@ -373,32 +375,26 @@ public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCa
                 s_logger.error(errMsg);
                 answer = new Answer(cmd, false, errMsg);
             } else {
-                boolean sent = false;
-                // Find the first endpoint to which the command can be sent to
-                for (EndPoint ep : eps) {
-                    if (getCopyCmdsCountToSpecificSSVM(ep.getId()) >= maxConcurrentCopyOpsPerSSVM) {
-                        continue;
+                // select endpoint with least number of commands running on them
+                EndPoint endPoint = null;
+                Long epId = ssvmWithLeastMigrateJobs();
+                if (epId == null) {
+                    Collections.shuffle(eps);
+                    endPoint = eps.get(0);
+                } else {
+                    List<EndPoint> remainingEps = eps.stream().filter(ep -> ep.getId() != epId ).collect(Collectors.toList());
+                    if (!remainingEps.isEmpty()) {
+                        Collections.shuffle(remainingEps);
+                        endPoint = remainingEps.get(0);
+                    } else {
+                        endPoint = _defaultEpSelector.getEndPointFromHostId(epId);
                     }
-
-                    CommandExecLogVO execLog = new CommandExecLogVO(ep.getId(), _secStorageVmDao.findByInstanceName(hostDao.findById(ep.getId()).getName()).getId(), cmd.getClass().getSimpleName(), 1);
-                    Long cmdExecId = _cmdExecLogDao.persist(execLog).getId();
-                    answer = ep.sendMessage(cmd);
-                    answer.setContextParam("cmd", cmdExecId.toString());
-                    sent = true;
-                    break;
-                }
-                // If both SSVMs are pre-occupied with tasks, choose the SSVM with least migrate jobs
-                if (!sent) {
-                    // Picking endpoint with least number of copy commands running on it
-                    Long epId = ssvmWithLeastMigrateJobs();
-                    EndPoint endPoint = _defaultEpSelector.getEndPointFromHostId(epId);
-                    CommandExecLogVO execLog = new CommandExecLogVO(epId, _secStorageVmDao.findByInstanceName(hostDao.findById(epId).getName()).getId(), cmd.getClass().getSimpleName(), 1);
-                    Long cmdExecId = _cmdExecLogDao.persist(execLog).getId();
-                    answer = endPoint.sendMessage(cmd);
-                    answer.setContextParam("cmd", cmdExecId.toString());
                 }
+                CommandExecLogVO execLog = new CommandExecLogVO(endPoint.getId(), _secStorageVmDao.findByInstanceName(hostDao.findById(endPoint.getId()).getName()).getId(), cmd.getClass().getSimpleName(), 1);
+                Long cmdExecId = _cmdExecLogDao.persist(execLog).getId();
+                answer = endPoint.sendMessage(cmd);
+                answer.setContextParam("cmd", cmdExecId.toString());

Review comment:
       Done




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

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