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

    https://github.com/apache/cloudstack/pull/1786#discussion_r90487461
  
    --- Diff: 
plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
 ---
    @@ -260,7 +264,7 @@ public boolean applyLBRules(Network config, 
List<LoadBalancingRule> rules) throw
             Map<Capability, String> lbCapabilities = new HashMap<Capability, 
String>();
     
             // Specifies that the RoundRobin and Leastconn algorithms are 
supported for load balancing rules
    -        lbCapabilities.put(Capability.SupportedLBAlgorithms, 
"roundrobin,leastconn");
    +        lbCapabilities.put(Capability.SupportedLBAlgorithms, 
"roundrobin,leastconn,source");
    --- End diff --
    
    The list of strings declared on this line must be sync with the list used 
to validate the algorithm on line 237.  Therefore, please consider extracting 
this list to a constant `ImmutableSet<String>`, `SUPPORTED_ALGORITHMS` in order 
to ensure cohesion between declaration and validation.  With this change, the 
validateLBRule can be re-implemented as follows:
    
    ```java
    public boolean validateLBRule(Network network, LoadBalancingRule rule) {
        Preconditions.checkArgument(network != null, "validateLBRule requires a 
non-null network");
        Preconditions.checkArgument(rule != null, "validateLBRule requires a 
non-null rule");
    
        return (canHandle(network, Service.Lb)) : 
SUPPORTED_ALGORITHMS.contains(rule.getAlgorithm()) : true;
    }
    ```
    
    This line can be re-implemented as follows:
    
    ```java
    lbCapabilities.put(Capability.SupportedLBAlgorithms, 
Joiner.on(",").join(SUPPORTED_ALGORITHMS));
    ```


---
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