bug 8603: Included netwrok_id in network usage records

status 8603: resolved fixed
This commit is contained in:
kishan 2011-02-24 15:31:59 +05:30
parent 57f6b16cdb
commit f138552f36
4 changed files with 22 additions and 11 deletions

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -39,7 +39,7 @@ import com.cloud.utils.db.Transaction;
@Local(value={UserStatisticsDao.class})
public class UserStatisticsDaoImpl extends GenericDaoBase<UserStatisticsVO, Long> 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";

View File

@ -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',