Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion server/src/com/cloud/storage/snapshot/SnapshotManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public interface SnapshotManager {
"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);
static final ConfigKey<Integer> SnapshotMonthlyMax = new ConfigKey<Integer>(Integer.class, "snapshot.max.monthly", "Snapshots", "8",
"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);

static final ConfigKey<Boolean> usageSnapshotSelection = new ConfigKey<Boolean>("Usage", Boolean.class, "usage.snapshot.virtualsize.select", "false",
"Set the value to true if snapshot usage need to consider virtual size, else physical size is considered ", false);
void deletePoliciesForVolume(Long volumeId);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1328,5 +1328,5 @@ public String getConfigComponentName() {

@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] { SnapshotHourlyMax, SnapshotDailyMax, SnapshotMonthlyMax, SnapshotWeeklyMax}; }
return new ConfigKey<?>[] { SnapshotHourlyMax, SnapshotDailyMax, SnapshotMonthlyMax, SnapshotWeeklyMax, usageSnapshotSelection}; }
}
8 changes: 7 additions & 1 deletion usage/src/com/cloud/usage/UsageManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
private Future _scheduledFuture = null;
private Future _heartbeat = null;
private Future _sanity = null;
private boolean usageSnapshotSelection = false;

public UsageManagerImpl() {
}
Expand Down Expand Up @@ -208,6 +209,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
String sanityCheckInterval = configs.get("usage.sanity.check.interval");
String quotaEnable = configs.get("quota.enable.service");
_runQuota = Boolean.valueOf(quotaEnable == null ? "false" : quotaEnable );
usageSnapshotSelection = Boolean.valueOf(configs.get("usage.snapshot.virtualsize.select"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use usageSnapshotSelection.value() instead of configs.get

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jayapalu It is effecting existing implementations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

if (sanityCheckInterval != null) {
_sanityCheckInterval = Integer.parseInt(sanityCheckInterval);
}
Expand Down Expand Up @@ -1535,7 +1537,11 @@ private void createSnapshotHelperEvent(UsageEventVO event) {

long snapId = event.getResourceId();
if (EventTypes.EVENT_SNAPSHOT_CREATE.equals(event.getType())) {
snapSize = event.getSize();
if (usageSnapshotSelection){
snapSize = event.getVirtualSize();
}else {
snapSize = event.getSize();
}
zoneId = event.getZoneId();
}

Expand Down