Gilad Chaplik has uploaded a new change for review. Change subject: engine: use vds query instead of search ......................................................................
engine: use vds query instead of search When quering for hosts in general vm dialog we should use a query instead of search, the search is limited to max results. Enhance the query to support sorting (the search used to order by vds_name) In userportal, removed redundant overrides Change-Id: If6d14448dd546135778b63a96924f8d28d1f13bc Related-Bug-Url: https://bugzilla.redhat.com/893457 Signed-off-by: Gilad Chaplik <gchap...@redhat.com> --- M backend/manager/dbscripts/vds_sp.sql M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetHostsByClusterIdQuery.java 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/dal/src/test/java/org/ovirt/engine/core/dao/VdsDAOTest.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterGuideModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterServiceModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeBrickListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalExistingVmModelBehavior.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalNewVmModelBehavior.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalTemplateVmModelBehavior.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java 14 files changed, 52 insertions(+), 66 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/41/11041/1 diff --git a/backend/manager/dbscripts/vds_sp.sql b/backend/manager/dbscripts/vds_sp.sql index 2cee45e..0a5719a 100644 --- a/backend/manager/dbscripts/vds_sp.sql +++ b/backend/manager/dbscripts/vds_sp.sql @@ -829,22 +829,38 @@ -Create or replace FUNCTION GetVdsByVdsGroupId(v_vds_group_id UUID, v_user_id UUID, v_is_filtered boolean) RETURNS SETOF vds +Create or replace FUNCTION GetVdsByVdsGroupId(v_vds_group_id UUID, v_user_id UUID, v_is_filtered boolean, v_is_sorted boolean) RETURNS SETOF vds AS $procedure$ BEGIN -- this sp returns all vds for a given cluster BEGIN if (v_is_filtered) then - RETURN QUERY SELECT DISTINCT (rec).* - FROM fn_db_mask_object('vds') as q (rec vds) - WHERE (rec).vds_group_id = v_vds_group_id - AND EXISTS (SELECT 1 - FROM user_vds_permissions_view - WHERE user_id = v_user_id AND entity_id = (rec).vds_id); - else - RETURN QUERY SELECT DISTINCT vds.* - FROM vds - WHERE vds_group_id = v_vds_group_id; + if(v_is_sorted) then + RETURN QUERY SELECT DISTINCT (rec).* + FROM fn_db_mask_object('vds') as q (rec vds) + WHERE (rec).vds_group_id = v_vds_group_id + AND EXISTS (SELECT 1 + FROM user_vds_permissions_view + WHERE user_id = v_user_id AND entity_id = (rec).vds_id) + ORDER BY vds_name; + else + RETURN QUERY SELECT DISTINCT (rec).* + FROM fn_db_mask_object('vds') as q (rec vds) + WHERE (rec).vds_group_id = v_vds_group_id + AND EXISTS (SELECT 1 + FROM user_vds_permissions_view + WHERE user_id = v_user_id AND entity_id = (rec).vds_id); + end if; + else if(v_is_sorted) then + RETURN QUERY SELECT DISTINCT vds.* + FROM vds + WHERE vds_group_id = v_vds_group_id + ORDER BY vds_name; + else + RETURN QUERY SELECT DISTINCT vds.* + FROM vds + WHERE vds_group_id = v_vds_group_id; + end if; end if; END; RETURN; diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetHostsByClusterIdQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetHostsByClusterIdQuery.java index 6d36fb9..513661a 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetHostsByClusterIdQuery.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetHostsByClusterIdQuery.java @@ -12,7 +12,7 @@ protected void executeQueryCommand() { getQueryReturnValue().setReturnValue(DbFacade.getInstance() .getVdsDao() - .getAllForVdsGroup(getParameters().getId(), getUserID(), getParameters().isFiltered())); + .getAllForVdsGroup(getParameters().getId(), getUserID(), getParameters().isFiltered(), true)); } } 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 e1cb3d2..f8b9b76 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 @@ -133,9 +133,11 @@ * the ID of the user requesting the information * @param isFiltered * Whether the results should be filtered according to the user's permissions + * @param isSorted + * will the results sorted by vds_name * @return the list of VDS instances */ - List<VDS> getAllForVdsGroup(Guid vdsGroup, Guid userID, boolean isFiltered); + List<VDS> getAllForVdsGroup(Guid vdsGroup, Guid userID, boolean isFiltered, boolean isSorted); /** * Retrieves all VDS instances by storage pool ID. 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 2db5f5a..2fe5007 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 @@ -118,17 +118,18 @@ @Override public List<VDS> getAllForVdsGroup(Guid vdsGroupID) { - return getAllForVdsGroup(vdsGroupID, null, false); + return getAllForVdsGroup(vdsGroupID, null, false, false); } @Override - public List<VDS> getAllForVdsGroup(Guid vdsGroupID, Guid userID, boolean isFiltered) { + public List<VDS> getAllForVdsGroup(Guid vdsGroupID, Guid userID, boolean isFiltered, boolean isSorted) { return getCallsHandler().executeReadList("GetVdsByVdsGroupId", VdsRowMapper.instance, getCustomMapSqlParameterSource() .addValue("vds_group_id", vdsGroupID) .addValue("user_id", userID) - .addValue("is_filtered", isFiltered)); + .addValue("is_filtered", isFiltered) + .addValue("is_sorted", isSorted)); } @Override diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDAOTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDAOTest.java index ff14483..5ca5abb 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDAOTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDAOTest.java @@ -298,7 +298,7 @@ */ @Test public void testGetAllForVdsGroupWithPermissionsForPriviligedUser() { - List<VDS> result = dao.getAllForVdsGroup(existingVds.getvds_group_id(), PRIVILEGED_USER_ID, true); + List<VDS> result = dao.getAllForVdsGroup(existingVds.getvds_group_id(), PRIVILEGED_USER_ID, true, false); assertGetAllForVdsGroupCorrectResult(result); } @@ -307,7 +307,7 @@ */ @Test public void testGetAllForVdsGroupWithPermissionsForUnpriviligedUser() { - List<VDS> result = dao.getAllForVdsGroup(existingVds.getvds_group_id(), UNPRIVILEGED_USER_ID, true); + List<VDS> result = dao.getAllForVdsGroup(existingVds.getvds_group_id(), UNPRIVILEGED_USER_ID, true, false); assertNotNull(result); assertTrue(result.isEmpty()); } @@ -317,7 +317,7 @@ */ @Test public void testGetAllForVdsGroupWithPermissionsDisabledForUnpriviligedUser() { - List<VDS> result = dao.getAllForVdsGroup(existingVds.getvds_group_id(), UNPRIVILEGED_USER_ID, false); + List<VDS> result = dao.getAllForVdsGroup(existingVds.getvds_group_id(), UNPRIVILEGED_USER_ID, false, false); assertGetAllForVdsGroupCorrectResult(result); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java index 1b0e739..8d4f7d4 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java @@ -55,6 +55,7 @@ import org.ovirt.engine.core.common.queries.CommandVersionsInfo; import org.ovirt.engine.core.common.queries.ConfigurationValues; import org.ovirt.engine.core.common.queries.GetAllAttachableDisks; +import org.ovirt.engine.core.common.queries.GetHostsByClusterIdParameters; import org.ovirt.engine.core.common.queries.InterfaceAndIdQueryParameters; import org.ovirt.engine.core.common.queries.GetAllDisksByVmIdParameters; import org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters; @@ -764,7 +765,7 @@ Frontend.RunQuery(VdcQueryType.GetVdsByVdsId, new GetVdsByVdsIdParameters(id), aQuery); } - public static void GetHostListByCluster(AsyncQuery aQuery, String clusterName) { + public static void GetHostListByCluster(AsyncQuery aQuery, Guid clusterId) { aQuery.converterCallback = new IAsyncConverter() { @Override public Object Convert(Object source, AsyncQuery _asyncQuery) @@ -778,8 +779,10 @@ return new ArrayList<VDS>(); } }; - Frontend.RunQuery(VdcQueryType.Search, new SearchParameters("Host: cluster = " + clusterName + " sortby name", //$NON-NLS-1$ //$NON-NLS-2$ - SearchType.VDS), aQuery); + Frontend.RunQuery( + VdcQueryType.GetHostsByClusterId, + new GetHostsByClusterIdParameters(clusterId), + aQuery); } public static void GetHostListByDataCenter(AsyncQuery aQuery, Guid spId) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterGuideModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterGuideModel.java index 56d0045..470f623 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterGuideModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterGuideModel.java @@ -80,7 +80,7 @@ clusterGuideModel.hosts = hosts; clusterGuideModel.UpdateOptionsNonLocalFS(); } - }), getEntity().getname()); + }), getEntity().getId()); AsyncDataProvider.GetHostList(new AsyncQuery(this, new INewAsyncCallback() { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterServiceModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterServiceModel.java index c5df80c..9b10b33 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterServiceModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterServiceModel.java @@ -138,7 +138,7 @@ getHostList().setItems(hostList); } }; - AsyncDataProvider.GetHostListByCluster(asyncQuery, getEntity().getname()); + AsyncDataProvider.GetHostListByCluster(asyncQuery, getEntity().getId()); } private void updateServiceTypeList() { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeBrickListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeBrickListModel.java index 6304f0c..0e2258e 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeBrickListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeBrickListModel.java @@ -219,7 +219,7 @@ volumeBrickModel.getServers().setItems(hostList); } }; - AsyncDataProvider.GetHostListByCluster(_asyncQueryInner, cluster.getname()); + AsyncDataProvider.GetHostListByCluster(_asyncQueryInner, cluster.getId()); } }; AsyncDataProvider.GetClusterById(_asyncQuery, volumeEntity.getClusterId()); @@ -629,7 +629,7 @@ brickModel.getServers().setItems(hostList); } }; - AsyncDataProvider.GetHostListByCluster(_asyncQueryInner, cluster.getname()); + AsyncDataProvider.GetHostListByCluster(_asyncQueryInner, cluster.getId()); } }; AsyncDataProvider.GetClusterById(_asyncQuery, volumeEntity.getClusterId()); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeModel.java index 0a7e994..b4a73e6 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeModel.java @@ -320,7 +320,7 @@ volumeBrickModel.getServers().setItems(hostList); } }; - AsyncDataProvider.GetHostListByCluster(_asyncQuery, ((VDSGroup) getCluster().getSelectedItem()).getname()); + AsyncDataProvider.GetHostListByCluster(_asyncQuery, ((VDSGroup) getCluster().getSelectedItem()).getId()); // TODO: fetch the mount points to display if (getBricks().getItems() != null) @@ -444,7 +444,7 @@ getAddBricksCommand().setIsExecutionAllowed(false); setMessage(ConstantsManager.getInstance().getConstants().volumeEmptyClusterValidationMsg()); } - }), cluster.getname()); + }), cluster.getId()); } else { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalExistingVmModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalExistingVmModelBehavior.java index 09e9750..0f8090a 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalExistingVmModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalExistingVmModelBehavior.java @@ -11,12 +11,9 @@ import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.storage_pool; -import org.ovirt.engine.core.common.queries.GetHostsByClusterIdParameters; -import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.NGuid; import org.ovirt.engine.ui.frontend.AsyncQuery; -import org.ovirt.engine.ui.frontend.Frontend; import org.ovirt.engine.ui.frontend.INewAsyncCallback; import org.ovirt.engine.ui.uicommonweb.Linq; import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; @@ -134,14 +131,5 @@ } super.doChangeDefautlHost(hostGuid); - } - - @Override - protected void getHostListByCluster(VDSGroup cluster, AsyncQuery query) { - Frontend.RunQuery( - VdcQueryType.GetHostsByClusterId, - new GetHostsByClusterIdParameters(cluster.getId()), - query - ); } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalNewVmModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalNewVmModelBehavior.java index f5a40c4..8418694 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalNewVmModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalNewVmModelBehavior.java @@ -15,7 +15,6 @@ import org.ovirt.engine.core.common.businessentities.VmTemplateStatus; import org.ovirt.engine.core.common.businessentities.storage_pool; import org.ovirt.engine.core.common.queries.GetEntitiesWithPermittedActionParameters; -import org.ovirt.engine.core.common.queries.GetHostsByClusterIdParameters; import org.ovirt.engine.core.common.queries.VdcQueryParametersBase; import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; import org.ovirt.engine.core.common.queries.VdcQueryType; @@ -177,14 +176,5 @@ */ @Override protected void doChangeDefautlHost(NGuid hostGuid) { - } - - @Override - protected void getHostListByCluster(VDSGroup cluster, AsyncQuery query) { - Frontend.RunQuery( - VdcQueryType.GetHostsByClusterId, - new GetHostsByClusterIdParameters(cluster.getId()), - query - ); } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalTemplateVmModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalTemplateVmModelBehavior.java index 3f37d0a..6656d70 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalTemplateVmModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalTemplateVmModelBehavior.java @@ -3,13 +3,8 @@ import java.util.Arrays; import org.ovirt.engine.core.common.businessentities.VDS; -import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VmTemplate; -import org.ovirt.engine.core.common.queries.GetHostsByClusterIdParameters; -import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.core.compat.NGuid; -import org.ovirt.engine.ui.frontend.AsyncQuery; -import org.ovirt.engine.ui.frontend.Frontend; public class UserPortalTemplateVmModelBehavior extends TemplateVmModelBehavior { @@ -32,14 +27,5 @@ } super.doChangeDefautlHost(hostGuid); - } - - @Override - protected void getHostListByCluster(VDSGroup cluster, AsyncQuery query) { - Frontend.RunQuery( - VdcQueryType.GetHostsByClusterId, - new GetHostsByClusterIdParameters(cluster.getId()), - query - ); } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java index 83d690d..d668756 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java @@ -437,8 +437,8 @@ /** * By default admin query is fired, UserPortal overrides it to fire user query */ - protected void getHostListByCluster(VDSGroup cluster, AsyncQuery query) { - AsyncDataProvider.GetHostListByCluster(query, cluster.getname()); + private void getHostListByCluster(VDSGroup cluster, AsyncQuery query) { + AsyncDataProvider.GetHostListByCluster(query, cluster.getId()); } protected void updateCustomPropertySheet() { -- To view, visit http://gerrit.ovirt.org/11041 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If6d14448dd546135778b63a96924f8d28d1f13bc Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches