Shubhendu Tripathi has uploaded a new change for review. Change subject: gluster: Entities for volume snapshot scheduling ......................................................................
gluster: Entities for volume snapshot scheduling Introduced entities for gluster volume snapshot scheduling. Change-Id: I010e5c3977af7adeac2e6865bb1a99280a40ea70 Signed-off-by: Shubhendu Tripathi <shtri...@redhat.com> --- A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotSchedule.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotScheduleRecurrence.java M packaging/dbscripts/create_views.sql A packaging/dbscripts/upgrade/03_05_1280_add_gluster_volume_snapshot_schedule_tables.sql 4 files changed, 248 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/39291/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotSchedule.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotSchedule.java new file mode 100644 index 0000000..ba3210b --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotSchedule.java @@ -0,0 +1,200 @@ +package org.ovirt.engine.core.common.businessentities.gluster; + +import java.sql.Time; +import java.util.Date; + +import org.ovirt.engine.core.common.businessentities.IVdcQueryable; +import org.ovirt.engine.core.common.utils.ObjectUtils; +import org.ovirt.engine.core.compat.Guid; + +public class GlusterVolumeSnapshotSchedule extends IVdcQueryable { + private static final long serialVersionUID = 2L; + private Guid clusterId; + private Guid volumeId; + private String jobId; + private String snapshotNamePrefix; + private String snapshotDescription; + private GlusterVolumeSnapshotScheduleRecurrence recurrence; + private String timeZone; + private Integer interval; + private Date startDate; + private Time executionTime; + private String days; + private Date endByDate; + + public Guid getClusterId() { + return this.clusterId; + } + + public void setClusterId(Guid id) { + this.clusterId = id; + } + + public Guid getVolumeId() { + return volumeId; + } + + public void setVolumeId(Guid volumeId) { + this.volumeId = volumeId; + } + + public String getJobId() { + return this.jobId; + } + + public void setJobId(String id) { + this.jobId = id; + } + + public String getSnapshotNamePrefix() { + return this.snapshotNamePrefix; + } + + public void setSnapshotNamePrefix(String prefix) { + this.snapshotNamePrefix = prefix; + } + + public String getSnapshotDescription() { + return this.snapshotDescription; + } + + public void setSnapshotDescription(String description) { + this.snapshotDescription = description; + } + + public GlusterVolumeSnapshotScheduleRecurrence getRecurrence() { + return recurrence; + } + + public void setRecurrence(GlusterVolumeSnapshotScheduleRecurrence recurrence) { + this.recurrence = recurrence; + } + + public String getTimeZone() { + return this.timeZone; + } + + public void setTimeZone(String timeZone) { + this.timeZone = timeZone; + } + + public Integer getInterval() { + return interval; + } + + public void setInterval(Integer interval) { + this.interval = interval; + } + + public Date getStartDate() { + return startDate; + } + + public void setStartDate(Date startDate) { + this.startDate = startDate; + } + + public Time getExecutionTime() { + return executionTime; + } + + public void setExecutionTime(Time executionTime) { + this.executionTime = executionTime; + } + + public String getDays() { + return this.days; + } + + public void setDays(String days) { + this.days = days; + } + + public Date getEndByDate() { + return endByDate; + } + + public void setEndByDate(Date endByDate) { + this.endByDate = endByDate; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + + result = prime * result + (clusterId == null ? 0 : clusterId.hashCode()); + result = prime * result + (volumeId == null ? 0 : volumeId.hashCode()); + result = prime * result + (jobId == null ? 0 : jobId.hashCode()); + result = prime * result + (snapshotNamePrefix == null ? 0 : snapshotNamePrefix.hashCode()); + result = prime * result + (snapshotDescription == null ? 0 : snapshotDescription.hashCode()); + result = prime * result + (recurrence == null ? 0 : recurrence.hashCode()); + result = prime * result + (timeZone == null ? 0 : timeZone.hashCode()); + result = prime * result + (interval == null ? 0 : interval.hashCode()); + result = prime * result + (startDate == null ? 0 : startDate.hashCode()); + result = prime * result + (executionTime == null ? 0 : executionTime.hashCode()); + result = prime * result + (days == null ? 0 : days.hashCode()); + result = prime * result + (endByDate == null ? 0 : endByDate.hashCode()); + + return result; + } + + @Override + public boolean equals(Object obj) { + if (obj == null || !(obj instanceof GlusterVolumeSnapshotSchedule)) { + return false; + } + + GlusterVolumeSnapshotSchedule schedule = (GlusterVolumeSnapshotSchedule) obj; + + if (!(ObjectUtils.objectsEqual(clusterId, schedule.getClusterId()))) { + return false; + } + + if (!(ObjectUtils.objectsEqual(volumeId, schedule.getVolumeId()))) { + return false; + } + + if (!(ObjectUtils.objectsEqual(jobId, schedule.getJobId()))) { + return false; + } + + if (!ObjectUtils.objectsEqual(snapshotNamePrefix, schedule.getSnapshotNamePrefix())) { + return false; + } + + if (!ObjectUtils.objectsEqual(snapshotDescription, schedule.getSnapshotDescription())) { + return false; + } + + if (!(ObjectUtils.objectsEqual(recurrence, schedule.getRecurrence()))) { + return false; + } + + if (!ObjectUtils.objectsEqual(timeZone, schedule.getTimeZone())) { + return false; + } + + if (!(ObjectUtils.objectsEqual(interval, schedule.getInterval()))) { + return false; + } + + if (!(ObjectUtils.objectsEqual(startDate, schedule.getStartDate()))) { + return false; + } + + if (!(ObjectUtils.objectsEqual(executionTime, schedule.getExecutionTime()))) { + return false; + } + + if (!(ObjectUtils.objectsEqual(days, schedule.getDays()))) { + return false; + } + + if (!(ObjectUtils.objectsEqual(endByDate, schedule.getEndByDate()))) { + return false; + } + + return true; + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotScheduleRecurrence.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotScheduleRecurrence.java new file mode 100644 index 0000000..8a79a9a --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotScheduleRecurrence.java @@ -0,0 +1,20 @@ +package org.ovirt.engine.core.common.businessentities.gluster; + +public enum GlusterVolumeSnapshotScheduleRecurrence { + INTERVAL, + HOURLY, + DAILY, + WEEKLY, + MONTHLY, + UNKNOWN; + + public static GlusterVolumeSnapshotScheduleRecurrence from(String value) { + for (GlusterVolumeSnapshotScheduleRecurrence recurrence : values()) { + if (recurrence.name().equals(value)) { + return recurrence; + } + } + + return GlusterVolumeSnapshotScheduleRecurrence.UNKNOWN; + } +} diff --git a/packaging/dbscripts/create_views.sql b/packaging/dbscripts/create_views.sql index a96c845..7ef2dbc 100644 --- a/packaging/dbscripts/create_views.sql +++ b/packaging/dbscripts/create_views.sql @@ -1730,6 +1730,13 @@ FROM gluster_volume_snapshots INNER JOIN gluster_volumes ON gluster_volume_snapshots.volume_id = gluster_volumes.id; +CREATE OR REPLACE VIEW gluster_volume_snapshot_schedules_view +AS +SELECT gluster_volume_snapshot_schedules.*, + gluster_volumes.cluster_id AS cluster_id +FROM gluster_volume_snapshot_schedules +INNER JOIN gluster_volumes ON gluster_volume_snapshot_schedules.volume_id = gluster_volumes.id; + CREATE OR REPLACE VIEW gluster_volume_bricks_view AS SELECT gluster_volume_bricks.*, diff --git a/packaging/dbscripts/upgrade/03_05_1280_add_gluster_volume_snapshot_schedule_tables.sql b/packaging/dbscripts/upgrade/03_05_1280_add_gluster_volume_snapshot_schedule_tables.sql new file mode 100644 index 0000000..fb80ff6 --- /dev/null +++ b/packaging/dbscripts/upgrade/03_05_1280_add_gluster_volume_snapshot_schedule_tables.sql @@ -0,0 +1,21 @@ +-- Add gluster_volume_snapshot_schedules table +CREATE TABLE gluster_volume_snapshot_schedules +( + volume_id UUID NOT NULL, + job_id VARCHAR(256) NOT NULL, + snapshot_name_prefix VARCHAR(128), + snapshot_description VARCHAR(1024), + recurrence VARCHAR(128) NOT NULL, + time_zone VARCHAR(128), + interval INTEGER, + start_date TIMESTAMP WITH TIME ZONE, + execution_time TIME, + days VARCHAR(256), + end_by TIMESTAMP WITH TIME ZONE, + _create_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT LOCALTIMESTAMP, + _update_date TIMESTAMP WITH TIME ZONE, + CONSTRAINT pk_volume_id PRIMARY KEY(volume_id) +) WITH OIDS; + +SELECT fn_db_create_constraint('gluster_volume_snapshot_schedules', 'fk_gluster_volume_snapshot_schedules_volume_id', 'FOREIGN KEY (volume_id) REFERENCES gluster_volumes(id) ON DELETE CASCADE'); + -- To view, visit https://gerrit.ovirt.org/39291 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I010e5c3977af7adeac2e6865bb1a99280a40ea70 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5-gluster Gerrit-Owner: Shubhendu Tripathi <shtri...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches