ipAssigment.put(address, IpEvent.getCreateDate());
} else if (EventTypes.EVENT_NET_IP_RELEASE.equals(IpEvent.getType())) {
if (ipAssigment.containsKey(address)) {
Date assigned = ipAssigment.get(address);
ipAssigment.remove(address);
IpPartialUsage.add(new UsageIPAddressVO(IpEvent.getAccountId(), address, assigned, IpEvent.getCreateDate()));
} else {
// Ip was assigned prior to lastCollection Date
IpPartialUsage.add(new UsageIPAddressVO(IpEvent.getAccountId(), address, lastCollection, IpEvent.getCreateDate()));
}
}
}
List<String> IpList = new ArrayList<String>();
for (IPAddressVO ip : allocatedIps) {
if (ip.getAllocatedToAccountId() == Account.ACCOUNT_ID_SYSTEM) {
//Ignore usage for system account
continue;
}
String address = (ip.getAddress()).toString();
if (ipAssigment.containsKey(address)) {
// Ip was assigned during the current period but not release till Date now
IpPartialUsage.add(new UsageIPAddressVO(ip.getAllocatedToAccountId(), address, ipAssigment.get(address), now));
} else {
// Ip was not assigned or released during current period. Consider entire duration for usage calculation (lastCollection to now)
fullDurationIpUsage.add(new UsageIPAddressVO(ip.getAllocatedToAccountId(), address, lastCollection, now));
//Store just the Ips to send the list as part of DirectNetworkUsageCommand
IpList.add(address);
}
}