org.mmbase.module.builders
Class Vwmtasks

java.lang.Object
  |
  +--org.mmbase.module.core.MMTable
        |
        +--org.mmbase.module.core.MMObjectBuilder
              |
              +--org.mmbase.module.builders.Vwmtasks
All Implemented Interfaces:
java.lang.Runnable

public class Vwmtasks
extends MMObjectBuilder
implements java.lang.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 rusna 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:
5-Apr-2001
Author:
Arjan Houtman, Pierre van Rooden (javadocs)

Field Summary
 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
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
broadcastChanges, className, database, debug, description, descriptions, fields, NODE_MAX_SIZE, nodeCache, obj2type, OBJ2TYPE_MAX_SIZE, oType, searchAge, sortedDBLayout, TEMPNODE_DEFAULT_SIZE, TemporaryNodes, virtual
 
Fields inherited from class org.mmbase.module.core.MMTable
mmb, tableName
 
Constructor Summary
Vwmtasks()
           
 
Method Summary
 java.lang.String getGUIIndicator(MMObjectNode node)
          What should a GUI display for this node.
 java.lang.String getGUIIndicator(java.lang.String field, MMObjectNode node)
          What should a GUI display for this node/field combo.
protected  void getVwmTasks()
          Task scheduling routine.
 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
addField, addLocalObserver, addRemoteObserver, buildSet, checkAddTmpField, commit, convertMMNode2SQL, count, create, createAlias, created, debug, deleteNodeCache, executeFunction, fieldLocalChanged, getAge, getAliasedNode, getCacheNumbers, getCacheSize, getCacheSize, getClassName, getDBByte, getDBKey, getDBState, getDBText, getDBType, getDefaultTeaser, getDefaultUrl, getDescription, getDescriptions, getDutchSName, getEditFields, getField, getFieldNames, getFields, getFullTableName, getFunctionParameters, getHardNode, getHTML, getInitParameter, getInitParameters, getList, getMachineName, getMaintainer, getNewNode, getNewTmpNode, getNextField, getNode, getNode, getNodeType, getNumberFromName, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getSortedFields, getSortedListFields, getTableName, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, getXMLSetup, hostname_function, init_obj2type, init, insert, insert, insertDone, isNodeCached, isVirtual, isXMLConfig, nodeLocalChanged, nodeRemoteChanged, preEdit, process, putTmpNode, readSearchResults, removeField, removeNode, removeRelations, removeTmpNode, replace, search, search, search, searchIn, searchIn, searchIn, searchNumbers, searchVector, searchVector, searchVector, searchVector, searchVectorIn, searchVectorIn, searchVectorIn, searchVectorIn, searchWithWhere, sendFieldChangeSignal, setClassName, setDBLayout_xml, setDBLayout, setDebug, setDefaults, setDescription, setDescriptions, setDutchSName, setInitParameter, setMaintainer, setMMBase, setPluralNames, setSearchAge, setSingularNames, setTableName, setValue, setVersion, setXmlConfig, setXMLPath, setXMLValues, signalNewObject, testValidData, toXML, waitUntilNodeChanged, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_REQUEST

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

STATUS_CLAIMED

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

STATUS_DONE

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

STATUS_TIMEOUT

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

STATUS_ERROR

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

SLEEP_TIME

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

replaceCache

public boolean replaceCache
Constructor Detail

Vwmtasks

public Vwmtasks()
Method Detail

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 java.lang.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 java.lang.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 java.lang.String getGUIIndicator(java.lang.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 2001