Fix CID 1114608 Store virtualsize in the the virtualsize column

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f275f293
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f275f293
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f275f293

Branch: refs/heads/master
Commit: f275f293bbcb2897179d96a137281aeccd1e12b7
Parents: da55aff
Author: Hugo Trippaers <[email protected]>
Authored: Thu Jul 24 12:00:34 2014 +0200
Committer: Hugo Trippaers <[email protected]>
Committed: Thu Jul 24 12:21:37 2014 +0200

----------------------------------------------------------------------
 .../src/com/cloud/usage/dao/UsageDaoImpl.java   | 27 ++++++++++----------
 1 file changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f275f293/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java 
b/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
index 32f63e6..a2d38e2 100644
--- a/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
+++ b/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
@@ -49,12 +49,12 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, 
Long> implements Usage
     private static final String DELETE_ALL_BY_ACCOUNTID = "DELETE FROM 
cloud_usage WHERE account_id = ?";
     private static final String INSERT_ACCOUNT = "INSERT INTO 
cloud_usage.account (id, account_name, type, domain_id, removed, 
cleanup_needed) VALUES (?,?,?,?,?,?)";
     private static final String INSERT_USER_STATS =
-        "INSERT INTO cloud_usage.user_statistics (id, data_center_id, 
account_id, public_ip_address, device_id, device_type, network_id, 
net_bytes_received,"
-            + " net_bytes_sent, current_bytes_received, current_bytes_sent, 
agg_bytes_received, agg_bytes_sent) VALUES (?,?,?,?,?,?,?,?,?,?, ?, ?, ?)";
+            "INSERT INTO cloud_usage.user_statistics (id, data_center_id, 
account_id, public_ip_address, device_id, device_type, network_id, 
net_bytes_received,"
+                    + " net_bytes_sent, current_bytes_received, 
current_bytes_sent, agg_bytes_received, agg_bytes_sent) VALUES 
(?,?,?,?,?,?,?,?,?,?, ?, ?, ?)";
 
     private static final String UPDATE_ACCOUNT = "UPDATE cloud_usage.account 
SET account_name=?, removed=? WHERE id=?";
     private static final String UPDATE_USER_STATS =
-        "UPDATE cloud_usage.user_statistics SET net_bytes_received=?, 
net_bytes_sent=?, current_bytes_received=?, current_bytes_sent=?, 
agg_bytes_received=?, agg_bytes_sent=? WHERE id=?";
+            "UPDATE cloud_usage.user_statistics SET net_bytes_received=?, 
net_bytes_sent=?, current_bytes_received=?, current_bytes_sent=?, 
agg_bytes_received=?, agg_bytes_sent=? WHERE id=?";
 
     private static final String GET_LAST_ACCOUNT = "SELECT id FROM 
cloud_usage.account ORDER BY id DESC LIMIT 1";
     private static final String GET_LAST_USER_STATS = "SELECT id FROM 
cloud_usage.user_statistics ORDER BY id DESC LIMIT 1";
@@ -62,15 +62,16 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, 
Long> implements Usage
 
     private static final String GET_LAST_VM_DISK_STATS = "SELECT id FROM 
cloud_usage.vm_disk_statistics ORDER BY id DESC LIMIT 1";
     private static final String INSERT_VM_DISK_STATS =
-        "INSERT INTO cloud_usage.vm_disk_statistics (id, data_center_id, 
account_id, vm_id, volume_id, 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) "
-            + " VALUES (?,?,?,?,?,?,?,?,?,?, ?, ?, ?, ?,?, ?, ?)";
+            "INSERT INTO cloud_usage.vm_disk_statistics (id, data_center_id, 
account_id, vm_id, volume_id, 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) "
+                    + " VALUES (?,?,?,?,?,?,?,?,?,?, ?, ?, ?, ?,?, ?, ?)";
     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=?, "
-            + "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, " +
-        "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 (?,?,?,?,?,?,?,?,?, ?, ?, ?,?,?,?,?,?,?)";
+            "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=?";
+    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_id, type, size, network_id, start_date, end_date, 
virtual_size) VALUES (?,?,?,?,?,?,?,?,?, ?, ?, ?,?,?,?,?,?,?)";
 
     protected final static TimeZone s_gmtTimeZone = 
TimeZone.getTimeZone("GMT");
 
@@ -390,7 +391,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, 
Long> implements Usage
         TransactionLegacy txn = TransactionLegacy.currentTxn();
         try {
             txn.start();
-            String sql = INSERT_USGAE_RECORDS;
+            String sql = INSERT_USAGE_RECORDS;
             PreparedStatement pstmt = null;
             pstmt = txn.prepareAutoCloseStatement(sql); // in reality I just 
want CLOUD_USAGE dataSource connection
             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(17, 
DateUtil.getDateDisplayString(s_gmtTimeZone, usageRecord.getEndDate()));
                 if (usageRecord.getVirtualSize() != null) {
-                    pstmt.setLong(18, usageRecord.getSize());
+                    pstmt.setLong(18, usageRecord.getVirtualSize());
                 } else {
                     pstmt.setNull(18, Types.BIGINT);
                 }

Reply via email to