Fix: allow executing CopyCommand operations in parallel when it is set (#5960)

* Invoke the hypervisor guru instead of the guru cycle

* Refactor

* Remove unused import

* Refactor error
This commit is contained in:
Nicolas Vazquez 2022-02-14 23:52:45 -03:00 committed by GitHub
parent fe03e306ac
commit 97d42e9980
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View File

@ -24,4 +24,6 @@ public interface HypervisorGuruManager extends Manager {
HypervisorGuru getGuru(HypervisorType hypervisorType);
long getGuruProcessedCommandTargetHost(long hostId, Command cmd);
long getGuruProcessedCommandTargetHost(long hostId, Command cmd, HypervisorType hypervisorType);
}

View File

@ -342,10 +342,15 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
}
Answer answer = null;
try {
final long targetHostId = _hvGuruMgr.getGuruProcessedCommandTargetHost(host.getId(), cmd);
final long targetHostId = _hvGuruMgr.getGuruProcessedCommandTargetHost(host.getId(), cmd, host.getHypervisorType());
answer = easySend(targetHostId, cmd);
} catch (final Exception e) {
String errorMsg = String.format("Error sending command %s to host %s, due to %s", cmd.getClass().getName(),
host.getUuid(), e.getLocalizedMessage());
s_logger.error(errorMsg);
if (s_logger.isDebugEnabled()) {
s_logger.debug(errorMsg, e);
}
}
if (answer != null) {
return answer;

View File

@ -81,6 +81,13 @@ public class HypervisorGuruManagerImpl extends ManagerBase implements Hypervisor
return hostId;
}
@Override
public long getGuruProcessedCommandTargetHost(long hostId, Command cmd, HypervisorType hypervisorType) {
HypervisorGuru guru = getGuru(hypervisorType);
Pair<Boolean, Long> result = guru.getCommandHostDelegation(hostId, cmd);
return result.first() ? result.second() : hostId;
}
public List<HypervisorGuru> getHvGuruList() {
return _hvGuruList;
}