Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 89401200B11 for ; Mon, 13 Jun 2016 15:53:40 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8474F160A64; Mon, 13 Jun 2016 13:53:40 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id CC887160A1A for ; Mon, 13 Jun 2016 15:53:39 +0200 (CEST) Received: (qmail 36235 invoked by uid 500); 13 Jun 2016 13:53:38 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 36223 invoked by uid 99); 13 Jun 2016 13:53:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Jun 2016 13:53:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B5B7FE01E2; Mon, 13 Jun 2016 13:53:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: swill@apache.org To: commits@cloudstack.apache.org Date: Mon, 13 Jun 2016 13:53:38 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/7] git commit: updated refs/heads/master to 22c6b47 archived-at: Mon, 13 Jun 2016 13:53:40 -0000 Repository: cloudstack Updated Branches: refs/heads/master 971c8a74e -> 22c6b4747 CLOUDSTACK-9409: Add role_id to cloud_usage.account Adds role_id column to cloud_usage.account, fixes UsageDaoImpl to insert Accounts with role_id from account table. Signed-off-by: Rohit Yadav Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/fd67871a Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fd67871a Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fd67871a Branch: refs/heads/master Commit: fd67871a27dcb2b2a67e36e4f96ea1b0f07f0ede Parents: 971c8a7 Author: Rohit Yadav Authored: Wed Jun 8 11:20:46 2016 +0900 Committer: Rohit Yadav Committed: Wed Jun 8 11:20:46 2016 +0900 ---------------------------------------------------------------------- .../src/com/cloud/upgrade/dao/Upgrade481to490.java | 8 +++++++- engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java | 11 ++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd67871a/engine/schema/src/com/cloud/upgrade/dao/Upgrade481to490.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade481to490.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade481to490.java index d1240ec..1c6ce38 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade481to490.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade481to490.java @@ -103,10 +103,16 @@ public class Upgrade481to490 implements DbUpgrade { s_logger.warn("cloud.account table already has the role_id column, skipping altering table and migration of accounts"); return; } else { - throw new CloudRuntimeException("Unable to create column quota_calculated in table cloud_usage.cloud_usage", e); + throw new CloudRuntimeException("Unable to create column role_id in table cloud.account", e); } } + try (final PreparedStatement pstmt = conn.prepareStatement("ALTER TABLE `cloud_usage`.`account` ADD COLUMN `role_id` bigint(20) unsigned AFTER `type`")) { + pstmt.executeUpdate(); + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to create column role_id in table cloud_usage.account", e); + } + migrateAccountsToDefaultRoles(conn); final Map apiMap = PropertiesUtil.processConfigFile(new String[] { PropertiesUtil.getDefaultApiCommandsFileName() }); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd67871a/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 9c9ab0b..39f57df 100644 --- a/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java +++ b/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java @@ -49,7 +49,7 @@ public class UsageDaoImpl extends GenericDaoBase implements Usage private static final String DELETE_ALL = "DELETE FROM cloud_usage"; private static final String DELETE_ALL_BY_ACCOUNTID = "DELETE FROM cloud_usage WHERE account_id = ?"; private static final String DELETE_ALL_BY_INTERVAL = "DELETE FROM cloud_usage WHERE end_date < DATE_SUB(CURRENT_DATE(), INTERVAL ? DAY)"; - 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_ACCOUNT = "INSERT INTO cloud_usage.account (id, account_name, type, role_id, 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 (?,?,?,?,?,?,?,?,?,?, ?, ?, ?)"; @@ -113,16 +113,17 @@ public class UsageDaoImpl extends GenericDaoBase implements Usage pstmt.setLong(1, acct.getId()); pstmt.setString(2, acct.getAccountName()); pstmt.setShort(3, acct.getType()); - pstmt.setLong(4, acct.getDomainId()); + pstmt.setLong(4, acct.getRoleId()); + pstmt.setLong(5, acct.getDomainId()); Date removed = acct.getRemoved(); if (removed == null) { - pstmt.setString(5, null); + pstmt.setString(6, null); } else { - pstmt.setString(5, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), acct.getRemoved())); + pstmt.setString(6, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), acct.getRemoved())); } - pstmt.setBoolean(6, acct.getNeedsCleanup()); + pstmt.setBoolean(7, acct.getNeedsCleanup()); pstmt.addBatch(); }