Project Wonder 5.0

er.extensions.concurrency
Class ERXJobLoadBalancer

java.lang.Object
  extended by er.extensions.concurrency.ERXJobLoadBalancer

public class ERXJobLoadBalancer
extends java.lang.Object


Nested Class Summary
static class ERXJobLoadBalancer.JobSet
          Describes which jobs (index mod modulo) the worker should attempt to process
static class ERXJobLoadBalancer.WorkerIdentification
          Identifies a worker to the load balancer
 
Constructor Summary
ERXJobLoadBalancer()
           
 
Method Summary
static void createJobs(java.lang.String workerType, int n)
           
 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
 ERXJobLoadBalancer.JobSet idSpace(ERXJobLoadBalancer.WorkerIdentification workerId)
           
static ERXJobLoadBalancer jobLoadBalancer()
           
static void main(java.lang.String[] args)
           
protected  java.lang.String pathForWorkerIdentification(ERXJobLoadBalancer.WorkerIdentification workerId)
           
static void processJobs(java.lang.String workerType, int workerNumber)
           
 void setTtlForWorkerType(java.lang.String type, long ttl)
          Sets the timeout for a given worker type
protected  java.io.File sharedRoot()
           
 java.lang.String sharedRootLocation()
           
 long ttlForWorkerType(java.lang.String type)
           
static void usage()
           
 java.lang.String workerInstanceIdentification()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXJobLoadBalancer

public ERXJobLoadBalancer()
Method Detail

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)

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.