Called when the client wishes to know on which node the next invocation must be performed.
6566676869707172737475
{ target = (InvokerLocator) ((AopLoadBalancePolicy) lb).chooseTarget(family.get(), invocation); } else { target = (InvokerLocator) lb.chooseTarget(family.get()); } Throwable lastException = null; while (target != null) {
163164165166167168169170171172173
if (!definitivlyRemoveNodeOnFailure) { family.get().resetView(); } target = (InvokerLocator) lb.chooseTarget(family.get()); if (target == null) { if (lastException != null) { throw new RuntimeException("cluster invocation failed, last exception was: ", lastException);
6162636465666768697071
{ testCount++; FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, Arrays.asList(TARGETS)); LoadBalancePolicy lbp = getLoadBalancePolicy(); Object target = lbp.chooseTarget(fci); for (int i = 0; i < 10000; i++) { assertSame(target, getLoadBalancePolicy().chooseTarget(fci)); }
7677787980818283848586
{ testCount++; FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, Arrays.asList(TARGETS)); LoadBalancePolicy lbp1 = getLoadBalancePolicy(); Object target1 = lbp1.chooseTarget(fci); LoadBalancePolicy lbp2 = getLoadBalancePolicy(); assertSame(target1, lbp2.chooseTarget(fci));
8081828384858687888990
LoadBalancePolicy lbp1 = getLoadBalancePolicy(); Object target1 = lbp1.chooseTarget(fci); LoadBalancePolicy lbp2 = getLoadBalancePolicy(); assertSame(target1, lbp2.chooseTarget(fci)); fci.removeDeadTarget(target1); Object target3 = lbp1.chooseTarget(fci);
8889909192939495969798
Object target3 = lbp1.chooseTarget(fci); assertFalse(target1.equals(target3)); assertSame(target3, lbp2.chooseTarget(fci)); } }
6768697071727374757677
testCount++; List<String> targets = Arrays.asList(TARGETS); FamilyClusterInfo fci = ClusteringTargetsRepository.initTarget(FAMILY_BASE + testCount, targets); LoadBalancePolicy lbp = getLoadBalancePolicy(); Object target = lbp.chooseTarget(fci); assertTrue(targets.contains(target)); for (int i = 0; i < 10; i++) assertEquals(target, lbp.chooseTarget(fci));
7273747576777879808182
Object target = lbp.chooseTarget(fci); assertTrue(targets.contains(target)); for (int i = 0; i < 10; i++) assertEquals(target, lbp.chooseTarget(fci)); } public void testInitialSelection() { testCount++;