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 committed by Kishan Kavala
parent b8429dcb17
commit 13cd215a19
2 changed files with 12 additions and 4 deletions

View File

@ -214,11 +214,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

@ -350,8 +350,8 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager {
}
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);
@ -359,6 +359,7 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager {
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();
@ -381,7 +382,7 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager {
}
}
//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());
@ -391,6 +392,7 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager {
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);
@ -412,6 +414,10 @@ public class NetworkUsageManagerImpl implements NetworkUsageManager {
}
}
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 {