Skip to content

Commit f138552

Browse files
author
kishan
committed
bug 8603: Included netwrok_id in network usage records
status 8603: resolved fixed
1 parent 57f6b16 commit f138552

4 files changed

Lines changed: 22 additions & 11 deletions

File tree

‎core/src/com/cloud/user/UserStatisticsVO.java‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ public class UserStatisticsVO {
4646
private Long deviceId;
4747

4848
@Column(name="device_type")
49-
private String deviceType;
49+
private String deviceType;
50+
51+
@Column(name="network_id")
52+
private Long networkId;
53+
5054

5155
@Column(name="net_bytes_received")
5256
private long netBytesReceived;
@@ -63,12 +67,13 @@ public class UserStatisticsVO {
6367
protected UserStatisticsVO() {
6468
}
6569

66-
public UserStatisticsVO(long accountId, long dcId, String publicIpAddress, Long deviceId, String deviceType) {
70+
public UserStatisticsVO(long accountId, long dcId, String publicIpAddress, Long deviceId, String deviceType, Long networkId) {
6771
this.accountId = accountId;
6872
this.dataCenterId = dcId;
6973
this.publicIpAddress = publicIpAddress;
7074
this.deviceId = deviceId;
71-
this.deviceType = deviceType;
75+
this.deviceType = deviceType;
76+
this.networkId = networkId;
7277
this.netBytesReceived = 0;
7378
this.netBytesSent = 0;
7479
this.currentBytesReceived = 0;
@@ -94,7 +99,15 @@ public String getPublicIpAddress() {
9499
public Long getDeviceId() {
95100
return deviceId;
96101
}
97-
102+
103+
public String getDeviceType() {
104+
return deviceType;
105+
}
106+
107+
public Long getNetworkId() {
108+
return networkId;
109+
}
110+
98111
public long getCurrentBytesReceived() {
99112
return currentBytesReceived;
100113
}
@@ -126,8 +139,5 @@ public void setNetBytesReceived(long netBytesReceived) {
126139
public void setNetBytesSent(long netBytesSent) {
127140
this.netBytesSent = netBytesSent;
128141
}
129-
130-
public String getDeviceType() {
131-
return deviceType;
132-
}
142+
133143
}

‎server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ public DomainRouterVO deployVirtualRouter(Network guestNetwork, DeployDestinatio
761761
if (s_logger.isDebugEnabled()) {
762762
s_logger.debug("Creating user statistics for the account: " + owner.getId() + " Router Id: "+router.getId());
763763
}
764-
stats = new UserStatisticsVO(owner.getId(), dcId, null, router.getId(), router.getType().toString());
764+
stats = new UserStatisticsVO(owner.getId(), dcId, null, router.getId(), router.getType().toString(), guestNetwork.getId());
765765
_userStatsDao.persist(stats);
766766
}
767767
return router;
@@ -829,7 +829,7 @@ public DomainRouterVO deployDhcp(Network guestNetwork, DeployDestination dest, A
829829
if (s_logger.isDebugEnabled()) {
830830
s_logger.debug("Creating user statistics for the account: " + owner.getId() + " Router Id: "+router.getId());
831831
}
832-
stats = new UserStatisticsVO(owner.getId(), dcId, null, router.getId(), router.getType().toString());
832+
stats = new UserStatisticsVO(owner.getId(), dcId, null, router.getId(), router.getType().toString(), guestNetwork.getId());
833833
_userStatsDao.persist(stats);
834834
}
835835

‎server/src/com/cloud/user/dao/UserStatisticsDaoImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
@Local(value={UserStatisticsDao.class})
4040
public class UserStatisticsDaoImpl extends GenericDaoBase<UserStatisticsVO, Long> implements UserStatisticsDao {
4141
private static final Logger s_logger = Logger.getLogger(UserStatisticsDaoImpl.class);
42-
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 " +
42+
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 " +
4343
"FROM user_statistics us, account a " +
4444
"WHERE us.account_id = a.id AND (a.removed IS NULL OR a.removed >= ?) " +
4545
"ORDER BY us.id";

‎setup/db/create-schema.sql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ CREATE TABLE `cloud`.`user_statistics` (
738738
`public_ip_address` varchar(15),
739739
`device_id` bigint unsigned NOT NULL,
740740
`device_type` varchar(32) NOT NULL,
741+
`network_id` bigint unsigned,
741742
`net_bytes_received` bigint unsigned NOT NULL default '0',
742743
`net_bytes_sent` bigint unsigned NOT NULL default '0',
743744
`current_bytes_received` bigint unsigned NOT NULL default '0',

0 commit comments

Comments
 (0)