KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > web > loadbalancer > scheduler > RoundRobinSchedulerService


1 /*
2  * JBoss, the OpenSource WebOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.web.loadbalancer.scheduler;
8
9 import java.net.URL JavaDoc;
10
11 /**
12  * A round robin scheduler.
13  * @jmx:mbean name="jboss.web.loadbalancer: service=RoundRobinScheduler"
14  * extends="org.jboss.web.loadbalancer.scheduler.AbstractSchedulerMBean"
15  *
16  * @author Thomas Peuss <jboss@peuss.de>
17  * @version $Revision: 1.4 $
18  */

19 public class RoundRobinSchedulerService
20     extends AbstractScheduler implements RoundRobinSchedulerServiceMBean {
21   private int index = 0;
22   public RoundRobinSchedulerService() {
23   }
24
25   protected Host getNextHost() {
26     Host host = null;
27     try
28     {
29       host = (Host) hostsUp.get(index++);
30     }
31     catch (IndexOutOfBoundsException JavaDoc iobex)
32     {
33       index = 0;
34     }
35     return host;
36   }
37 }
38
Popular Tags