diff --git a/core/src/com/cloud/storage/Snapshot.java b/core/src/com/cloud/storage/Snapshot.java index 62ca195ce69..87ae90509f0 100644 --- a/core/src/com/cloud/storage/Snapshot.java +++ b/core/src/com/cloud/storage/Snapshot.java @@ -39,8 +39,7 @@ public interface Snapshot { Creating, CreatedOnPrimary, BackingUp, - BackedUp, - EmptySnapshot; + BackedUp; public String toString() { return this.name(); diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index f17d861b05a..f4daf1068b8 100644 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -93,11 +93,12 @@ public enum Config { // ConsoleProxyURLPort("Console Proxy", ManagementServer.class, Integer.class, "consoleproxy.url.port", "80", "Console proxy port for AJAX viewer", null), // Snapshots - SnapshotHourlyMax("Snapshots", SnapshotManager.class, String.class, "snapshot.max.hourly", "8", "Maximum hourly snapshots for a volume", null), - SnapshotDailyMax("Snapshots", SnapshotManager.class, String.class, "snapshot.max.daily", "8", "Maximum dalily snapshots for a volume", null), - SnapshotWeeklyMax("Snapshots", SnapshotManager.class, String.class, "snapshot.max.weekly", "8", "Maximum hourly snapshots for a volume", null), - SnapshotMonthlyMax("Snapshots", SnapshotManager.class, String.class, "snapshot.max.monthly", "8", "Maximum hourly snapshots for a volume", null), - SnapshotPollInterval("Snapshots", SnapshotManager.class, Boolean.class, "snapshot.poll.interval", "300", "The time interval in seconds when the management server polls for snapshots to be scheduled.", null), + SnapshotHourlyMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.max.hourly", "8", "Maximum hourly snapshots for a volume", null), + SnapshotDailyMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.max.daily", "8", "Maximum dalily snapshots for a volume", null), + SnapshotWeeklyMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.max.weekly", "8", "Maximum hourly snapshots for a volume", null), + SnapshotMonthlyMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.max.monthly", "8", "Maximum hourly snapshots for a volume", null), + SnapshotPollInterval("Snapshots", SnapshotManager.class, Integer.class, "snapshot.poll.interval", "300", "The time interval in seconds when the management server polls for snapshots to be scheduled.", null), + SnapshotDeltaMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.delta.max", "16", "max delta snapshots between two full snapshots.", null), // Advanced JobExpireMinutes("Advanced", ManagementServer.class, String.class, "job.expire.minutes", "1440", "Time (in minutes) for async-jobs to be kept in system", null), diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManager.java b/server/src/com/cloud/storage/snapshot/SnapshotManager.java index ca4b1f81005..8ece39d9270 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManager.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManager.java @@ -46,6 +46,7 @@ public interface SnapshotManager extends Manager { public static final int DAILYMAX = 8; public static final int WEEKLYMAX = 8; public static final int MONTHLYMAX = 8; + public static final int DELTAMAX = 16; /** * Create a snapshot of a volume diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 899c867744c..c3fee935df4 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -129,6 +129,7 @@ public class SnapshotManagerImpl implements SnapshotManager { String _name; private int _totalRetries; private int _pauseInterval; + private int _deltaSnapshotMax; protected SearchBuilder PolicySnapshotSearch; protected SearchBuilder PoliciesForSnapSearch; @@ -297,27 +298,15 @@ public class SnapshotManagerImpl implements SnapshotManager { createdSnapshot = _snapshotDao.findById(id); // delete from the snapshots table _snapshotDao.expunge(id); - - createdSnapshot.setStatus(Status.EmptySnapshot); + throw new CloudRuntimeException("There is no change for volume " + volumeId + " since last snapshot, please use last snapshot instead."); } else { long preSnapshotId = 0; if( preSnapshotVO != null && preSnapshotVO.getBackupSnapshotId() != null) { preSnapshotId = preId; - // default delta snap number is 4 - int deltaSnap = 4; - if( policyId != Snapshot.MANUAL_POLICY_ID ) { - SnapshotPolicyVO snapshotPolicy = _snapshotPolicyDao.findById(policyId); - int maxSnap = snapshotPolicy.getMaxSnaps(); - deltaSnap = (maxSnap + 1) >> 1; - } else { - // check if there are policy for this volume - SnapshotPolicyVO snapshotPolicy = _snapshotPolicyDao.findOneByVolume(volumeId); - if( snapshotPolicy != null ) { - int maxSnap = snapshotPolicy.getMaxSnaps(); - deltaSnap = (maxSnap + 1) >> 1; - } - } + // default delta snap number is 16 + int deltaSnap = _deltaSnapshotMax; + int i; for (i = 1; i < deltaSnap; i++) { String prevBackupUuid = preSnapshotVO.getBackupSnapshotId(); @@ -347,7 +336,6 @@ public class SnapshotManagerImpl implements SnapshotManager { _snapshotScheduleDao.update(snapshotSchedule.getId(), snapshotSchedule); } } - } else { if (answer != null) { s_logger.error(answer.getDetails()); @@ -355,8 +343,8 @@ public class SnapshotManagerImpl implements SnapshotManager { // The snapshot was not successfully created createdSnapshot = _snapshotDao.findById(id); // delete from the snapshots table - _snapshotDao.expunge(id); - + _snapshotDao.expunge(id); + throw new CloudRuntimeException("Creating snapshot for volume " + volumeId + " on primary storage failed."); } return createdSnapshot; @@ -1150,6 +1138,7 @@ public class SnapshotManagerImpl implements SnapshotManager { DateUtil.IntervalType.DAILY.setMax(NumbersUtil.parseInt(configDao.getValue("snapshot.max.daily"), DAILYMAX)); DateUtil.IntervalType.WEEKLY.setMax(NumbersUtil.parseInt(configDao.getValue("snapshot.max.weekly"), WEEKLYMAX)); DateUtil.IntervalType.MONTHLY.setMax(NumbersUtil.parseInt(configDao.getValue("snapshot.max.monthly"), MONTHLYMAX)); + _deltaSnapshotMax = NumbersUtil.parseInt(configDao.getValue("snapshot.delta.max"), DELTAMAX); _totalRetries = NumbersUtil.parseInt(configDao.getValue("total.retries"), 4); _pauseInterval = 2*NumbersUtil.parseInt(configDao.getValue("ping.interval"), 60); diff --git a/server/src/com/cloud/test/DatabaseConfig.java b/server/src/com/cloud/test/DatabaseConfig.java index 881a5dec434..aed35560ab0 100644 --- a/server/src/com/cloud/test/DatabaseConfig.java +++ b/server/src/com/cloud/test/DatabaseConfig.java @@ -199,6 +199,11 @@ public class DatabaseConfig { s_configurationDescriptions.put("use.local.storage", "Indicates whether to use local storage pools or shared storage pools for user VMs"); s_configurationDescriptions.put("use.local.storage", "Indicates whether to use local storage pools or shared storage pools for system VMs."); s_configurationDescriptions.put("snapshot.poll.interval", "The time interval in seconds when the management server polls for snapshots to be scheduled."); + s_configurationDescriptions.put("snapshot.max.hourly", "Maximum hourly snapshots for a volume"); + s_configurationDescriptions.put("snapshot.max.daily", "Maximum dalily snapshots for a volume"); + s_configurationDescriptions.put("snapshot.max.weekly", "Maximum hourly snapshots for a volume"); + s_configurationDescriptions.put("snapshot.max.monthly", "Maximum hourly snapshots for a volume"); + s_configurationDescriptions.put("snapshot.delta.max", "max delta snapshots between two full snapshots."); s_configurationDescriptions.put("snapshot.recurring.test", "Flag for testing recurring snapshots"); s_configurationDescriptions.put("snapshot.test.minutes.per.hour", "Set it to a smaller value to take more recurring snapshots"); s_configurationDescriptions.put("snapshot.test.hours.per.day", "Set it to a smaller value to take more recurring snapshots"); @@ -272,6 +277,11 @@ public class DatabaseConfig { s_configurationComponents.put("system.vm.use.local.storage", "ManagementServer"); s_configurationComponents.put("use.local.storage", "ManagementServer"); s_configurationComponents.put("snapshot.poll.interval", "SnapshotManager"); + s_configurationComponents.put("snapshot.max.hourly", "SnapshotManager"); + s_configurationComponents.put("snapshot.max.daily", "SnapshotManager"); + s_configurationComponents.put("snapshot.max.weekly", "SnapshotManager"); + s_configurationComponents.put("snapshot.max.monthly", "SnapshotManager"); + s_configurationComponents.put("snapshot.delta.max", "SnapshotManager"); s_configurationComponents.put("snapshot.recurring.test", "SnapshotManager"); s_configurationComponents.put("snapshot.test.minutes.per.hour", "SnapshotManager"); s_configurationComponents.put("snapshot.test.hours.per.day", "SnapshotManager"); @@ -297,6 +307,11 @@ public class DatabaseConfig { s_defaultConfigurationValues.put("ping.timeout", "2.5"); s_defaultConfigurationValues.put("ping.interval", "60"); s_defaultConfigurationValues.put("snapshot.poll.interval", "300"); + s_defaultConfigurationValues.put("snapshot.max.hourly", "8"); + s_defaultConfigurationValues.put("snapshot.max.daily", "8"); + s_defaultConfigurationValues.put("snapshot.max.weekly", "8"); + s_defaultConfigurationValues.put("snapshot.max.monthly", "8"); + s_defaultConfigurationValues.put("snapshot.delta.max", "16"); s_defaultConfigurationValues.put("snapshot.recurring.test", "false"); s_defaultConfigurationValues.put("snapshot.test.minutes.per.hour", "60"); s_defaultConfigurationValues.put("snapshot.test.hours.per.day", "24");