1 22 package org.jboss.ha.framework.interfaces; 23 24 import java.util.List ; 25 import java.util.Random ; 26 27 import org.jboss.invocation.Invocation; 28 29 37 public class RandomRobin implements LoadBalancePolicy 38 { 39 41 private static final long serialVersionUID = -3599638697906618428L; 42 45 public static final Random localRandomizer = new Random (System.currentTimeMillis ()); 46 47 49 51 53 55 public void init (HARMIClient father) 56 { 57 } 59 60 public Object chooseTarget (FamilyClusterInfo clusterFamily) 61 { 62 return chooseTarget(clusterFamily, null); 63 } 64 public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision) 65 { 66 List targets = clusterFamily.getTargets (); 67 int max = targets.size(); 68 69 if (max == 0) 70 return null; 71 72 int cursor = localRandomizer.nextInt (max); 73 return targets.get(cursor); 74 } 75 76 } 77 | Popular Tags |