Shubhendu Tripathi has uploaded a new change for review.

Change subject: gluster: Propagate the scheduler error to UI
......................................................................

gluster: Propagate the scheduler error to UI

Earlier the scheduler execption scenarios were just
logged and UI used to show Internal Error. Corrected
to porpagate the errors to UI properly.

Change-Id: I2630cb8701d394da8a658c3ba677616f026625a2
Bug-Url: https://bugzilla.redhat.com/1224691
Signed-off-by: Shubhendu Tripathi <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RescheduleGlusterVolumeSnapshotCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommandBase.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
M 
backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/DBSchedulerUtilQuartzImpl.java
M 
backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtil.java
M 
backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilBaseImpl.java
7 files changed, 52 insertions(+), 37 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/22/41822/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RescheduleGlusterVolumeSnapshotCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RescheduleGlusterVolumeSnapshotCommand.java
index a494632..01fec22 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RescheduleGlusterVolumeSnapshotCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RescheduleGlusterVolumeSnapshotCommand.java
@@ -29,16 +29,21 @@
             // Keep a copy of the execution time before conversion to engine 
time zone
             Time originalExecutionTime = schedule.getExecutionTime();
 
-            String newJobId = scheduleJob();
+            try {
+                String newJobId = scheduleJob();
 
-            if (newJobId != null) {
-                setSucceeded(true);
-                schedule.setJobId(newJobId);
-                // reverting to original execution time in UI populated time 
zone
-                schedule.setExecutionTime(originalExecutionTime);
-                
getGlusterVolumeSnapshotScheduleDao().updateScheduleByVolumeId(volumeId, 
schedule);
-            } else {
+                if (newJobId != null) {
+                    setSucceeded(true);
+                    schedule.setJobId(newJobId);
+                    // reverting to original execution time in UI populated 
time zone
+                    schedule.setExecutionTime(originalExecutionTime);
+                    
getGlusterVolumeSnapshotScheduleDao().updateScheduleByVolumeId(volumeId, 
schedule);
+                } else {
+                    setSucceeded(false);
+                }
+            } catch (Exception ex) {
                 setSucceeded(false);
+                
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESCHEDULE_FAILED, 
ex.getMessage());
             }
         } else {
             getGlusterVolumeSnapshotScheduleDao().removeByVolumeId(volumeId);
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommand.java
index a886c91..ca873b5 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommand.java
@@ -18,16 +18,21 @@
         Time originalExecutionTime = getSchedule().getExecutionTime();
 
         // schedule the snapshot creation task
-        String jobId = scheduleJob();
+        try {
+            String jobId = scheduleJob();
 
-        if (jobId != null) {
-            setSucceeded(true);
-            getSchedule().setJobId(jobId);
-            // reverting to original execution time in UI populated time zone
-            getSchedule().setExecutionTime(originalExecutionTime);
-            getGlusterVolumeSnapshotScheduleDao().save(getSchedule());
-        } else {
+            if (jobId != null) {
+                setSucceeded(true);
+                getSchedule().setJobId(jobId);
+                // reverting to original execution time in UI populated time 
zone
+                getSchedule().setExecutionTime(originalExecutionTime);
+                getGlusterVolumeSnapshotScheduleDao().save(getSchedule());
+            } else {
+                setSucceeded(false);
+            }
+        } catch (Exception ex) {
             setSucceeded(false);
+            
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_SCHEDULE_FAILED, 
ex.getMessage());
         }
     }
 
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommandBase.java
index 54940a1..4c790b1 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/ScheduleGlusterVolumeSnapshotCommandBase.java
@@ -3,6 +3,8 @@
 import java.sql.Time;
 import java.util.Date;
 
+import javax.inject.Inject;
+
 import org.ovirt.engine.core.bll.utils.GlusterUtil;
 import 
org.ovirt.engine.core.common.action.gluster.ScheduleGlusterVolumeSnapshotParameters;
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus;
@@ -13,8 +15,6 @@
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
 import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotScheduleDao;
 import org.ovirt.engine.core.utils.timer.DBSchedulerUtilQuartzImpl;
-
-import javax.inject.Inject;
 
 public abstract class ScheduleGlusterVolumeSnapshotCommandBase<T extends 
ScheduleGlusterVolumeSnapshotParameters> extends GlusterSnapshotCommandBase<T> {
     private GlusterVolumeSnapshotSchedule schedule;
@@ -67,7 +67,7 @@
         return true;
     }
 
-    protected String scheduleJob() {
+    protected String scheduleJob() throws Exception {
         // convert the execution time to engine time zone
         if (schedule.getExecutionTime() != null) {
             Time convertedTime =
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index f96c406..c44f198 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -895,6 +895,10 @@
 GLUSTER_MASTER_VOLUME_SNAPSHOT_RESTORE_FAILED=Could not restore master volume 
${glusterVolumeName}.
 GLUSTER_VOLUME_SNAPSHOT_CREATED=Snapshot ${snapname} created for volume 
${glusterVolumeName} on cluster ${vdsGroupName}.
 GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED=Could not create snapshot for volume 
${glusterVolumeName} on cluster ${vdsGroupName}.
+GLUSTER_VOLUME_SNAPSHOT_SCHEDULED=Snapshots scheduled on volume 
${glusterVolumeName} of cluster ${vdsGroupName}.
+GLUSTER_VOLUME_SNAPSHOT_SCHEDULE_FAILED=Failed to schedule snapshots on the 
volume ${glusterVolumeName} of cluster ${vdsGroupName}.
+GLUSTER_VOLUME_SNAPSHOT_RESCHEDULED=Rescheduled snapshots on volume 
${glusterVolumeName} of cluster ${vdsGroupName}.
+GLUSTER_VOLUME_SNAPSHOT_RESCHEDULE_FAILED=Failed to reschedule snapshots on 
volume ${glusterVolumeName} of cluster ${vdsGroupName}.
 CREATE_GLUSTER_BRICK=Brick ${brickName} created successfully.
 CREATE_GLUSTER_BRICK_FAILED=Failed to create brick ${brickName}.
 GLUSTER_VOLUME_SNAPSHOT_SCHEDULE_DELETED=Snapshot schedule deleted for volume 
${glusterVolumeName} of ${vdsGroupName}.
diff --git 
a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/DBSchedulerUtilQuartzImpl.java
 
b/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/DBSchedulerUtilQuartzImpl.java
index f1911d1..bb72c75 100644
--- 
a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/DBSchedulerUtilQuartzImpl.java
+++ 
b/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/DBSchedulerUtilQuartzImpl.java
@@ -1,5 +1,17 @@
 package org.ovirt.engine.core.utils.timer;
 
+import static org.quartz.JobBuilder.newJob;
+import static org.quartz.impl.matchers.GroupMatcher.jobGroupEquals;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Singleton;
+
 import org.apache.commons.lang.ClassUtils;
 import org.ovirt.engine.core.utils.ResourceUtils;
 import org.quartz.JobDataMap;
@@ -8,17 +20,6 @@
 import org.quartz.SchedulerException;
 import org.quartz.SchedulerFactory;
 import org.quartz.impl.StdSchedulerFactory;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.inject.Singleton;
-import java.io.IOException;
-import java.util.Date;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import static org.quartz.JobBuilder.newJob;
-import static org.quartz.impl.matchers.GroupMatcher.jobGroupEquals;
 
 @Singleton
 public class DBSchedulerUtilQuartzImpl extends SchedulerUtilBaseImpl 
implements SchedulerUtil {
@@ -157,7 +158,7 @@
             Object[] inputParams,
             String cronExpression,
             Date startAt,
-            Date endBy) {
+            Date endBy) throws Exception {
         if (!validate(instance, inputTypes)) {
             return null;
         }
diff --git 
a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtil.java
 
b/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtil.java
index d78561f..8cbbacd 100644
--- 
a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtil.java
+++ 
b/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtil.java
@@ -1,10 +1,10 @@
 package org.ovirt.engine.core.utils.timer;
 
-import org.quartz.Scheduler;
-import org.quartz.Trigger;
-
 import java.util.Date;
 import java.util.concurrent.TimeUnit;
+
+import org.quartz.Scheduler;
+import org.quartz.Trigger;
 
 public interface SchedulerUtil {
 
@@ -167,7 +167,7 @@
                             Object[] inputParams,
                             String cronExpression,
                             Date startAt,
-                            Date endBy);
+                            Date endBy) throws Exception;
 
 
     /**
diff --git 
a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilBaseImpl.java
 
b/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilBaseImpl.java
index 5f1c1392..3bd5c20 100644
--- 
a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilBaseImpl.java
+++ 
b/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilBaseImpl.java
@@ -254,7 +254,7 @@
             Object[] inputParams,
             String cronExpression,
             Date startAt,
-            Date endBy) {
+            Date endBy) throws Exception {
         JobDetail job = createJobWithBasicMapValues(instance, methodName, 
inputTypes, inputParams);
         try {
             String triggerName = generateUniqueNameForInstance(instance, 
TRIGGER_PREFIX);
@@ -268,7 +268,7 @@
         } catch (Exception se) {
             log.error("failed to schedule job: {}", se.getMessage());
             log.debug("Exception", se);
-            return null;
+            throw se;
         }
         return job.getKey().getName();
     }


-- 
To view, visit https://gerrit.ovirt.org/41822
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2630cb8701d394da8a658c3ba677616f026625a2
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Shubhendu Tripathi <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to