com.googlecode.lightest.core
Class QueuedDispatcherAssignmentStrategy

java.lang.Object
  extended by com.googlecode.lightest.core.QueuedDispatcherAssignmentStrategy
All Implemented Interfaces:
IDispatcherAssignmentStrategy, groovy.lang.GroovyObject
Direct Known Subclasses:
SimpleDispatcherAssignmentStrategy

public abstract class QueuedDispatcherAssignmentStrategy
extends Object
implements groovy.lang.GroovyObject, IDispatcherAssignmentStrategy

Assigns testcases to dispatchers in a FIFO manner. Each testcase passed into assign() waits in a queue until getAvailableDispatchers() returns an idle ITaskDispatcher object the testcase can be assigned to.


Constructor Summary
QueuedDispatcherAssignmentStrategy()
           
 
Method Summary
 boolean assign(LightestTestCase testcase)
          Assigns a dispatcher to a testcase, and the testcase to the dispatcher.
protected  List getAvailableDispatchers(LightestTestCase testcase)
          Returns a potentially empty list of currently available (unassigned) task dispatchers for a given testcase.
protected abstract  List getCompatibleDispatchers(LightestTestCase testcase)
           
 groovy.lang.MetaClass getMetaClass()
           
 Object getProperty(String name)
           
 Object invokeMethod(String name, Object args)
           
 void setAssignmentTimeout(long timeout)
          Sets the maximum time a testcase will wait to have a task dispatcher assigned to it, before timing out.
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setProperty(String name, Object value)
           
 void unassign(LightestTestCase testcase)
          Breaks the bi-directional association between a dispatcher and a testcase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.googlecode.lightest.core.IDispatcherAssignmentStrategy
setDispatchers
 

Constructor Detail

QueuedDispatcherAssignmentStrategy

public QueuedDispatcherAssignmentStrategy()
Method Detail

setAssignmentTimeout

public void setAssignmentTimeout(long timeout)
Sets the maximum time a testcase will wait to have a task dispatcher assigned to it, before timing out.

Parameters:
timeout - allotted time, in milliseconds. Non-positive values will be considered infinite time.

assign

public boolean assign(LightestTestCase testcase)
Assigns a dispatcher to a testcase, and the testcase to the dispatcher. Returns true if the assignment was successful, and false otherwise. Testcases that cannot be immediately assigned are queued up for assignment in FIFO order, and stay in the queue until assigned, or the timeout elapses (if any).

Specified by:
assign in interface IDispatcherAssignmentStrategy
Parameters:
testcase -

unassign

public void unassign(LightestTestCase testcase)
Description copied from interface: IDispatcherAssignmentStrategy
Breaks the bi-directional association between a dispatcher and a testcase.

Specified by:
unassign in interface IDispatcherAssignmentStrategy

getAvailableDispatchers

protected List getAvailableDispatchers(LightestTestCase testcase)
Returns a potentially empty list of currently available (unassigned) task dispatchers for a given testcase. This accommodates the possibility of filtering dispatchers based on testcase attributes, by starting with the result of getCompatibleDispatchers() passing in the testcase.

Parameters:
testcase - the testcase for which to return the dispatchers

getCompatibleDispatchers

protected abstract List getCompatibleDispatchers(LightestTestCase testcase)

getMetaClass

public groovy.lang.MetaClass getMetaClass()
Specified by:
getMetaClass in interface groovy.lang.GroovyObject

setMetaClass

public void setMetaClass(groovy.lang.MetaClass metaClass)
Specified by:
setMetaClass in interface groovy.lang.GroovyObject

invokeMethod

public Object invokeMethod(String name,
                           Object args)
Specified by:
invokeMethod in interface groovy.lang.GroovyObject

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface groovy.lang.GroovyObject

setProperty

public void setProperty(String name,
                        Object value)
Specified by:
setProperty in interface groovy.lang.GroovyObject


Copyright © 2009. All Rights Reserved.