mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-102: Clean up and simplify WLC sorting code.
This commit is contained in:
committed by
Nick Couchman
parent
56f6c4bb2f
commit
f22852721c
@@ -189,28 +189,21 @@ public class RestrictedGuacamoleTunnelService
|
|||||||
public int compare(ModeledConnection a, ModeledConnection b) {
|
public int compare(ModeledConnection a, ModeledConnection b) {
|
||||||
|
|
||||||
int weightA, weightB;
|
int weightA, weightB;
|
||||||
// Check if weight of a is null, assign 1 if it is.
|
// Check if weight of a is non-null and retrieve it.
|
||||||
if (a.getConnectionWeight() == null)
|
if (a.getConnectionWeight() != null && a.getConnectionWeight().intValue() > 0)
|
||||||
weightA = 1;
|
weightA = a.getConnectionWeight().intValue();
|
||||||
// If weight is less than 1, host will be disabled
|
// In all other cases assign 1 for sorting.
|
||||||
// but for sorting we set it to 1 to avoid divide
|
|
||||||
// by 0.
|
|
||||||
else if (a.getConnectionWeight().intValue() < 1)
|
|
||||||
weightA = 1;
|
|
||||||
else
|
else
|
||||||
weightA = a.getConnectionWeight().intValue() + 1;
|
weightA = 1;
|
||||||
|
|
||||||
// Check if weight of b is null, assign 1 if it is.
|
// Check if weight of b is null, assign 1 if it is.
|
||||||
if (b.getConnectionWeight() == null)
|
if (b.getConnectionWeight() != null && b.getConnectionWeight().intValue() > 0)
|
||||||
weightB = 1;
|
weightB = b.getConnectionWeight().intValue();
|
||||||
// If weight is less than 1, host will be disabled,
|
// In all other cases assign 1 for sorting.
|
||||||
// but for sorting we set it to 1 to avoid divide
|
|
||||||
// by 0.
|
|
||||||
else if (b.getConnectionWeight().intValue() < 1)
|
|
||||||
weightB = 1;
|
|
||||||
else
|
else
|
||||||
weightB = b.getConnectionWeight().intValue() + 1;
|
weightB = 1;
|
||||||
|
|
||||||
|
// Get current active connections, add 1 to both to avoid calculations with 0.
|
||||||
int connsA = getActiveConnections(a).size() + 1;
|
int connsA = getActiveConnections(a).size() + 1;
|
||||||
int connsB = getActiveConnections(b).size() + 1;
|
int connsB = getActiveConnections(b).size() + 1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user