Bug 13619: Throw exception when not traffic sentinel host is not available. Update last_collection timestamp when atleast 1 IP has nonzero bytes

Status 13619: resolved fixed
Reviewed-By: Nitin
This commit is contained in:
kishan 2012-02-21 23:39:20 +05:30
parent 53bf8742f8
commit 04341c0839
2 changed files with 12 additions and 4 deletions

View File

@ -229,11 +229,13 @@ public class TrafficSentinelResource implements ServerResource {
in.close();
} catch (MalformedURLException e1) {
s_logger.info("Invalid Traffic Sentinel URL",e1);
throw new ExecutionException(e1.getMessage());
} catch (IOException e) {
s_logger.debug("Error in direct network usage accounting",e);
throw new ExecutionException(e.getMessage());
}
} catch (Exception e) {
s_logger.error(e);
s_logger.debug(e);
throw new ExecutionException(e.getMessage());
}
return answer;

View File

@ -372,8 +372,8 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager, ResourceSta
}
List<UserStatisticsVO> collectedStats = new ArrayList<UserStatisticsVO>();
//Get usage for Ips for which were assigned for the entire duration
//Get usage for Ips which were assigned for the entire duration
if(fullDurationIpUsage.size() > 0){
DirectNetworkUsageCommand cmd = new DirectNetworkUsageCommand(IpList, lastCollection, now);
DirectNetworkUsageAnswer answer = (DirectNetworkUsageAnswer) _agentMgr.easySend(host.getId(), cmd);
@ -381,6 +381,7 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager, ResourceSta
String details = (answer != null) ? answer.getDetails() : "details unavailable";
String msg = "Unable to get network usage stats from " + host.getId() + " due to: " + details + ".";
s_logger.error(msg);
return false;
} else {
for(UsageIPAddressVO usageIp : fullDurationIpUsage){
String publicIp = usageIp.getAddress();
@ -403,7 +404,7 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager, ResourceSta
}
}
//Get usage for Ips for which were assigned for part of the duration period
//Get usage for Ips which were assigned for part of the duration period
for(UsageIPAddressVO usageIp : IpPartialUsage){
IpList = new ArrayList<String>() ;
IpList.add(usageIp.getAddress());
@ -413,6 +414,7 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager, ResourceSta
String details = (answer != null) ? answer.getDetails() : "details unavailable";
String msg = "Unable to get network usage stats from " + host.getId() + " due to: " + details + ".";
s_logger.error(msg);
return false;
} else {
String publicIp = usageIp.getAddress();
long[] bytesSentRcvd = answer.get(publicIp);
@ -434,6 +436,10 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager, ResourceSta
}
}
if(collectedStats.size() == 0){
s_logger.debug("No new direct network stats. No need to persist");
return false;
}
//Persist all the stats and last_collection time in a single transaction
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
try {