mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Switch back to CLOUD_DB after purging usage records (#9367)
This commit is contained in:
parent
beebeed5e2
commit
22ef08154d
@ -28,6 +28,7 @@ import com.cloud.utils.db.QueryBuilder;
|
|||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.db.TransactionCallback;
|
import com.cloud.utils.db.TransactionCallback;
|
||||||
|
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||||
import com.cloud.utils.db.TransactionLegacy;
|
import com.cloud.utils.db.TransactionLegacy;
|
||||||
import com.cloud.utils.db.TransactionStatus;
|
import com.cloud.utils.db.TransactionStatus;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
@ -469,21 +470,25 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeOldUsageRecords(int days) {
|
public void removeOldUsageRecords(int days) {
|
||||||
String sql = DELETE_ALL_BY_INTERVAL;
|
Transaction.execute(TransactionLegacy.USAGE_DB, new TransactionCallbackNoReturn() {
|
||||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
|
@Override
|
||||||
PreparedStatement pstmt = null;
|
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||||
try {
|
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||||
txn.start();
|
PreparedStatement pstmt = null;
|
||||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
try {
|
||||||
pstmt.setLong(1, days);
|
txn.start();
|
||||||
pstmt.executeUpdate();
|
pstmt = txn.prepareAutoCloseStatement(DELETE_ALL_BY_INTERVAL);
|
||||||
txn.commit();
|
pstmt.setLong(1, days);
|
||||||
} catch (Exception ex) {
|
pstmt.executeUpdate();
|
||||||
txn.rollback();
|
txn.commit();
|
||||||
s_logger.error("error removing old cloud_usage records for interval: " + days);
|
} catch (Exception ex) {
|
||||||
} finally {
|
txn.rollback();
|
||||||
txn.close();
|
s_logger.error("error removing old cloud_usage records for interval: " + days);
|
||||||
}
|
} finally {
|
||||||
|
txn.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public UsageVO persistUsage(final UsageVO usage) {
|
public UsageVO persistUsage(final UsageVO usage) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user