|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.edustructures.sifworks.tools.LoadBalancer
public class LoadBalancer
A LoadBalancer manages a free pool of Baton objects representing the right of a thread to perform a resource-intensive task. For example, you could create a LoadBalancer that represents the task "query all students" and assign it an initial pool of 5 Batons, meaning at most 5 threads will be able to carry out this task at once. A thread must check out a Baton in order to perform the task, and must release it back to the LoadBalancer when finished.
Refer to the Baton class for a description of how to use the LoadBalancer and Baton classes and the LoadBalancerListener interface. These classes can be used to introduce internal load balancing into an agent to significantly improve scalability when connecting to tens or hundreds of zones concurrently.
| Field Summary | |
|---|---|
static boolean |
TRACE
|
| Constructor Summary | |
|---|---|
LoadBalancer(java.lang.Object id,
int batons,
long timeout)
Constructs a LoadBalancer to represent a specific logical task. |
|
| Method Summary | |
|---|---|
void |
addLoadBalancerListener(LoadBalancerListener listener)
Register a LoadBalancerListener with this LoadBalancer. |
void |
checkinBaton(Baton baton)
Check-in a Baton. |
Baton |
checkoutBaton()
Check-out a Baton. |
static void |
define(LoadBalancer balancer)
Define a LoadBalancer that may be subsequently returned by the lookup method. |
int |
getFreeBatons()
Gets the number of Batons |
int |
getLoad()
Gets the current load (the number of Batons in use) |
int |
getTotalBatons()
Gets the total number of Batons |
static LoadBalancer |
lookup(java.lang.Object id)
Lookup a LoadBalancer that was previously defined by the define method. |
void |
removeLoadBalancerListener(LoadBalancerListener listener)
Remove a LoadBalancerListener previously registered with the
addLoadBalancerListener method |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static boolean TRACE
| Constructor Detail |
|---|
public LoadBalancer(java.lang.Object id,
int batons,
long timeout)
id - A unique arbitrary ID that the agent will use to request this
LoadBalancer (e.g. "Request_StudentPersonal")batons - The number of Batons that will be available to threadstimeout - The timeout period (in milliseconds) applied to the
checkoutBaton method. The timeout period should be less
than the HTTP or other transport timeout period so that the connection
to the ZIS does not timeout before the load balancer does.| Method Detail |
|---|
public static void define(LoadBalancer balancer)
lookup method.
balancer - A LoadBalancer instancepublic static LoadBalancer lookup(java.lang.Object id)
define method.
id - The ID of the LoadBalancer to obtain
define methodpublic Baton checkoutBaton()
public void checkinBaton(Baton baton)
public int getLoad()
public int getTotalBatons()
public int getFreeBatons()
public void addLoadBalancerListener(LoadBalancerListener listener)
public void removeLoadBalancerListener(LoadBalancerListener listener)
addLoadBalancerListener method
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||