From 36bd6f585903f8226f7eb5870ae855fe3da417dc Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 13 Jul 2011 18:24:14 -0700 Subject: [PATCH] bug 10691: expand try-catch, and add more log --- .../snapshot/SnapshotSchedulerImpl.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java index 3d5dfb0697a..6d5bc42844c 100644 --- a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java @@ -214,27 +214,29 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler { long userId = 1; for (SnapshotScheduleVO snapshotToBeExecuted : snapshotsToBeExecuted) { + SnapshotScheduleVO tmpSnapshotScheduleVO = null; + long snapshotScheId = snapshotToBeExecuted.getId(); long policyId = snapshotToBeExecuted.getPolicyId(); long volumeId = snapshotToBeExecuted.getVolumeId(); - VolumeVO volume = _volsDao.findById(volumeId); - if ( volume.getPoolId() == null) { - // this volume is not attached - continue; - } - if ( _snapshotPolicyDao.findById(policyId) == null ) { - _snapshotScheduleDao.remove(snapshotToBeExecuted.getId()); - } - if (s_logger.isDebugEnabled()) { - Date scheduledTimestamp = snapshotToBeExecuted.getScheduledTimestamp(); - displayTime = DateUtil.displayDateInTimezone(DateUtil.GMT_TIMEZONE, scheduledTimestamp); - s_logger.debug("Scheduling 1 snapshot for volume " + volumeId + " for schedule id: " - + snapshotToBeExecuted.getId() + " at " + displayTime); - } - long snapshotScheId = snapshotToBeExecuted.getId(); - SnapshotScheduleVO tmpSnapshotScheduleVO = null; try { - tmpSnapshotScheduleVO = _snapshotScheduleDao.acquireInLockTable(snapshotScheId); + VolumeVO volume = _volsDao.findById(volumeId); + if ( volume.getPoolId() == null) { + // this volume is not attached + continue; + } + if ( _snapshotPolicyDao.findById(policyId) == null ) { + _snapshotScheduleDao.remove(snapshotToBeExecuted.getId()); + } + if (s_logger.isDebugEnabled()) { + Date scheduledTimestamp = snapshotToBeExecuted.getScheduledTimestamp(); + displayTime = DateUtil.displayDateInTimezone(DateUtil.GMT_TIMEZONE, scheduledTimestamp); + s_logger.debug("Scheduling 1 snapshot for volume " + volumeId + " for schedule id: " + + snapshotToBeExecuted.getId() + " at " + displayTime); + } + + + tmpSnapshotScheduleVO = _snapshotScheduleDao.acquireInLockTable(snapshotScheId); Long eventId = EventUtils.saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SNAPSHOT_CREATE, "creating snapshot for volume Id:"+volumeId,0); @@ -266,7 +268,7 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler { } catch (Exception e) { s_logger.debug("Scheduling snapshot failed due to " + e.toString(), e); } finally { - if (tmpSnapshotScheduleVO != null) { + if ( tmpSnapshotScheduleVO != null) { _snapshotScheduleDao.releaseFromLockTable(snapshotScheId); } }