diff --git a/core/src/com/cloud/user/UserStatisticsVO.java b/core/src/com/cloud/user/UserStatisticsVO.java index 49886c15803..1636c3ef2d8 100644 --- a/core/src/com/cloud/user/UserStatisticsVO.java +++ b/core/src/com/cloud/user/UserStatisticsVO.java @@ -46,7 +46,11 @@ public class UserStatisticsVO { private Long deviceId; @Column(name="device_type") - private String deviceType; + private String deviceType; + + @Column(name="network_id") + private Long networkId; + @Column(name="net_bytes_received") private long netBytesReceived; @@ -63,12 +67,13 @@ public class UserStatisticsVO { protected UserStatisticsVO() { } - public UserStatisticsVO(long accountId, long dcId, String publicIpAddress, Long deviceId, String deviceType) { + public UserStatisticsVO(long accountId, long dcId, String publicIpAddress, Long deviceId, String deviceType, Long networkId) { this.accountId = accountId; this.dataCenterId = dcId; this.publicIpAddress = publicIpAddress; this.deviceId = deviceId; - this.deviceType = deviceType; + this.deviceType = deviceType; + this.networkId = networkId; this.netBytesReceived = 0; this.netBytesSent = 0; this.currentBytesReceived = 0; @@ -94,7 +99,15 @@ public class UserStatisticsVO { public Long getDeviceId() { return deviceId; } - + + public String getDeviceType() { + return deviceType; + } + + public Long getNetworkId() { + return networkId; + } + public long getCurrentBytesReceived() { return currentBytesReceived; } @@ -126,8 +139,5 @@ public class UserStatisticsVO { public void setNetBytesSent(long netBytesSent) { this.netBytesSent = netBytesSent; } - - public String getDeviceType() { - return deviceType; - } + } diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index cad6914b161..96adcd7ccf4 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -761,7 +761,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian if (s_logger.isDebugEnabled()) { s_logger.debug("Creating user statistics for the account: " + owner.getId() + " Router Id: "+router.getId()); } - stats = new UserStatisticsVO(owner.getId(), dcId, null, router.getId(), router.getType().toString()); + stats = new UserStatisticsVO(owner.getId(), dcId, null, router.getId(), router.getType().toString(), guestNetwork.getId()); _userStatsDao.persist(stats); } return router; @@ -829,7 +829,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian if (s_logger.isDebugEnabled()) { s_logger.debug("Creating user statistics for the account: " + owner.getId() + " Router Id: "+router.getId()); } - stats = new UserStatisticsVO(owner.getId(), dcId, null, router.getId(), router.getType().toString()); + stats = new UserStatisticsVO(owner.getId(), dcId, null, router.getId(), router.getType().toString(), guestNetwork.getId()); _userStatsDao.persist(stats); } diff --git a/server/src/com/cloud/user/dao/UserStatisticsDaoImpl.java b/server/src/com/cloud/user/dao/UserStatisticsDaoImpl.java index 647c85f36a6..8131b023132 100644 --- a/server/src/com/cloud/user/dao/UserStatisticsDaoImpl.java +++ b/server/src/com/cloud/user/dao/UserStatisticsDaoImpl.java @@ -39,7 +39,7 @@ import com.cloud.utils.db.Transaction; @Local(value={UserStatisticsDao.class}) public class UserStatisticsDaoImpl extends GenericDaoBase implements UserStatisticsDao { private static final Logger s_logger = Logger.getLogger(UserStatisticsDaoImpl.class); - private static final String ACTIVE_AND_RECENTLY_DELETED_SEARCH = "SELECT us.id, us.data_center_id, us.account_id, us.public_ip_address, us.device_id, us.device_type, us.net_bytes_received, us.net_bytes_sent, us.current_bytes_received, us.current_bytes_sent " + + private static final String ACTIVE_AND_RECENTLY_DELETED_SEARCH = "SELECT us.id, us.data_center_id, us.account_id, us.public_ip_address, us.device_id, us.device_type, us.network_id, us.net_bytes_received, us.net_bytes_sent, us.current_bytes_received, us.current_bytes_sent " + "FROM user_statistics us, account a " + "WHERE us.account_id = a.id AND (a.removed IS NULL OR a.removed >= ?) " + "ORDER BY us.id"; diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 625e1f1b85f..f98e152339d 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -738,6 +738,7 @@ CREATE TABLE `cloud`.`user_statistics` ( `public_ip_address` varchar(15), `device_id` bigint unsigned NOT NULL, `device_type` varchar(32) NOT NULL, + `network_id` bigint unsigned, `net_bytes_received` bigint unsigned NOT NULL default '0', `net_bytes_sent` bigint unsigned NOT NULL default '0', `current_bytes_received` bigint unsigned NOT NULL default '0',