Called when the client wishes to know on which node the next invocation must be performed.
120121122123124125126127128129130
testCount++; List<String> targets = Arrays.asList(TARGETS); FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, targets); LoadBalancePolicy lbp = getLoadBalancePolicy(); String target = (String) lbp.chooseTarget(fci); int cursor = fci.getCursor(); assertEquals(target, fci.getTargets().get(cursor)); targets = Arrays.asList(new String[]{"W", "X", "Y", "Z"}); fci.updateClusterInfo(targets, 1);
129130131132133134135136137138139
targets = Arrays.asList(new String[]{"W", "X", "Y", "Z"}); fci.updateClusterInfo(targets, 1); int expectedCursor = ++cursor % targets.size(); target = (String) lbp.chooseTarget(fci); cursor = fci.getCursor(); assertEquals(expectedCursor, cursor); assertEquals(target, targets.get(cursor)); }