org.mmbase.module.builders
Class Vwmtasks

java.lang.Object
  extended by org.mmbase.util.functions.FunctionProvider
      extended by org.mmbase.module.core.MMTable
          extended by org.mmbase.module.core.MMObjectBuilder
              extended by org.mmbase.module.builders.Vwmtasks
All Implemented Interfaces:
Runnable, EventListener, NodeEventListener, RelationEventListener

public class Vwmtasks
extends MMObjectBuilder
implements Runnable

Virtual Web Master task builder. This builder holds the tasks that need to be performed by the various VWMs (which are registered in the VWMS builder). It also runs a taskscheduler that periodically cehcks whether any new tasks need to be handled
Task nodes have a number of fields that define if, when, and how a task is to be performed. These fields are :
Requested Machine: the machine on which the task is to be performed (wantedcpu)
VWM: the name of the vwm (as known in the VWMS builder) trhat should perform the task
Status : the state of the task (i.e. requesting, claimed, error, done)
Claiming Machine : the cpu that claimed the task for performance (claimedcpu)
Wanted Time : time at which to start the task
Changed Time : time at which the task was last changed
Expire Time : time at which the task expires
Task : name of the task
Id : unknown
Data : field for including properties/parameters

Version:
$Id: Vwmtasks.java 35335 2009-05-21 08:14:41Z michiel $
Author:
Arjan Houtman, Pierre van Rooden (javadocs)
Application:
VWMs
Rename:
VwmTasks

Field Summary
(package private)  Thread kicker
          Thread in which the task scheduler runms
(package private)  int lastchecked
          Time (in seconds since 1/1/1970) that the builder last checked for new tasknodes to en handled
 boolean replaceCache
           
static int SLEEP_TIME
          The interval (in seconds) between checks for new nodes by the task scheduler.
static int STATUS_CLAIMED
          Status value for a task that is being performed
static int STATUS_DONE
          Status value for a task that was succesfully performed
static int STATUS_ERROR
          Status value for a task that failed to be performed
static int STATUS_REQUEST
          Status value for a task that requests to be performed
static int STATUS_TIMEOUT
          Status value for a task that timed out
(package private)  Hashtable vwm_cache
           
(package private)  Vwms vwms
          Reference to the VWMs builder
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
AGE_PARAMETERS, broadCastChanges, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, EVENT_TYPE_LOCAL, EVENT_TYPE_REMOTE, FIELD_NUMBER, FIELD_OBJECT_TYPE, FIELD_OWNER, fields, genericBlobCache, getFunctions, GUI_INDICATOR, GUI_PARAMETERS, guiFunction, infoFunction, internalVersion, nodeCache, oType, pluralNames, searchAge, singularNames, SYSTEM_OWNER, TEMPNODE_DEFAULT_SIZE, TMP_FIELD_EXISTS, TMP_FIELD_NUMBER, virtual, WRAP_PARAMETERS, wrapFunction
 
Fields inherited from class org.mmbase.module.core.MMTable
maxNodesFromQuery, mmb, storageConnector, tableName
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions
 
Constructor Summary
Vwmtasks()
           
 
Method Summary
 String getGUIIndicator(MMObjectNode node)
          What should a GUI display for this node.
 String getGUIIndicator(String field, MMObjectNode node)
          What should a GUI display for this node/field combo.
protected  void getVwmTasks()
          Task scheduling routine.
 boolean init()
          Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called.
 MMObjectNode preCommit(MMObjectNode node)
          This method is called just before an actual write to the database is performed.
 void run()
          VWM maintenance scheduler.
 void start()
          Starts the thread for the task scheduler
 void stop()
          Stops the thread for the task scheduler Sets the kicker field to null, which causes the run method to terminate.
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addEventListener, addField, addLocalObserver, addRemoteObserver, broadcastChanges, checkAddTmpField, clearBlobCache, commit, create, createAlias, createAlias, delete, equals, equals, executeFunction, executeFunction, fieldLocalChanged, getAncestors, getBlobCache, getClassName, getConfigFile, getConfigResource, getDataTypeCollector, getDBState, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEmptyNode, getField, getFieldNames, getFields, getFields, getFunction, getFunctionParameters, getFunctions, getGUIIndicator, getHTML, getInitParameter, getInitParameters, getInitParameters, getInternalVersion, getList, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNodeFromCache, getNodeGUIIndicator, getNumber, getObjectType, getObjectValue, getParentBuilder, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedInputStream, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hasField, hashCode, hashCode, hostname_function, insert, insert, isExtensionOf, isNodeCached, isNull, isVirtual, loadInitParameters, newFunctionInstance, nodeLocalChanged, nodeRemoteChanged, notify, notify, process, removeEventListener, removeField, removeLocalObserver, removeNode, removeRelations, removeRemoteObserver, removeSyncNodes, replace, safeCache, sendFieldChangeSignal, setDefaults, setDescription, setDescriptions, setFields, setInitParameter, setMaintainer, setPluralNames, setSearchAge, setSingularNames, setUniqueValue, setUniqueValue, setValue, setValue, setVersion, setXMLPath, shutdown, testValidData, toString, toString, update, updateFields, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
count, count, created, getFullTableName, getMMBase, getNode, getNodes, getNodes, getNodes, getNodeType, getStorageConnector, getTableName, search, searchVector, setMMBase, setTableName, size
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

STATUS_REQUEST

public static final int STATUS_REQUEST
Status value for a task that requests to be performed

See Also:
Constant Field Values

STATUS_CLAIMED

public static final int STATUS_CLAIMED
Status value for a task that is being performed

See Also:
Constant Field Values

STATUS_DONE

public static final int STATUS_DONE
Status value for a task that was succesfully performed

See Also:
Constant Field Values

STATUS_TIMEOUT

public static final int STATUS_TIMEOUT
Status value for a task that timed out

See Also:
Constant Field Values

STATUS_ERROR

public static final int STATUS_ERROR
Status value for a task that failed to be performed

See Also:
Constant Field Values

SLEEP_TIME

public static final int SLEEP_TIME
The interval (in seconds) between checks for new nodes by the task scheduler.

See Also:
Constant Field Values

replaceCache

public boolean replaceCache

kicker

Thread kicker
Thread in which the task scheduler runms


vwms

Vwms vwms
Reference to the VWMs builder


vwm_cache

Hashtable vwm_cache

lastchecked

int lastchecked
Time (in seconds since 1/1/1970) that the builder last checked for new tasknodes to en handled

Constructor Detail

Vwmtasks

public Vwmtasks()
Method Detail

init

public boolean init()
Description copied from class: MMObjectBuilder
Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called. The method retrieves data from the TypeDef builder, or adds data to that builder if the current builder is not yet registered.

Overrides:
init in class MMObjectBuilder
Returns:
true if init was completed, false if uncompleted.
See Also:
MMObjectBuilder.create()

start

public void start()
Starts the thread for the task scheduler


stop

public void stop()
Stops the thread for the task scheduler Sets the kicker field to null, which causes the run method to terminate.


run

public void run()
VWM maintenance scheduler. Calls the getVwmTasks() method, after which the thread sleeps for a number of seconds as set in SLEEP_TIME.

Specified by:
run in interface Runnable

preCommit

public MMObjectNode preCommit(MMObjectNode node)
This method is called just before an actual write to the database is performed. It sets the last changed time to the current time (so the scheduler will select this node).

Overrides:
preCommit in class MMObjectBuilder
Parameters:
node - The node to be committed.
Returns:
the node to be committed (after changes have been made).

getGUIIndicator

public String getGUIIndicator(MMObjectNode node)
What should a GUI display for this node. Returns the contents of the task field (the task's description).

Overrides:
getGUIIndicator in class MMObjectBuilder
Parameters:
node - The node to display
Returns:
the display of the node as a String

getGUIIndicator

public String getGUIIndicator(String field,
                              MMObjectNode node)
What should a GUI display for this node/field combo. Returns a descriptive text for the status field, or a formatted date struing in case of a time-value.

Overrides:
getGUIIndicator in class MMObjectBuilder
Parameters:
node - The node to display
field - the name field of the field to display
Returns:
the display of the node's field as a String, null if not specified

getVwmTasks

protected void getVwmTasks()
Task scheduling routine. This routine selects all tasks that are to be performed. In order to be selected, a task should be new or recently changed, it's status should indicate that it needs a request, and the desired machine to execute the code should match this machine. The tasks are passed to the VWM that is associated with the task.



MMBase 2.0-SNAPSHOT - null