Skip to content

Commit ccd623f

Browse files
authored
Merge pull request #2100 from Accelerite/CLOUDSTACK-9907
CLOUDSTACK-9907 Physical size of snapshot is considered for usage
2 parents be6e1a8 + 721f447 commit ccd623f

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎server/src/com/cloud/storage/snapshot/SnapshotManager.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public interface SnapshotManager {
4242
"Maximum recurring weekly snapshots to be retained for a volume. If the limit is reached, snapshots from the beginning of the week are deleted so that newer ones can be saved. This limit does not apply to manual snapshots. If set to 0, recurring weekly snapshots can not be scheduled.", false, ConfigKey.Scope.Global, null);
4343
static final ConfigKey<Integer> SnapshotMonthlyMax = new ConfigKey<Integer>(Integer.class, "snapshot.max.monthly", "Snapshots", "8",
4444
"Maximum recurring monthly snapshots to be retained for a volume. If the limit is reached, snapshots from the beginning of the month are deleted so that newer ones can be saved. This limit does not apply to manual snapshots. If set to 0, recurring monthly snapshots can not be scheduled.", false, ConfigKey.Scope.Global, null);
45-
45+
static final ConfigKey<Boolean> usageSnapshotSelection = new ConfigKey<Boolean>("Usage", Boolean.class, "usage.snapshot.virtualsize.select", "false",
46+
"Set the value to true if snapshot usage need to consider virtual size, else physical size is considered ", false);
4647
void deletePoliciesForVolume(Long volumeId);
4748

4849
/**

‎server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,5 +1339,5 @@ public String getConfigComponentName() {
13391339

13401340
@Override
13411341
public ConfigKey<?>[] getConfigKeys() {
1342-
return new ConfigKey<?>[] { SnapshotHourlyMax, SnapshotDailyMax, SnapshotMonthlyMax, SnapshotWeeklyMax}; }
1342+
return new ConfigKey<?>[] { SnapshotHourlyMax, SnapshotDailyMax, SnapshotMonthlyMax, SnapshotWeeklyMax, usageSnapshotSelection}; }
13431343
}

‎usage/src/com/cloud/usage/UsageManagerImpl.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
169169
private Future _scheduledFuture = null;
170170
private Future _heartbeat = null;
171171
private Future _sanity = null;
172+
private boolean usageSnapshotSelection = false;
172173

173174
public UsageManagerImpl() {
174175
}
@@ -208,6 +209,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
208209
String sanityCheckInterval = configs.get("usage.sanity.check.interval");
209210
String quotaEnable = configs.get("quota.enable.service");
210211
_runQuota = Boolean.valueOf(quotaEnable == null ? "false" : quotaEnable );
212+
usageSnapshotSelection = Boolean.valueOf(configs.get("usage.snapshot.virtualsize.select"));
211213
if (sanityCheckInterval != null) {
212214
_sanityCheckInterval = Integer.parseInt(sanityCheckInterval);
213215
}
@@ -1535,7 +1537,11 @@ private void createSnapshotHelperEvent(UsageEventVO event) {
15351537

15361538
long snapId = event.getResourceId();
15371539
if (EventTypes.EVENT_SNAPSHOT_CREATE.equals(event.getType())) {
1538-
snapSize = event.getSize();
1540+
if (usageSnapshotSelection){
1541+
snapSize = event.getVirtualSize();
1542+
}else {
1543+
snapSize = event.getSize();
1544+
}
15391545
zoneId = event.getZoneId();
15401546
}
15411547

0 commit comments

Comments
 (0)