Roy Golan has uploaded a new change for review. Change subject: core: VURTI - use ResourceManager instead of commands ......................................................................
core: VURTI - use ResourceManager instead of commands Use ResourceManager instead of direct command invocation Add List, GetVmStats and GetAllVmsStats to the list of Command Types Clean-up the code expressions, format, indent etc Change-Id: I16359bf4af4968c8e9d8a650fb2af541ae0cc3fb Signed-off-by: Roy Golan <rgo...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java 2 files changed, 37 insertions(+), 35 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/98/25598/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java index 60aab98..4890150 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java @@ -156,7 +156,10 @@ GetDiskAlignment("org.ovirt.engine.core.vdsbroker.vdsbroker"), GlusterTasksList("org.ovirt.engine.core.vdsbroker.gluster"), GetGlusterVolumeRemoveBricksStatus("org.ovirt.engine.core.vdsbroker.gluster"), - SetNumberOfCpus("org.ovirt.engine.core.vdsbroker"); + SetNumberOfCpus("org.ovirt.engine.core.vdsbroker"), + List("org.ovirt.engine.core.vdsbroker.vdsbroker"), // get a list of VMs with status only + GetVmStats("org.ovirt.engine.core.vdsbroker.vdsbroker"), // get a VM with full data and statistics + GetAllVmStats("org.ovirt.engine.core.vdsbroker.vdsbroker"); // get a list of VMs with full data and statistics String packageName; diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java index 31801f2..b1be8a9 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java @@ -59,6 +59,8 @@ import org.ovirt.engine.core.common.vdscommands.DestroyVmVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.FullListVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.GetVmStatsVDSCommandParameters; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; import org.ovirt.engine.core.common.vdscommands.VdsIdAndVdsVDSCommandParametersBase; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.RefObject; @@ -76,15 +78,11 @@ import org.ovirt.engine.core.vdsbroker.irsbroker.IRSErrorException; import org.ovirt.engine.core.vdsbroker.vdsbroker.DestroyVDSCommand; import org.ovirt.engine.core.vdsbroker.vdsbroker.FullListVdsCommand; -import org.ovirt.engine.core.vdsbroker.vdsbroker.GetAllVmStatsVDSCommand; import org.ovirt.engine.core.vdsbroker.vdsbroker.GetStatsVDSCommand; -import org.ovirt.engine.core.vdsbroker.vdsbroker.GetVmStatsVDSCommand; -import org.ovirt.engine.core.vdsbroker.vdsbroker.ListVDSCommand; import org.ovirt.engine.core.vdsbroker.vdsbroker.VDSErrorException; import org.ovirt.engine.core.vdsbroker.vdsbroker.VDSNetworkException; import org.ovirt.engine.core.vdsbroker.vdsbroker.VDSProtocolException; import org.ovirt.engine.core.vdsbroker.vdsbroker.VDSRecoveringException; -import org.ovirt.engine.core.vdsbroker.vdsbroker.VdsBrokerCommand; import org.ovirt.engine.core.vdsbroker.vdsbroker.VdsProperties; import org.ovirt.engine.core.vdsbroker.vdsbroker.entities.VmInternalData; @@ -908,18 +906,16 @@ if (Config.<Boolean> getValue(ConfigValues.DebugTimerLogging)) { log.debug("vds::refreshVmList entered"); } + VDSReturnValue vdsReturnValue; + VDSCommandType commandType = + _vdsManager.getRefreshStatistics() + ? VDSCommandType.GetAllVmStats + : VDSCommandType.List; + vdsReturnValue = getResourceManager().runVdsCommand(commandType, new VdsIdAndVdsVDSCommandParametersBase(_vds)); - VdsBrokerCommand<VdsIdAndVdsVDSCommandParametersBase> command; - if (!_vdsManager.getRefreshStatistics()) { - command = new ListVDSCommand<VdsIdAndVdsVDSCommandParametersBase>( - new VdsIdAndVdsVDSCommandParametersBase(_vds)); - } else { - command = new GetAllVmStatsVDSCommand<VdsIdAndVdsVDSCommandParametersBase>( - new VdsIdAndVdsVDSCommandParametersBase(_vds)); - } - _runningVms = (Map<Guid, VmInternalData>) command.executeWithReturnValue(); + _runningVms = (Map<Guid, VmInternalData>) vdsReturnValue.getReturnValue(); - if (command.getVDSReturnValue().getSucceeded()) { + if (vdsReturnValue.getSucceeded()) { List<VM> running = checkVmsStatusChanged(); proceedWatchdogEvents(); @@ -950,20 +946,22 @@ updateLunDisks(); - } else if (command.getVDSReturnValue().getExceptionObject() != null) { - if (command.getVDSReturnValue().getExceptionObject() instanceof VDSErrorException) { - log.errorFormat("Failed vds listing, vds = {0} : {1}, error = {2}", _vds.getId(), - _vds.getName(), command.getVDSReturnValue().getExceptionString()); - } else if (command.getVDSReturnValue().getExceptionObject() instanceof VDSNetworkException) { - _saveVdsDynamic = _vdsManager.handleNetworkException((VDSNetworkException) command.getVDSReturnValue() - .getExceptionObject(), _vds); - } else if (command.getVDSReturnValue().getExceptionObject() instanceof VDSProtocolException) { - log.errorFormat("Failed vds listing, vds = {0} : {1}, error = {2}", _vds.getId(), - _vds.getName(), command.getVDSReturnValue().getExceptionString()); - } - throw command.getVDSReturnValue().getExceptionObject(); } else { - log.error("GetCapabilitiesVDSCommand failed with no exception!"); + RuntimeException callException = vdsReturnValue.getExceptionObject(); + if (callException != null) { + if (callException instanceof VDSErrorException) { + log.errorFormat("Failed vds listing, vds = {0} : {1}, error = {2}", _vds.getId(), + _vds.getName(), vdsReturnValue.getExceptionString()); + } else if (callException instanceof VDSNetworkException) { + _saveVdsDynamic = _vdsManager.handleNetworkException((VDSNetworkException) callException, _vds); + } else if (callException instanceof VDSProtocolException) { + log.errorFormat("Failed vds listing, vds = {0} : {1}, error = {2}", _vds.getId(), + _vds.getName(), vdsReturnValue.getExceptionString()); + } + throw callException; + } else { + log.errorFormat("{0} failed with no exception!", commandType.name()); + } } } @@ -1272,13 +1270,11 @@ if (vmToUpdate == null || (vmToUpdate.getStatus() != runningVm.getStatus() && !(vmToUpdate.getStatus() == VMStatus.PreparingForHibernate && runningVm.getStatus() == VMStatus.Up))) { - GetVmStatsVDSCommand<GetVmStatsVDSCommandParameters> command = - new GetVmStatsVDSCommand<GetVmStatsVDSCommandParameters>(new GetVmStatsVDSCommandParameters( - _vds, runningVm.getId())); - command.execute(); - if (command.getVDSReturnValue().getSucceeded()) { - _runningVms.put(runningVm.getId(), - (VmInternalData) command.getReturnValue()); + VDSReturnValue vdsReturnValue = getResourceManager().runVdsCommand( + VDSCommandType.GetVmStats, + new GetVmStatsVDSCommandParameters(_vds, runningVm.getId())); + if (vdsReturnValue.getSucceeded()) { + _runningVms.put(runningVm.getId(), (VmInternalData) vdsReturnValue.getReturnValue()); } else { _runningVms.remove(runningVm.getId()); } @@ -2162,4 +2158,7 @@ AuditLogDirector.log(auditLogable, AuditLogType.VM_STATUS_RESTORED); } + protected ResourceManager getResourceManager() { + return ResourceManager.getInstance(); + } } -- To view, visit http://gerrit.ovirt.org/25598 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I16359bf4af4968c8e9d8a650fb2af541ae0cc3fb Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.4 Gerrit-Owner: Roy Golan <rgo...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches