diff --git a/core/src/com/cloud/user/UserStatisticsVO.java b/core/src/com/cloud/user/UserStatisticsVO.java index fff50160861..3d1e1fa04e4 100644 --- a/core/src/com/cloud/user/UserStatisticsVO.java +++ b/core/src/com/cloud/user/UserStatisticsVO.java @@ -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; + } } diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index da2cb3c6f70..4e66bb1a6cd 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -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(); diff --git a/server/src/com/cloud/user/dao/UserStatisticsDaoImpl.java b/server/src/com/cloud/user/dao/UserStatisticsDaoImpl.java index fa4599163df..07021535891 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.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"; diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 22e8b519c30..e3f5275770c 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -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',