Michael Kublin has uploaded a new change for review. Change subject: engine: Replacing call to host by query ......................................................................
engine: Replacing call to host by query The following patch should replace a call to host by query during moving host to maintenance. All task should be kept in Db so no need to perform an XML RPC call. Query to DB is much more efficient and faster. Change-Id: I1e864961ab05538bd565d74f31869f64aa40b758 Signed-off-by: Michael Kublin <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/DeactivateStorageDomainCommand.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java 3 files changed, 9 insertions(+), 32 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/16/13616/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java index 703f607..d20e0ec 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java @@ -17,7 +17,6 @@ import org.ovirt.engine.core.common.action.MaintenanceVdsParameters; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; -import org.ovirt.engine.core.common.businessentities.AsyncTaskStatus; import org.ovirt.engine.core.common.businessentities.MigrationSupport; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; @@ -25,13 +24,10 @@ import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VdsSpmStatus; import org.ovirt.engine.core.common.businessentities.network.Network; -import org.ovirt.engine.core.common.errors.VdcBLLException; -import org.ovirt.engine.core.common.errors.VdcBllErrors; import org.ovirt.engine.core.common.locks.LockingGroup; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.common.vdscommands.SetVdsStatusVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; -import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.VdcBllMessages; import org.ovirt.engine.core.dal.dbbroker.DbFacade; @@ -179,29 +175,10 @@ } else if (vds.getStatus() == VDSStatus.NonResponsive && vds.getSpmStatus() != VdsSpmStatus.None) { result = false; addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_VDS_IS_NOT_RESPONDING_AND_IS_SPM); - } else if (vds.getSpmStatus() == VdsSpmStatus.SPM && vds.getStatus() == VDSStatus.Up) { - try { - @SuppressWarnings("unchecked") - HashMap<Guid, AsyncTaskStatus> taskStatuses = - (HashMap<Guid, AsyncTaskStatus>) Backend - .getInstance() - .getResourceManager() - .RunVdsCommand(VDSCommandType.HSMGetAllTasksStatuses, - new VdsIdVDSCommandParametersBase(vdsId)).getReturnValue(); - if (taskStatuses.size() > 0) { - addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_SPM_WITH_RUNNING_TASKS); - result = false; - } - } catch (VdcBLLException e) { - if (e.getErrorCode() == VdcBllErrors.VDS_NETWORK_ERROR) { - addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_VDS_IS_NOT_RESPONDING_AND_IS_SPM); - result = false; - } else { - log.error("Error getting spm task list.", e); - } - } catch (RuntimeException exp) { - log.error("Error getting spm task list.", exp); - } + } else if (vds.getSpmStatus() == VdsSpmStatus.SPM && vds.getStatus() == VDSStatus.Up && + getAsyncTaskDao().getAsyncTaskIdsByStoragePoolId(vds.getStoragePoolId()).size() > 0) { + addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_SPM_WITH_RUNNING_TASKS); + result = false; } } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/DeactivateStorageDomainCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/DeactivateStorageDomainCommand.java index ebf92b8..f580735 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/DeactivateStorageDomainCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/DeactivateStorageDomainCommand.java @@ -29,7 +29,6 @@ import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector; import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase; -import org.ovirt.engine.core.dao.AsyncTaskDAO; import org.ovirt.engine.core.utils.linq.LinqUtils; import org.ovirt.engine.core.utils.linq.Predicate; import org.ovirt.engine.core.utils.transaction.TransactionMethod; @@ -300,10 +299,6 @@ _isLastMaster = true; } } - } - - protected AsyncTaskDAO getAsyncTaskDao() { - return DbFacade.getInstance().getAsyncTaskDao(); } @Override diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java index 527c582..7666ade 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java @@ -23,6 +23,7 @@ import org.ovirt.engine.core.compat.NGuid; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dao.AdGroupDAO; +import org.ovirt.engine.core.dao.AsyncTaskDAO; import org.ovirt.engine.core.dao.DbUserDAO; import org.ovirt.engine.core.dao.PermissionDAO; import org.ovirt.engine.core.dao.RoleDAO; @@ -605,6 +606,10 @@ return getDbFacade().getNetworkDao(); } + protected AsyncTaskDAO getAsyncTaskDao() { + return getDbFacade().getAsyncTaskDao(); + } + protected DbFacade getDbFacade() { return DbFacade.getInstance(); } -- To view, visit http://gerrit.ovirt.org/13616 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1e864961ab05538bd565d74f31869f64aa40b758 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Michael Kublin <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
