mirror of https://github.com/apache/cloudstack.git
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:
parent
53bf8742f8
commit
04341c0839
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue