including host type in network stats

This commit is contained in:
kishan 2011-01-31 19:35:47 +05:30
parent f53e18b0ab
commit 92bf106ab9
4 changed files with 15 additions and 6 deletions

View File

@ -43,7 +43,10 @@ public class UserStatisticsVO {
private String publicIpAddress;
@Column(name="host_id")
private Long hostId;
private Long hostId;
@Column(name="host_type")
private String hostType;
@Column(name="net_bytes_received")
private long netBytesReceived;
@ -60,11 +63,12 @@ public class UserStatisticsVO {
protected UserStatisticsVO() {
}
public UserStatisticsVO(long accountId, long dcId, String publicIpAddress, Long hostId) {
public UserStatisticsVO(long accountId, long dcId, String publicIpAddress, Long hostId, String hostType) {
this.accountId = accountId;
this.dataCenterId = dcId;
this.publicIpAddress = publicIpAddress;
this.hostId = hostId;
this.hostId = hostId;
this.hostType = hostType;
this.netBytesReceived = 0;
this.netBytesSent = 0;
this.currentBytesReceived = 0;
@ -121,5 +125,9 @@ public class UserStatisticsVO {
public void setNetBytesSent(long netBytesSent) {
this.netBytesSent = netBytesSent;
}
}
public String getHostType() {
return hostType;
}
}

View File

@ -343,7 +343,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (s_logger.isDebugEnabled()) {
s_logger.debug("Creating statistics for the owner: " + ownerId);
}
stats = new UserStatisticsVO(ownerId, dcId, null, null);
stats = new UserStatisticsVO(ownerId, dcId, null, null, null);
_userStatsDao.persist(stats);
}
txn.commit();

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.host_id, 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.host_id, us.host_type, 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

@ -682,6 +682,7 @@ CREATE TABLE `cloud`.`user_statistics` (
`account_id` bigint unsigned NOT NULL,
`public_ip_address` varchar(15),
`host_id` bigint unsigned,
`host_type` varchar(32),
`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',