cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [14/32] git commit: CLOUDSTACK-721: Fixed network usage. Send network usage command for isolated guest nic of non VPC VR. Send network usage command for public nic in VPC VR.
Date Fri, 11 Jan 2013 00:01:22 GMT
CLOUDSTACK-721: Fixed network usage. Send network usage command for isolated guest nic of non
VPC VR. Send network usage command for public nic in VPC VR.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/cd7f7716
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/cd7f7716
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/cd7f7716

Branch: refs/heads/javelin
Commit: cd7f7716155c3cd2d29b97d7ea302518d81fdfab
Parents: 7f8262d
Author: Kishan Kavala <kishan@cloud.com>
Authored: Thu Jan 10 14:53:29 2013 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Thu Jan 10 14:56:11 2013 +0530

----------------------------------------------------------------------
 .../router/VirtualNetworkApplianceManagerImpl.java |   37 ++++++++-------
 1 files changed, 20 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cd7f7716/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 1a6eb09..1f74c71 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -823,26 +823,29 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
                     String privateIP = router.getPrivateIpAddress();
 
                     if (privateIP != null) {
+                        boolean forVpc = router.getVpcId() != null;
                         List<? extends Nic> routerNics = _nicDao.listByVmId(router.getId());
                         for (Nic routerNic : routerNics) {
                             Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
-                            if (network.getTrafficType() == TrafficType.Public) {
-                                boolean forVpc = router.getVpcId() != null;
+                            //Send network usage command for public nic in VPC VR
+                            //Send network usage command for isolated guest nic of non VPC
VR                            
+                            if ((forVpc && network.getTrafficType() == TrafficType.Public)
|| (!forVpc && network.getTrafficType() == TrafficType.Guest && network.getGuestType()
== Network.GuestType.Isolated)) {
                                 final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP,
router.getHostName(),
                                         forVpc, routerNic.getIp4Address());
-                                UserStatisticsVO previousStats = _statsDao.findBy(router.getAccountId(),

-                                        router.getDataCenterIdToDeployIn(), network.getId(),
null, router.getId(), router.getType().toString());
+                                String routerType = router.getType().toString();
+                                UserStatisticsVO previousStats = _statsDao.findBy(router.getAccountId(),
+                                        router.getDataCenterIdToDeployIn(), network.getId(),
(forVpc ? routerNic.getIp4Address() : null), router.getId(), routerType);
                                 NetworkUsageAnswer answer = null;
                                 try {
                                     answer = (NetworkUsageAnswer) _agentMgr.easySend(router.getHostId(),
usageCmd);
                                 } catch (Exception e) {
-                                    s_logger.warn("Error while collecting network stats from
router: "+router.getInstanceName()+" from host: "+router.getHostId(), e);
+                                    s_logger.warn("Error while collecting network stats from
router: " + router.getInstanceName() + " from host: " + router.getHostId(), e);
                                     continue;
                                 }
 
                                 if (answer != null) {
                                     if (!answer.getResult()) {
-                                        s_logger.warn("Error while collecting network stats
from router: "+router.getInstanceName()+" from host: "+router.getHostId() + "; details: "
+ answer.getDetails());
+                                        s_logger.warn("Error while collecting network stats
from router: " + router.getInstanceName() + " from host: " + router.getHostId() + "; details:
" + answer.getDetails());
                                         continue;
                                     }
                                     Transaction txn = Transaction.open(Transaction.CLOUD_DB);
@@ -852,27 +855,27 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
                                             continue;
                                         }
                                         txn.start();
-                                        UserStatisticsVO stats = _statsDao.lock(router.getAccountId(),

-                                                router.getDataCenterIdToDeployIn(), network.getId(),
routerNic.getIp4Address(), router.getId(), router.getType().toString());
+                                        UserStatisticsVO stats = _statsDao.lock(router.getAccountId(),
+                                                router.getDataCenterIdToDeployIn(), network.getId(),
(forVpc ? routerNic.getIp4Address() : null), router.getId(), routerType);
                                         if (stats == null) {
                                             s_logger.warn("unable to find stats for account:
" + router.getAccountId());
                                             continue;
                                         }
 
-                                        if(previousStats != null 
-                                                && ((previousStats.getCurrentBytesReceived()
!= stats.getCurrentBytesReceived()) 
-                                                        || (previousStats.getCurrentBytesSent()
!= stats.getCurrentBytesSent()))){
+                                        if (previousStats != null
+                                                && ((previousStats.getCurrentBytesReceived()
!= stats.getCurrentBytesReceived())
+                                                || (previousStats.getCurrentBytesSent() !=
stats.getCurrentBytesSent()))) {
                                             s_logger.debug("Router stats changed from the
time NetworkUsageCommand was sent. " +
-                                                    "Ignoring current answer. Router: "+answer.getRouterName()+"
Rcvd: " + 
-                                                    answer.getBytesReceived()+ "Sent: " +answer.getBytesSent());
+                                                    "Ignoring current answer. Router: " +
answer.getRouterName() + " Rcvd: " +
+                                                    answer.getBytesReceived() + "Sent: "
+ answer.getBytesSent());
                                             continue;
                                         }
 
                                         if (stats.getCurrentBytesReceived() > answer.getBytesReceived())
{
                                             if (s_logger.isDebugEnabled()) {
                                                 s_logger.debug("Received # of bytes that's
less than the last one.  " +
-                                                        "Assuming something went wrong and
persisting it. Router: " + 
-                                                        answer.getRouterName()+" Reported:
" + answer.getBytesReceived()
+                                                        "Assuming something went wrong and
persisting it. Router: " +
+                                                        answer.getRouterName() + " Reported:
" + answer.getBytesReceived()
                                                         + " Stored: " + stats.getCurrentBytesReceived());
                                             }
                                             stats.setNetBytesReceived(stats.getNetBytesReceived()
+ stats.getCurrentBytesReceived());
@@ -881,8 +884,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
                                         if (stats.getCurrentBytesSent() > answer.getBytesSent())
{
                                             if (s_logger.isDebugEnabled()) {
                                                 s_logger.debug("Received # of bytes that's
less than the last one.  " +
-                                                        "Assuming something went wrong and
persisting it. Router: " + 
-                                                        answer.getRouterName()+" Reported:
" + answer.getBytesSent()
+                                                        "Assuming something went wrong and
persisting it. Router: " +
+                                                        answer.getRouterName() + " Reported:
" + answer.getBytesSent()
                                                         + " Stored: " + stats.getCurrentBytesSent());
                                             }
                                             stats.setNetBytesSent(stats.getNetBytesSent()
+ stats.getCurrentBytesSent());


Mime
View raw message