1 22 package org.jboss.ha.framework.interfaces; 23 24 import java.util.List ; 25 26 import org.jboss.invocation.Invocation; 27 28 43 public class FirstAvailableIdenticalAllProxies implements LoadBalancePolicy 44 { 45 private static final long serialVersionUID = 2910756623413400467L; 47 48 50 52 54 56 public void init (HARMIClient father) 57 { 58 } 60 61 public Object chooseTarget (FamilyClusterInfo clusterFamily) 62 { 63 return chooseTarget(clusterFamily, null); 64 } 65 public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision) 66 { 67 Object target = clusterFamily.getObject (); 68 List targets = clusterFamily.getTargets (); 69 70 if (targets.size () == 0) 71 return null; 72 73 if (target != null && targets.contains (target) ) 74 { 75 return target; 76 } 77 else 78 { 79 int cursor = RandomRobin.localRandomizer.nextInt (targets.size()); 80 target = targets.get(cursor); 81 clusterFamily.setObject (target); 82 return target; 83 } 84 } 85 86 } 87 | Popular Tags |