Liran Zelkha has uploaded a new change for review. Change subject: engine: Make VDSPartial, a partially loaded VDS object ......................................................................
engine: Make VDSPartial, a partially loaded VDS object Since loading a full VDS object is time consuming, this patch introduces a VDSPartial object, that is much faster to load. VDSPartial loading takes 5ms as opposed to 8ms for VDS Change-Id: I7d72c21f1686c4031607d793bbbefcc3e45e98cb Bug-Url: https://bugzilla.redhat.com/992883 Signed-off-by: lzel...@redhat.com <lzel...@redhat.com> --- M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAO.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java 3 files changed, 50 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/62/21662/1 diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAO.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAO.java index 0098504..adbd832 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAO.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAO.java @@ -209,4 +209,19 @@ * @return the list of VDS instances */ List<VDS> getHostsForStorageOperation(Guid storagePoolId, boolean localFsOnly); + + /** + * Retrieve the partial instance (static, dynamic) with the given id. + * @param id + * the VDS GUID + * @return the VDS instance + */ + VDS getPartial(Guid vdsId); + + /** + * Completes the retrieval of the partial instance + * @param the + * partial VDS + */ + void reloadPartial(VDS vds); } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java index 1f26158..c0b1ac8 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java @@ -8,6 +8,7 @@ import org.ovirt.engine.core.common.businessentities.NonOperationalReason; import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.businessentities.VDSType; import org.ovirt.engine.core.common.businessentities.VdsSpmStatus; @@ -15,6 +16,7 @@ import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.RpmVersion; import org.ovirt.engine.core.compat.Version; +import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dal.dbbroker.DbFacadeUtils; import org.ovirt.engine.core.utils.serialization.json.JsonObjectDeserializer; import org.springframework.jdbc.core.RowMapper; @@ -343,4 +345,34 @@ return entity; } } + + @Override + public VDS getPartial(Guid vdsId) { + VDS vdsPartial = new VDS(); + + // TODO: A future patch will load this from cache + vdsPartial.setStaticData(DbFacade.getInstance().getVdsStaticDao().get(vdsId)); + vdsPartial.setDynamicData(DbFacade.getInstance().getVdsDynamicDao().get(vdsId)); + + // TODO: A future patch will load this from cache + VDSGroup group = DbFacade.getInstance().getVdsGroupDao().get(vdsPartial.getVdsGroupId()); + vdsPartial.setVdsGroupCompatibilityVersion(group.getcompatibility_version()); + vdsPartial.setVdsGroupCpuName(group.getcpu_name()); + vdsPartial.setVdsGroupDescription(group.getdescription()); + vdsPartial.setVdsGroupName(group.getName()); + vdsPartial.setStoragePoolId(group.getStoragePoolId()); + vdsPartial.setStoragePoolName(group.getStoragePoolName()); + vdsPartial.setMaxVdsMemoryOverCommit(group.getmax_vds_memory_over_commit()); + + return vdsPartial; + } + + @Override + public void reloadPartial(VDS vds) { + vds.setStatisticsData(DbFacade.getInstance().getVdsStatisticsDao().get(vds.getId())); + + // TODO: A future patch will load this from cache + vds.setVdsSpmId(DbFacade.getInstance().getVdsSpmIdMapDao().get(vds.getId()).getvds_spm_id()); + } + } 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 9a28736..de10aa7 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 @@ -337,6 +337,9 @@ } finally { try { if (_firstStatus != _vds.getStatus() && _vds.getStatus() == VDSStatus.Up) { + // If status changed, reload the entire vds + DbFacade.getInstance().getVdsDao().reloadPartial(_vds); + // use this lock in order to allow only one host updating DB and // calling UpEvent in a time VdsManager.cancelRecoveryJob(_vds.getId()); -- To view, visit http://gerrit.ovirt.org/21662 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7d72c21f1686c4031607d793bbbefcc3e45e98cb Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Liran Zelkha <lzel...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches