er.extensions.concurrency
Class ERXJobLoadBalancer
java.lang.Object
er.extensions.concurrency.ERXJobLoadBalancer
public class ERXJobLoadBalancer
- extends java.lang.Object
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ERXJobLoadBalancer
public ERXJobLoadBalancer()
jobLoadBalancer
public static ERXJobLoadBalancer jobLoadBalancer()
sharedRootLocation
public java.lang.String sharedRootLocation()
- Returns:
- the shared path where the state of the workers is stored
sharedRoot
protected java.io.File sharedRoot()
ttlForWorkerType
public long ttlForWorkerType(java.lang.String type)
- Parameters:
type
-
- Returns:
- the ttl for a given worker type. An instance that has not called heartbeat for more than this TTL
will be considered dead by the other instances
setTtlForWorkerType
public void setTtlForWorkerType(java.lang.String type,
long ttl)
- Sets the timeout for a given worker type
- Parameters:
type
- ttl
- (in milliseconds)
pathForWorkerIdentification
protected java.lang.String pathForWorkerIdentification(ERXJobLoadBalancer.WorkerIdentification workerId)
heartbeat
public void heartbeat(ERXJobLoadBalancer.WorkerIdentification workerId)
- Signals to the load balncer that the worker identified is alive
Clients should call this periodically, and certainly more often than the timeout
- Parameters:
workerId
- which worker is alive
idSpace
public ERXJobLoadBalancer.JobSet idSpace(ERXJobLoadBalancer.WorkerIdentification workerId)
- Parameters:
workerId
-
- Returns:
- the JobSet that the worker should attempt to process
Given a worker looks at the shared state and determine the id space (index mod module) they should be processing
workerInstanceIdentification
public java.lang.String workerInstanceIdentification()
- Returns:
- a String suitable to identify this particular worker instance
!! this string is not MT safe
main
public static void main(java.lang.String[] args)
usage
public static void usage()
createJobs
public static void createJobs(java.lang.String workerType,
int n)
processJobs
public static void processJobs(java.lang.String workerType,
int workerNumber)
Copyright © 2002 – 2007 Project Wonder.