Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1623#discussion_r73604377
  
    --- Diff: server/src/com/cloud/network/IpAddressManagerImpl.java ---
    @@ -1698,6 +1698,22 @@ public String acquireGuestIpAddress(Network network, 
String requestedIp) {
     
         Random _rand = new Random(System.currentTimeMillis());
     
    +    /**
    +     * Get the list of public IPs that need to be applied for a static NAT 
enable/disable operation.
    +     * Manipulating only these ips prevents concurrency issues when 
disabling static nat at the same time.
    +     * @param staticNats
    +     * @return The list of IPs that need to be applied for the static NAT 
to work.
    +     */
    +    public List<IPAddressVO> getStaticNatSourceIps(List<? extends 
StaticNat> staticNats) {
    +        List<IPAddressVO> userIps = new ArrayList<>();
    +
    +        for (StaticNat snat : staticNats) {
    +            
userIps.add(_ipAddressDao.findById(snat.getSourceIpAddressId()));
    +        }
    --- End diff --
    
    Executing queries in a ``for`` loop in unnecessarily expensive.  Could you 
please refactor this ``for`` loop into a new method on ``IPAddressDao`` that 
retrieves a list of IP addresses for a list of IPs?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to