Repository navigation
Events listing, deletion and archival optimizations #11443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,6 @@ | |
| import org.apache.cloudstack.context.CallContext; | ||
|
|
||
| import com.cloud.event.Event; | ||
| import com.cloud.exception.InvalidParameterValueException; | ||
| import com.cloud.user.Account; | ||
|
|
||
| @APICommand(name = "deleteEvents", description = "Delete one or more events.", responseObject = SuccessResponse.class, entityType = {Event.class}, | ||
|
|
@@ -82,6 +81,22 @@ public String getType() { | |
| return type; | ||
| } | ||
|
|
||
| public void setIds(List<Long> ids) { | ||
| this.ids = ids; | ||
| } | ||
|
|
||
| public void setEndDate(Date endDate) { | ||
| this.endDate = endDate; | ||
| } | ||
|
|
||
| public void setStartDate(Date startDate) { | ||
| this.startDate = startDate; | ||
| } | ||
|
|
||
| public void setType(String type) { | ||
| this.type = type; | ||
| } | ||
|
|
||
|
Comment on lines
+84
to
+99
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need the setters here |
||
| // /////////////////////////////////////////////////// | ||
| // ///////////// API Implementation/////////////////// | ||
| // /////////////////////////////////////////////////// | ||
|
|
@@ -97,17 +112,12 @@ public long getEntityOwnerId() { | |
|
|
||
| @Override | ||
| public void execute() { | ||
| if (ids == null && type == null && endDate == null) { | ||
| throw new InvalidParameterValueException("either ids, type or enddate must be specified"); | ||
| } else if (startDate != null && endDate == null) { | ||
| throw new InvalidParameterValueException("enddate must be specified with startdate parameter"); | ||
| } | ||
| boolean result = _mgr.deleteEvents(this); | ||
| if (result) { | ||
| SuccessResponse response = new SuccessResponse(getCommandName()); | ||
| setResponseObject(response); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to delete Events, one or more parameters has invalid values"); | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to delete any events. One or more parameters have invalid values."); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |||||||||||||||||||||||||||||
| // under the License. | ||||||||||||||||||||||||||||||
| package com.cloud.upgrade.dao; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| import java.sql.Connection; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public class Upgrade42300to2400 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate { | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||
|
|
@@ -27,4 +29,25 @@ public String[] getUpgradableVersionRange() { | |||||||||||||||||||||||||||||
| public String getUpgradedVersion() { | ||||||||||||||||||||||||||||||
| return "24.0.0"; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||
| public void performDataMigration(Connection conn) { | ||||||||||||||||||||||||||||||
| addIndexes(conn); | ||||||||||||||||||||||||||||||
| dropOldIndexes(conn); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| private void addIndexes(Connection conn) { | ||||||||||||||||||||||||||||||
| DbUpgradeUtils.addIndexWithNameIfNeeded(conn, "event", "i_event__archived__created__id", | ||||||||||||||||||||||||||||||
| "archived", "created", "id"); | ||||||||||||||||||||||||||||||
| DbUpgradeUtils.addIndexWithNameIfNeeded(conn, "event", "i_event__account_id__archived__created__id", | ||||||||||||||||||||||||||||||
| "account_id", "archived", "created", "id"); | ||||||||||||||||||||||||||||||
| DbUpgradeUtils.addIndexWithNameIfNeeded(conn, "event", "i_event__domain_id__archived__created__id", | ||||||||||||||||||||||||||||||
| "domain_id", "archived", "created", "id"); | ||||||||||||||||||||||||||||||
| DbUpgradeUtils.addIndexWithNameIfNeeded(conn, "event", "i_event__resource_type__resource_id__archived__created__id", | ||||||||||||||||||||||||||||||
| "resource_type", "resource_id", "archived", "created", "id"); | ||||||||||||||||||||||||||||||
|
Comment on lines
+41
to
+47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When using innoDB, the primary key is already added to the end of every index:
Suggested change
|
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| private void dropOldIndexes(Connection conn) { | ||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should also drop |
||||||||||||||||||||||||||||||
| DbUpgradeUtils.dropIndexIfExists(conn, "event", "i_event__resource_type__resource_id"); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need the setters here