Shubhendu Tripathi has uploaded a new change for review. Change subject: gluster: BLL query to get volume snapshot configurations ......................................................................
gluster: BLL query to get volume snapshot configurations Introduced BLL query to get the gluster volume snapshot configuration parameter details. If sync job is not yet executed and data not available in DB, it gets the details from gluster using a VDS call. Change-Id: I4374b51297549731bc6c93c8a72b033ca64fdfef Signed-off-by: Shubhendu Tripathi <[email protected]> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeSnapshotConfigQuery.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterQueriesCommandBase.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java 4 files changed, 59 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/49/39349/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeSnapshotConfigQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeSnapshotConfigQuery.java new file mode 100644 index 0000000..ab1cf0e --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeSnapshotConfigQuery.java @@ -0,0 +1,47 @@ +package org.ovirt.engine.core.bll.gluster; + +import java.util.ArrayList; +import java.util.List; + +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig; +import org.ovirt.engine.core.common.queries.gluster.GlusterVolumeQueriesParameters; +import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.core.compat.Guid; + +public class GetGlusterVolumeSnapshotConfigQuery<P extends GlusterVolumeQueriesParameters> extends GlusterQueriesCommandBase<P> { + public GetGlusterVolumeSnapshotConfigQuery(P parameters) { + super(parameters); + } + + private Pair<List<GlusterVolumeSnapshotConfig>, List<GlusterVolumeSnapshotConfig>> getConfigPair(List<GlusterVolumeSnapshotConfig> configs) { + List<GlusterVolumeSnapshotConfig> clusterCfgs = new ArrayList<>(); + List<GlusterVolumeSnapshotConfig> volumeCfgs = new ArrayList<>(); + + for (GlusterVolumeSnapshotConfig config : configs) { + if (Guid.isNullOrEmpty(config.getVolumeId())) { + clusterCfgs.add(config); + } else if (getParameters().getVolumeId() != null + && config.getVolumeId().equals(getParameters().getVolumeId())) { + volumeCfgs.add(config); + } + } + + return new Pair<List<GlusterVolumeSnapshotConfig>, List<GlusterVolumeSnapshotConfig>>(clusterCfgs, volumeCfgs); + } + + @Override + public void executeQueryCommand() { + List<GlusterVolumeSnapshotConfig> configs = + getGlusterVolumeSnapshotConfigDao().getConfigByClusterId(getParameters().getClusterId()); + + if (configs != null && configs.size() > 0) { + getQueryReturnValue().setReturnValue(getConfigPair(configs)); + } else { + GlusterSnapshotSyncJob.getInstance() + .refreshSnapshotConfigInCluster(getVdsGroupDao().get(getParameters().getClusterId())); + // fetch the configuration again after sync + configs = getGlusterVolumeSnapshotConfigDao().getConfigByClusterId(getParameters().getClusterId()); + getQueryReturnValue().setReturnValue(getConfigPair(configs)); + } + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterQueriesCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterQueriesCommandBase.java index ab30f28..50c71e4 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterQueriesCommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterQueriesCommandBase.java @@ -12,11 +12,13 @@ import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.dbbroker.DbFacade; +import org.ovirt.engine.core.dao.VdsGroupDAO; import org.ovirt.engine.core.dao.gluster.GlusterBrickDao; import org.ovirt.engine.core.dao.gluster.GlusterClusterServiceDao; import org.ovirt.engine.core.dao.gluster.GlusterHooksDao; import org.ovirt.engine.core.dao.gluster.GlusterServerServiceDao; import org.ovirt.engine.core.dao.gluster.GlusterVolumeDao; +import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotConfigDao; import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotDao; public abstract class GlusterQueriesCommandBase<P extends VdcQueryParametersBase> extends QueriesCommandBase<P> { @@ -57,10 +59,18 @@ return ClusterUtils.getInstance(); } + protected VdsGroupDAO getVdsGroupDao() { + return DbFacade.getInstance().getVdsGroupDao(); + } + protected GlusterVolumeSnapshotDao getGlusterVolumeSnapshotDao() { return DbFacade.getInstance().getGlusterVolumeSnapshotDao(); } + protected GlusterVolumeSnapshotConfigDao getGlusterVolumeSnapshotConfigDao() { + return DbFacade.getInstance().getGlusterVolumeSnapshotConfigDao(); + } + protected Guid getUpServerId(Guid clusterId) { VDS vds = getClusterUtils().getUpServer(clusterId); if (vds == null) { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java index 5b3c590b..05ad23f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java @@ -84,7 +84,7 @@ } } - private void refreshSnapshotConfigInCluster(VDSGroup cluster) { + public void refreshSnapshotConfigInCluster(VDSGroup cluster) { if (!supportsGlusterSnapshotFeature(cluster)) { return; } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java index 9ab850a..279d570 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java @@ -336,6 +336,7 @@ GetGlusterVolumeRemoveBricksStatus, GetGlusterVolumeByTaskId, GetGlusterVolumeSnapshotsByVolumeId, + GetGlusterVolumeSnapshotConfig, GetDefaultConfigurationVersion(VdcQueryAuthType.User), OsRepository(VdcQueryAuthType.User), -- To view, visit https://gerrit.ovirt.org/39349 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4374b51297549731bc6c93c8a72b033ca64fdfef Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5-gluster Gerrit-Owner: Shubhendu Tripathi <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
