Fix CID 1114608 Store virtualsize in the the virtualsize column

This commit is contained in:
Hugo Trippaers 2014-07-24 12:00:34 +02:00
parent da55aff64f
commit f275f293bb

View File

@ -68,7 +68,8 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage
private static final String UPDATE_VM_DISK_STATS = private static final String UPDATE_VM_DISK_STATS =
"UPDATE cloud_usage.vm_disk_statistics SET net_io_read=?, net_io_write=?, current_io_read=?, current_io_write=?, agg_io_read=?, agg_io_write=?, " "UPDATE cloud_usage.vm_disk_statistics SET net_io_read=?, net_io_write=?, current_io_read=?, current_io_write=?, agg_io_read=?, agg_io_write=?, "
+ "net_bytes_read=?, net_bytes_write=?, current_bytes_read=?, current_bytes_write=?, agg_bytes_read=?, agg_bytes_write=? WHERE id=?"; + "net_bytes_read=?, net_bytes_write=?, current_bytes_read=?, current_bytes_write=?, agg_bytes_read=?, agg_bytes_write=? WHERE id=?";
private static final String INSERT_USGAE_RECORDS = "INSERT INTO cloud_usage.cloud_usage (zone_id, account_id, domain_id, description, usage_display, " + private static final String INSERT_USAGE_RECORDS = "INSERT INTO cloud_usage.cloud_usage (zone_id, account_id, domain_id, description, usage_display, "
+
"usage_type, raw_usage, vm_instance_id, vm_name, offering_id, template_id, " "usage_type, raw_usage, vm_instance_id, vm_name, offering_id, template_id, "
+ "usage_id, type, size, network_id, start_date, end_date, virtual_size) VALUES (?,?,?,?,?,?,?,?,?, ?, ?, ?,?,?,?,?,?,?)"; + "usage_id, type, size, network_id, start_date, end_date, virtual_size) VALUES (?,?,?,?,?,?,?,?,?, ?, ?, ?,?,?,?,?,?,?)";
@ -390,7 +391,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage
TransactionLegacy txn = TransactionLegacy.currentTxn(); TransactionLegacy txn = TransactionLegacy.currentTxn();
try { try {
txn.start(); txn.start();
String sql = INSERT_USGAE_RECORDS; String sql = INSERT_USAGE_RECORDS;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
pstmt = txn.prepareAutoCloseStatement(sql); // in reality I just want CLOUD_USAGE dataSource connection pstmt = txn.prepareAutoCloseStatement(sql); // in reality I just want CLOUD_USAGE dataSource connection
for (UsageVO usageRecord : usageRecords) { for (UsageVO usageRecord : usageRecords) {
@ -436,7 +437,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage
pstmt.setString(16, DateUtil.getDateDisplayString(s_gmtTimeZone, usageRecord.getStartDate())); pstmt.setString(16, DateUtil.getDateDisplayString(s_gmtTimeZone, usageRecord.getStartDate()));
pstmt.setString(17, DateUtil.getDateDisplayString(s_gmtTimeZone, usageRecord.getEndDate())); pstmt.setString(17, DateUtil.getDateDisplayString(s_gmtTimeZone, usageRecord.getEndDate()));
if (usageRecord.getVirtualSize() != null) { if (usageRecord.getVirtualSize() != null) {
pstmt.setLong(18, usageRecord.getSize()); pstmt.setLong(18, usageRecord.getVirtualSize());
} else { } else {
pstmt.setNull(18, Types.BIGINT); pstmt.setNull(18, Types.BIGINT);
} }