| | |
| | | private Map<Integer, ReplicationServerInfo> newRSInfos( |
| | | ReplicationServerInfo... rsInfos) |
| | | { |
| | | Map<Integer, ReplicationServerInfo> results = |
| | | new HashMap<Integer, ReplicationServerInfo>(); |
| | | Map<Integer, ReplicationServerInfo> results = new HashMap<>(); |
| | | for (ReplicationServerInfo rsInfo : rsInfos) |
| | | { |
| | | results.put(rsInfo.getServerId(), rsInfo); |
| | |
| | | private void containsOnly(final Map<Integer, LocalizableMessage> evaluations, |
| | | MapEntry... entries) |
| | | { |
| | | final List<MapEntry> notFound = new ArrayList<MapEntry>(Arrays.asList(entries)); |
| | | final List<MapEntry> notFound = new ArrayList<>(Arrays.asList(entries)); |
| | | for (Iterator<MapEntry> iter = notFound.iterator(); iter.hasNext();) |
| | | { |
| | | final MapEntry entry = iter.next(); |
| | |
| | | /** Contains ordinal for each message. */ |
| | | private Map<Integer, Integer> getOrdinal(Map<Integer, LocalizableMessage> evaluations) |
| | | { |
| | | final Map<Integer, Integer> result = new LinkedHashMap<Integer, Integer>(); |
| | | final Map<Integer, Integer> result = new LinkedHashMap<>(); |
| | | for (Entry<Integer, LocalizableMessage> entry : evaluations.entrySet()) |
| | | { |
| | | result.put(entry.getKey(), entry.getValue().ordinal()); |
| | |
| | | * Expected winner: the RS |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "AwinnerHost:123", 0L, (byte)1, 1), |
| | | EMPTY_SET); |
| | |
| | | * Excepted winner: first in the list |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "BwinnerHost:123", 0L, (byte)1, 1), |
| | | EMPTY_SET); |
| | |
| | | * Excepted winner: R2 (still no connected DS) |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 1), |
| | | newSet(1)); |
| | |
| | | * and have same weight |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "DwinnerHost:123", 0L, (byte)1, 1), |
| | | newSet(1)); |
| | |
| | | * Excepted winner: RS2 -> 2 DSs on each RS |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 1), |
| | | newSet(1, 2)); |
| | |
| | | * Excepted winner: RS2 -> go to perfect load balance |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 1), |
| | | newSet(1)); |
| | |
| | | * highest weight |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 1), |
| | | newSet(1)); |
| | |
| | | * highest weight |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 1), |
| | | newSet(1, 2)); |
| | |
| | | * highest weight |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 1), |
| | | newSet(1)); |
| | |
| | | * Excepted winner: RS1 -> misses more DSs than RS3 |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "JwinnerHost:123", 0L, (byte)1, 5), |
| | | newSet(1, 2, 3)); |
| | |
| | | * Excepted winner: RS2 (stay connected to it as load correctly spread) |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 1), |
| | | newSet(1)); |
| | |
| | | * Excepted winner: RS2 (one must disconnect from RS1) |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 1), |
| | | newSet(1, 2)); |
| | |
| | | * one with the lowest id so not DS with server id 2) |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "MwinnerHost:123", 0L, (byte)1, 1), |
| | | newSet(1, 2)); |
| | |
| | | * Excepted winner: RS2 no change as load correctly spread |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 3), |
| | | newSet(1, 2, 3, 4, 5, 6)); |
| | |
| | | * previous test where the loads were ok) |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 3), |
| | | newSet(1, 2, 3, 4)); |
| | |
| | | * is one of the two lowest ids connected to RS4 |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "PwinnerHost:123", 0L, (byte)1, 3), |
| | | newSet(1, 2, 3, 4)); |
| | |
| | | * is not one of the two lowest ids connected to RS4 |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 3), |
| | | newSet(1, 2, 3, 4)); |
| | |
| | | * previous test where the loads were ok) |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte) 1, 3), |
| | | newSet(1, 2, 3, 4)); |
| | |
| | | * RS. |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "RwinnerHost:123", 0L, (byte)1, 1), |
| | | newSet(1, 2)); |
| | |
| | | * Note: Same test as before, but not with the lowest local DS server id |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "SwinnerHost:123", 0L, (byte)1, 1), |
| | | newSet(1, 2)); |
| | |
| | | * the local server would not stop going and coming back between RSs. |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "TwinnerHost:123", 0L, (byte)1, 1), |
| | | newSet(1, 2)); |
| | |
| | | * the local server would not stop going and coming back between RSs. |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "UwinnerHost:123", 0L, (byte)1, 1), |
| | | newSet(1, 2, 3)); |
| | |
| | | * RS3 |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "looserHost:123", 0L, (byte)1, 1), |
| | | newSet(1, 2)); |
| | |
| | | * DS server id 1 should disconnect for reconnection to RS3 |
| | | */ |
| | | |
| | | rsInfos = new HashMap<Integer, ReplicationServerInfo>(); |
| | | rsInfos = new HashMap<>(); |
| | | put(rsInfos, |
| | | new RSInfo(11, "WwinnerHost:123", 0L, (byte)1, 1), |
| | | newSet(1, 2)); |