biz.hammurapi.util
Class LoadBalancer

java.lang.Object
  extended by biz.hammurapi.util.LoadBalancer
All Implemented Interfaces:
Worker

public class LoadBalancer
extends java.lang.Object
implements Worker

Load balancer distributes work to other workers according to weights. The less the weight the more job worker is getting.

Author:
Pavel Vlasov

Constructor Summary
LoadBalancer()
           
 
Method Summary
 void addWorker(Worker worker, int weight)
           
 boolean post(java.lang.Runnable job)
          Gives job to worker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoadBalancer

public LoadBalancer()
Method Detail

post

public boolean post(java.lang.Runnable job)
Description copied from interface: Worker
Gives job to worker

Specified by:
post in interface Worker
Returns:
true if worker accepted job. There can be situations when worker cannot accept job. E.g. remote worker cannot accept non-serializable job.

addWorker

public void addWorker(Worker worker,
                      int weight)


Copyright © 2003 Hammurapi Group. All Rights Reserved.