diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index ad67101b20a..05de6edf42c 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -423,7 +423,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian final Transaction txn = Transaction.currentTxn(); try { txn.start(); - final UserStatisticsVO userStats = _userStatsDao.lock(router.getAccountId(), router.getDataCenterId(), null, router.getId(), router.getType().toString()); + final UserStatisticsVO userStats = _userStatsDao.lock(router.getAccountId(), router.getDataCenterId(), router.getNetworkId(), null, router.getId(), router.getType().toString()); if (userStats != null) { final RebootAnswer sa = (RebootAnswer) answer; final Long received = sa.getBytesReceived(); @@ -644,7 +644,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian continue; } txn.start(); - UserStatisticsVO stats = _statsDao.lock(router.getAccountId(), router.getDataCenterId(), null, router.getId(), router.getType().toString()); + UserStatisticsVO stats = _statsDao.lock(router.getAccountId(), router.getDataCenterId(), router.getNetworkId(), null, router.getId(), router.getType().toString()); if (stats == null) { s_logger.warn("unable to find stats for account: " + router.getAccountId()); continue; @@ -761,7 +761,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian } // Creating stats entry for router - UserStatisticsVO stats = _userStatsDao.findBy(owner.getId(), dcId, null, router.getId(), router.getType().toString()); + UserStatisticsVO stats = _userStatsDao.findBy(owner.getId(), dcId, router.getNetworkId(), null, router.getId(), router.getType().toString()); if (stats == null) { if (s_logger.isDebugEnabled()) { s_logger.debug("Creating user statistics for the account: " + owner.getId() + " Router Id: " + router.getId()); @@ -846,7 +846,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian router = this.start(router, _accountService.getSystemUser(), _accountService.getSystemAccount(), params); } // Creating stats entry for router - UserStatisticsVO stats = _userStatsDao.findBy(owner.getId(), dcId, null, router.getId(), router.getType().toString()); + UserStatisticsVO stats = _userStatsDao.findBy(owner.getId(), dcId, router.getNetworkId(), null, router.getId(), router.getType().toString()); if (stats == null) { if (s_logger.isDebugEnabled()) { s_logger.debug("Creating user statistics for the account: " + owner.getId() + " Router Id: " + router.getId()); diff --git a/server/src/com/cloud/user/dao/UserStatisticsDao.java b/server/src/com/cloud/user/dao/UserStatisticsDao.java index d2054eec4c2..5566b2dff49 100644 --- a/server/src/com/cloud/user/dao/UserStatisticsDao.java +++ b/server/src/com/cloud/user/dao/UserStatisticsDao.java @@ -25,9 +25,9 @@ import com.cloud.user.UserStatisticsVO; import com.cloud.utils.db.GenericDao; public interface UserStatisticsDao extends GenericDao { - UserStatisticsVO findBy(long accountId, long dcId, String publicIp, Long deviceId, String deviceType); + UserStatisticsVO findBy(long accountId, long dcId, long networkId, String publicIp, Long deviceId, String deviceType); - UserStatisticsVO lock(long accountId, long dcId, String publicIp, Long hostId, String deviceType); + UserStatisticsVO lock(long accountId, long dcId, long networkId, String publicIp, Long hostId, String deviceType); List listBy(long accountId); diff --git a/server/src/com/cloud/user/dao/UserStatisticsDaoImpl.java b/server/src/com/cloud/user/dao/UserStatisticsDaoImpl.java index 8131b023132..7df6c9d57b8 100644 --- a/server/src/com/cloud/user/dao/UserStatisticsDaoImpl.java +++ b/server/src/com/cloud/user/dao/UserStatisticsDaoImpl.java @@ -43,7 +43,7 @@ public class UserStatisticsDaoImpl extends GenericDaoBase= ?) " + "ORDER BY us.id"; - private final SearchBuilder AccountDcIpDeviceSearch; + private final SearchBuilder AllFieldsSearch; private final SearchBuilder AccountSearch; public UserStatisticsDaoImpl() { @@ -51,34 +51,37 @@ public class UserStatisticsDaoImpl extends GenericDaoBase sc = AccountDcIpDeviceSearch.create(); + public UserStatisticsVO findBy(long accountId, long dcId, long networkId, String publicIp, Long deviceId, String deviceType) { + SearchCriteria sc = AllFieldsSearch.create(); sc.setParameters("account", accountId); sc.setParameters("dc", dcId); + sc.setParameters("network", networkId); sc.setParameters("ip", publicIp); sc.setParameters("device", deviceId); - sc.setParameters("deviceType", deviceType); + sc.setParameters("deviceType", deviceType); return findOneBy(sc); } @Override - public UserStatisticsVO lock(long accountId, long dcId, String publicIp, Long deviceId, String deviceType) { - SearchCriteria sc = AccountDcIpDeviceSearch.create(); + public UserStatisticsVO lock(long accountId, long dcId, long networkId, String publicIp, Long deviceId, String deviceType) { + SearchCriteria sc = AllFieldsSearch.create(); sc.setParameters("account", accountId); sc.setParameters("dc", dcId); + sc.setParameters("network", networkId); sc.setParameters("ip", publicIp); sc.setParameters("device", deviceId); - sc.setParameters("deviceType", deviceType); + sc.setParameters("deviceType", deviceType); return lockOneRandomRow(sc, true); }