Selvasundaram has uploaded a new change for review. Change subject: [WIP] engine: Gluster geo-replication search query ......................................................................
[WIP] engine: Gluster geo-replication search query Change-Id: Ib8c8b9e480064364aff5daf1502334e22072982b Signed-off-by: Selvasundaram <[email protected]> --- M backend/manager/dbscripts/create_views.sql M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/SearchType.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoreplicationDao.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoreplicationDaoDbFacadeImpl.java M backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SearchObjectAutoCompleter.java M backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SearchObjects.java M backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxContainer.java A backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/gluster/GlusterVolumeGeorepConditionFieldAutoCompleter.java A backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/gluster/GlusterVolumeGeorepCrossRefAutoCompleter.java M frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml 11 files changed, 205 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/9999/1 diff --git a/backend/manager/dbscripts/create_views.sql b/backend/manager/dbscripts/create_views.sql index d6dd745..5e26041 100644 --- a/backend/manager/dbscripts/create_views.sql +++ b/backend/manager/dbscripts/create_views.sql @@ -1080,6 +1080,29 @@ INNER JOIN storage_pool ON network.storage_pool_id = storage_pool.id; ---------------------------------------------- +-- Gluster Volumes +---------------------------------------------- +CREATE OR REPLACE VIEW gluster_georeplication_view +AS +SELECT gluster_georeplication.id AS id, + gluster_georeplication.volume_id AS volume_id, + gluster_georeplication.server_id AS server_id, + gluster_volumes.vol_name AS vol_name, + vds_static.vds_name AS vds_name, + vds_groups.vds_group_id AS cluster_id, + vds_groups.name AS cluster_name, + gluster_georeplication.remote_server AS remote_server, + gluster_georeplication.ssh_key_fingerprint AS ssh_key_fingerprint, + gluster_georeplication.remote_server_user AS remote_server_user, + gluster_georeplication.remote_vol_dir AS remote_vol_dir, + gluster_georeplication.status AS status +FROM vds_groups +JOIN gluster_volumes ON vds_groups.vds_group_id = gluster_volumes.cluster_id +JOIN gluster_georeplication ON gluster_georeplication.volume_id = gluster_volumes.id +JOIN vds_static ON vds_static.vds_id = gluster_georeplication.server_id; + + +---------------------------------------------- -- Query Permissions ---------------------------------------------- diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java index 0a6a398..3715e6a 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java @@ -28,6 +28,7 @@ import org.ovirt.engine.core.common.businessentities.storage_domains; import org.ovirt.engine.core.common.businessentities.storage_pool; import org.ovirt.engine.core.common.businessentities.vm_pools; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoreplicationEntity; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; import org.ovirt.engine.core.common.config.Config; import org.ovirt.engine.core.common.config.ConfigValues; @@ -130,6 +131,10 @@ } case Network: { returnValue = searchNetworks(); + break; + } + case GlusterVolumeGeorep: { + returnValue = searchGlusterVolumeGeoreplications(); break; } default: { @@ -267,6 +272,10 @@ return genericSearch(getDbFacade().getNetworkViewDao(), true, null); } + private List<GlusterGeoreplicationEntity> searchGlusterVolumeGeoreplications() { + return genericSearch(getDbFacade().getGlusterGeoreplicationDao(), true, null); + } + private QueryData2 InitQueryData(boolean useCache) { QueryData2 data = null; boolean isExistsValue = false; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/SearchType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/SearchType.java index 79fcd3a..2ac984e 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/SearchType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/interfaces/SearchType.java @@ -17,7 +17,8 @@ Quota, Disk, GlusterVolume, - Network; + Network, + GlusterVolumeGeorep; public int getValue() { return this.ordinal(); diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoreplicationDao.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoreplicationDao.java index 920ca68..5c603ea 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoreplicationDao.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoreplicationDao.java @@ -6,11 +6,12 @@ import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dao.DAO; import org.ovirt.engine.core.dao.MassOperationsDao; +import org.ovirt.engine.core.dao.SearchDAO; /** * Interface for DB operations on Gluster Volume Geo-replication. */ -public interface GlusterGeoreplicationDao extends DAO, MassOperationsDao<GlusterGeoreplicationEntity, Guid> { +public interface GlusterGeoreplicationDao extends DAO, SearchDAO<GlusterGeoreplicationEntity>, MassOperationsDao<GlusterGeoreplicationEntity, Guid> { public void save(GlusterGeoreplicationEntity geoReplicationEntity); @@ -41,5 +42,8 @@ Guid serverId, String remoteServer, String user); + + @Override + public List<GlusterGeoreplicationEntity> getAllWithQuery(String query); } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoreplicationDaoDbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoreplicationDaoDbFacadeImpl.java index 830453c..7ce09f2 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoreplicationDaoDbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoreplicationDaoDbFacadeImpl.java @@ -9,6 +9,7 @@ import org.ovirt.engine.core.dao.MassOperationsGenericDaoDbFacade; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.simple.ParameterizedRowMapper; +import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; public class GlusterGeoreplicationDaoDbFacadeImpl extends MassOperationsGenericDaoDbFacade<GlusterGeoreplicationEntity, Guid> @@ -150,4 +151,11 @@ } } + @Override + public List<GlusterGeoreplicationEntity> getAllWithQuery(String query) { + List<GlusterGeoreplicationEntity> georepEntities = + new SimpleJdbcTemplate(jdbcTemplate).query(query, georeplicationRowMapper); + return georepEntities; + } + } diff --git a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SearchObjectAutoCompleter.java b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SearchObjectAutoCompleter.java index fd499b6..9a0cd6f 100644 --- a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SearchObjectAutoCompleter.java +++ b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SearchObjectAutoCompleter.java @@ -26,6 +26,7 @@ mVerbs.put(SearchObjects.VDC_STORAGE_POOL_OBJ_NAME, SearchObjects.VDC_STORAGE_POOL_OBJ_NAME); mVerbs.put(SearchObjects.VDC_STORAGE_DOMAIN_OBJ_NAME, SearchObjects.VDC_STORAGE_DOMAIN_OBJ_NAME); mVerbs.put(SearchObjects.GLUSTER_VOLUME_PLU_OBJ_NAME, SearchObjects.GLUSTER_VOLUME_PLU_OBJ_NAME); + mVerbs.put(SearchObjects.GLUSTER_VOLUME_GEOREP_PLU_OBJ_NAME, SearchObjects.GLUSTER_VOLUME_GEOREP_PLU_OBJ_NAME); mVerbs.put(SearchObjects.QUOTA_OBJ_NAME, SearchObjects.QUOTA_OBJ_NAME); mVerbs.put(SearchObjects.NETWORK_PLU_OBJ_NAME, SearchObjects.NETWORK_PLU_OBJ_NAME); @@ -41,6 +42,7 @@ mVerbs.put(SearchObjects.VDC_USER_OBJ_NAME, SearchObjects.VDC_USER_OBJ_NAME); mVerbs.put(SearchObjects.VDC_CLUSTER_OBJ_NAME, SearchObjects.VDC_CLUSTER_OBJ_NAME); mVerbs.put(SearchObjects.GLUSTER_VOLUME_OBJ_NAME, SearchObjects.GLUSTER_VOLUME_OBJ_NAME); + mVerbs.put(SearchObjects.GLUSTER_VOLUME_GEOREP_OBJ_NAME, SearchObjects.GLUSTER_VOLUME_GEOREP_OBJ_NAME); mVerbs.put(SearchObjects.NETWORK_OBJ_NAME, SearchObjects.NETWORK_OBJ_NAME); // vms - vds @@ -106,6 +108,12 @@ // gluster volume - cluster addJoin(SearchObjects.GLUSTER_VOLUME_OBJ_NAME, "cluster_id", SearchObjects.VDC_CLUSTER_OBJ_NAME, "vds_group_id"); + // gluster volume georep - Volume + addJoin(SearchObjects.GLUSTER_VOLUME_GEOREP_OBJ_NAME, + "cluster_id", + SearchObjects.VDC_CLUSTER_OBJ_NAME, + "vds_group_id"); + // cluster - network addJoin(SearchObjects.VDC_CLUSTER_OBJ_NAME, "vds_group_id", @@ -126,6 +134,13 @@ // audit - gluster volume addJoin(SearchObjects.GLUSTER_VOLUME_OBJ_NAME, "id", SearchObjects.AUDIT_OBJ_NAME, "gluster_volume_id"); + + // audit - gluster volume georep + addJoin(SearchObjects.GLUSTER_VOLUME_GEOREP_OBJ_NAME, + "id", + SearchObjects.AUDIT_OBJ_NAME, + "gluster_volume_georep_id"); + // data center - network addJoin(SearchObjects.VDC_STORAGE_POOL_OBJ_NAME, "id", SearchObjects.NETWORK_OBJ_NAME, "storage_pool_id"); @@ -242,6 +257,15 @@ "gluster_volumes", "id", "vol_name ASC ")); + + put(SearchObjects.GLUSTER_VOLUME_GEOREP_OBJ_NAME, + new EntitySearchInfo(GlusterVolumeCrossRefAutoCompleter.INSTANCE, + GlusterVolumeConditionFieldAutoCompleter.INSTANCE, + null, + "gluster_georeplication_view", + "id", + "vol_name ASC ")); + put(SearchObjects.VDC_POOL_OBJ_NAME, new EntitySearchInfo(null, new PoolConditionFieldAutoCompleter(), null, @@ -298,6 +322,7 @@ put(SearchObjects.QUOTA_PLU_OBJ_NAME, SearchObjects.QUOTA_OBJ_NAME); put(SearchObjects.DISK_PLU_OBJ_NAME, SearchObjects.DISK_OBJ_NAME); put(SearchObjects.GLUSTER_VOLUME_PLU_OBJ_NAME, SearchObjects.GLUSTER_VOLUME_OBJ_NAME); + put(SearchObjects.GLUSTER_VOLUME_GEOREP_PLU_OBJ_NAME, SearchObjects.GLUSTER_VOLUME_GEOREP_OBJ_NAME); put(SearchObjects.VDC_POOL_PLU_OBJ_NAME, SearchObjects.VDC_POOL_OBJ_NAME); put(SearchObjects.VDC_STORAGE_DOMAIN_PLU_OBJ_NAME, SearchObjects.VDC_STORAGE_DOMAIN_OBJ_NAME); put(SearchObjects.NETWORK_PLU_OBJ_NAME, SearchObjects.NETWORK_OBJ_NAME); diff --git a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SearchObjects.java b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SearchObjects.java index f4c156d..e2bfdb4 100644 --- a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SearchObjects.java +++ b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SearchObjects.java @@ -30,6 +30,8 @@ public static final String DISK_PLU_OBJ_NAME = "DISKS"; public static final String GLUSTER_VOLUME_OBJ_NAME = "VOLUME"; public static final String GLUSTER_VOLUME_PLU_OBJ_NAME = "VOLUMES"; + public static final String GLUSTER_VOLUME_GEOREP_OBJ_NAME = "GEOREPLICATION"; + public static final String GLUSTER_VOLUME_GEOREP_PLU_OBJ_NAME = "GEOREPLICATIONS"; public static final String QUOTA_OBJ_NAME = "QUOTA"; public static final String QUOTA_PLU_OBJ_NAME = "QUOTAS"; public static final String NETWORK_OBJ_NAME = "NETWORK"; @@ -72,6 +74,8 @@ SAFE_SEARCH_EXPR.add(DISK_PLU_OBJ_NAME.toLowerCase() + SEPERATOR); SAFE_SEARCH_EXPR.add(GLUSTER_VOLUME_OBJ_NAME.toLowerCase() + SEPERATOR); SAFE_SEARCH_EXPR.add(GLUSTER_VOLUME_PLU_OBJ_NAME.toLowerCase() + SEPERATOR); + SAFE_SEARCH_EXPR.add(GLUSTER_VOLUME_GEOREP_OBJ_NAME.toLowerCase() + SEPERATOR); + SAFE_SEARCH_EXPR.add(GLUSTER_VOLUME_GEOREP_PLU_OBJ_NAME.toLowerCase() + SEPERATOR); SAFE_SEARCH_EXPR.add(QUOTA_OBJ_NAME.toLowerCase() + SEPERATOR); SAFE_SEARCH_EXPR.add(QUOTA_PLU_OBJ_NAME.toLowerCase() + SEPERATOR); SAFE_SEARCH_EXPR.add(NETWORK_OBJ_NAME.toLowerCase() + SEPERATOR); diff --git a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxContainer.java b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxContainer.java index 7019afb..17299b8 100644 --- a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxContainer.java +++ b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxContainer.java @@ -214,6 +214,10 @@ || StringHelper.EqOp(obj, SearchObjects.GLUSTER_VOLUME_PLU_OBJ_NAME)) { retval = SearchObjects.GLUSTER_VOLUME_OBJ_NAME; } + else if (StringHelper.EqOp(obj, SearchObjects.GLUSTER_VOLUME_GEOREP_OBJ_NAME) + || StringHelper.EqOp(obj, SearchObjects.GLUSTER_VOLUME_GEOREP_PLU_OBJ_NAME)) { + retval = SearchObjects.GLUSTER_VOLUME_GEOREP_OBJ_NAME; + } else if (StringHelper.EqOp(obj, SearchObjects.NETWORK_OBJ_NAME) || StringHelper.EqOp(obj, SearchObjects.NETWORK_PLU_OBJ_NAME)) { retval = SearchObjects.NETWORK_OBJ_NAME; diff --git a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/gluster/GlusterVolumeGeorepConditionFieldAutoCompleter.java b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/gluster/GlusterVolumeGeorepConditionFieldAutoCompleter.java new file mode 100644 index 0000000..fc0f518 --- /dev/null +++ b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/gluster/GlusterVolumeGeorepConditionFieldAutoCompleter.java @@ -0,0 +1,105 @@ +package org.ovirt.engine.core.searchbackend.gluster; + +import java.util.ArrayList; +import java.util.List; + +import org.ovirt.engine.core.searchbackend.BaseConditionFieldAutoCompleter; +import org.ovirt.engine.core.searchbackend.IAutoCompleter; +import org.ovirt.engine.core.searchbackend.IConditionValueAutoCompleter; +import org.ovirt.engine.core.searchbackend.StringConditionRelationAutoCompleter; + +/** + * Auto completer for conditions on Gluster Volume Georeplications. Gluster Volumes Geo-replication can be filtered on + * following fields:<br> + */ +public class GlusterVolumeGeorepConditionFieldAutoCompleter extends BaseConditionFieldAutoCompleter { + public final static GlusterVolumeGeorepConditionFieldAutoCompleter INSTANCE = new GlusterVolumeGeorepConditionFieldAutoCompleter(); + + private enum FIELDS { + REMOTE_SERVER, + STATUS + }; + + private static List<AutoCompletionField> fields; + + private static void populateAutoCompletionFields() { + fields = new ArrayList<AutoCompletionField>(); + + addField(FIELDS.REMOTE_SERVER.toString(), String.class, "remote_server"); + addField(FIELDS.STATUS.toString(), String.class, "status"); + } + + private GlusterVolumeGeorepConditionFieldAutoCompleter() { + super(); + populateAutoCompletionFields(); + buildDictionaries(); + } + + @Override + public IAutoCompleter getFieldRelationshipAutoCompleter(String fieldName) { + try { + switch (FIELDS.valueOf(fieldName.toUpperCase())) { + case REMOTE_SERVER: + case STATUS: + return StringConditionRelationAutoCompleter.INSTANCE; + default: + return null; + } + } catch (Exception e) { + return null; + } + } + + @Override + public IConditionValueAutoCompleter getFieldValueAutoCompleter(String fieldName) { + try { + switch (FIELDS.valueOf(fieldName.toUpperCase())) { + + default: + return null; + } + } catch (Exception e) { + return null; + } + } + + private static void addField(String fieldName, Class<?> fieldType, String columnName) { + fields.add(new AutoCompletionField(fieldName, fieldName, fieldType, columnName)); + } + + private void buildDictionaries() { + // Build the field name auto completion dictionary + for (AutoCompletionField field : fields) { + mVerbs.put(field.fieldName, field.displayName); + } + buildCompletions(); + + // Build the field type dictionary + for (AutoCompletionField field : fields) { + getTypeDictionary().put(field.fieldName, field.fieldType); + } + + // Build the column name dictionary + for (AutoCompletionField field : fields) { + mColumnNameDict.put(field.fieldName, field.columnName); + } + + // Build the validation dictionary + buildBasicValidationTable(); + } + + private static final class AutoCompletionField { + protected final String fieldName; + protected final String displayName; + protected final Class<?> fieldType; + protected final String columnName; + + public AutoCompletionField(String fieldName, String displayName, Class<?> fieldType, String columnName) { + this.fieldName = fieldName; + this.displayName = displayName; + this.fieldType = fieldType; + this.columnName = columnName; + } + } +} + diff --git a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/gluster/GlusterVolumeGeorepCrossRefAutoCompleter.java b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/gluster/GlusterVolumeGeorepCrossRefAutoCompleter.java new file mode 100644 index 0000000..d1b5eda --- /dev/null +++ b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/gluster/GlusterVolumeGeorepCrossRefAutoCompleter.java @@ -0,0 +1,19 @@ +package org.ovirt.engine.core.searchbackend.gluster; + +import org.ovirt.engine.core.searchbackend.SearchObjects; +import org.ovirt.engine.core.searchbackend.SearchObjectsBaseAutoCompleter; + +/** + * Cross reference auto completer for Gluster Volume Georeplication entity.<br> + * Adds the Volume entity cross reference so that Volume Geo-replications<br> + * can be filtered by a particular Volume. + */ +public class GlusterVolumeGeorepCrossRefAutoCompleter extends SearchObjectsBaseAutoCompleter { + public final static GlusterVolumeGeorepCrossRefAutoCompleter INSTANCE = new GlusterVolumeGeorepCrossRefAutoCompleter(); + + private GlusterVolumeGeorepCrossRefAutoCompleter() { + mVerbs.put(SearchObjects.GLUSTER_VOLUME_OBJ_NAME, SearchObjects.GLUSTER_VOLUME_OBJ_NAME); + mVerbs.put(SearchObjects.VDS_OBJ_NAME, SearchObjects.VDS_OBJ_NAME); + buildCompletions(); + } +} diff --git a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml index 2daa132..aa3f4ad 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml @@ -304,6 +304,7 @@ <include name="common/businessentities/gluster/MemoryStatus.java"/> <include name="common/businessentities/gluster/Mempool.java"/> <include name="common/businessentities/gluster/ServiceType.java"/> + <include name="common/businessentities/gluster/GlusterGeoreplicationEntity.java"/> <include name="common/action/gluster/*.java"/> <include name="common/queries/gluster/*.java"/> <include name="common/constants/gluster/GlusterConstants.java"/> -- To view, visit http://gerrit.ovirt.org/9999 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib8c8b9e480064364aff5daf1502334e22072982b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Selvasundaram <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
