Skip to content

Commit

Permalink
Usage: Fixup entity exists exception (apache#8726)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishesh92 authored Mar 12, 2024
1 parent d487a1c commit f8fd22c
Showing 1 changed file with 33 additions and 28 deletions.
61 changes: 33 additions & 28 deletions usage/src/main/java/com/cloud/usage/UsageManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import javax.inject.Inject;
import javax.naming.ConfigurationException;
import javax.persistence.EntityExistsException;

import org.apache.cloudstack.quota.QuotaAlertManager;
import org.apache.cloudstack.quota.QuotaManager;
Expand Down Expand Up @@ -983,34 +984,38 @@ private boolean parseHelperTables(AccountVO account, Date currentStartDate, Date

private void createHelperRecord(UsageEventVO event) {
String eventType = event.getType();
if (isVMEvent(eventType)) {
createVMHelperEvent(event);
} else if (isIPEvent(eventType)) {
createIPHelperEvent(event);
} else if (isVolumeEvent(eventType)) {
createVolumeHelperEvent(event);
} else if (isTemplateEvent(eventType)) {
createTemplateHelperEvent(event);
} else if (isISOEvent(eventType)) {
createISOHelperEvent(event);
} else if (isSnapshotEvent(eventType)) {
createSnapshotHelperEvent(event);
} else if (isLoadBalancerEvent(eventType)) {
createLoadBalancerHelperEvent(event);
} else if (isPortForwardingEvent(eventType)) {
createPortForwardingHelperEvent(event);
} else if (isNetworkOfferingEvent(eventType)) {
createNetworkOfferingEvent(event);
} else if (isVPNUserEvent(eventType)) {
handleVpnUserEvent(event);
} else if (isSecurityGroupEvent(eventType)) {
createSecurityGroupEvent(event);
} else if (isVmSnapshotEvent(eventType)) {
handleVMSnapshotEvent(event);
} else if (isVmSnapshotOnPrimaryEvent(eventType)) {
createVmSnapshotOnPrimaryEvent(event);
} else if (isBackupEvent(eventType)) {
createBackupEvent(event);
try {
if (isVMEvent(eventType)) {
createVMHelperEvent(event);
} else if (isIPEvent(eventType)) {
createIPHelperEvent(event);
} else if (isVolumeEvent(eventType)) {
createVolumeHelperEvent(event);
} else if (isTemplateEvent(eventType)) {
createTemplateHelperEvent(event);
} else if (isISOEvent(eventType)) {
createISOHelperEvent(event);
} else if (isSnapshotEvent(eventType)) {
createSnapshotHelperEvent(event);
} else if (isLoadBalancerEvent(eventType)) {
createLoadBalancerHelperEvent(event);
} else if (isPortForwardingEvent(eventType)) {
createPortForwardingHelperEvent(event);
} else if (isNetworkOfferingEvent(eventType)) {
createNetworkOfferingEvent(event);
} else if (isVPNUserEvent(eventType)) {
handleVpnUserEvent(event);
} else if (isSecurityGroupEvent(eventType)) {
createSecurityGroupEvent(event);
} else if (isVmSnapshotEvent(eventType)) {
handleVMSnapshotEvent(event);
} else if (isVmSnapshotOnPrimaryEvent(eventType)) {
createVmSnapshotOnPrimaryEvent(event);
} else if (isBackupEvent(eventType)) {
createBackupEvent(event);
}
} catch (EntityExistsException e) {
s_logger.warn(String.format("Failed to create usage event id: %d type: %s due to %s", event.getId(), eventType, e.getMessage()), e);
}
}

Expand Down

0 comments on commit f8fd22c

Please sign in to comment.