org.mmbase.module.builders
Class Vwms

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.Vwms
All Implemented Interfaces:
EventListener, NodeEventListener, RelationEventListener, MMBaseObserver

public class Vwms
extends MMObjectBuilder
implements MMBaseObserver

Virtual WebMasterS (VWMS) are agents within MMBase. To be able to start a VWMS the following things have to be done:
- Create a VWMS that does the work
- Start the VWMS in the VWMS-Builder.
- Make a relation from the Vwm object to a MMserver.
- start the VWMS-Builder if it isn't already running.

In the Vwms builder you have to insert the following information:
Name: name of the Vwm
Machine: machine on which the VwmM is running (wanted_cpu)
Maintenance_Time: This is the interval time in which the Vwm is invoked
State: inactive means Vwm is off. active means Vwm is on.
Description: just a description
ClassName: the classname of the actual VWM that is performing the task.
Note that currently, vwms are only started during startup.

Version:
$Id: Vwms.java 35335 2009-05-21 08:14:41Z michiel $
Author:
Arjan Houtman, Rico Jansen, Pierre van Rooden (javadoc)
Application:
VWMs

Field Summary
static int STATUS_ACTIVE
          Status value for a VWM that it is active
static int STATUS_INACTIVE
          Status value for a VWM that it is inactive
static int STATUS_REFRESH
          Status value for a VWM that it is being refreshed (?)
(package private)  Hashtable<String,VwmInterface> vwm_cache
          Cache of VWMs, by name.
 
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
Vwms()
           
 
Method Summary
 String getGUIIndicator(String field, MMObjectNode node)
          Returns gui information for a field.
 VwmInterface getVwm(String vwmname)
          Retrieve a currently active vwm by name.
 boolean init()
          Initializes the vwms builder.
 boolean nodeLocalChanged(String machine, String number, String builder, String ctype)
          Passes a local change of a vwms node to the appropriate (active) vwm.
 boolean nodeRemoteChanged(String machine, String number, String builder, String ctype)
          Passes a remote change of a vwms node to the appropriate (active) vwm.
 boolean putTask(String vwmname, MMObjectNode node)
          Passes a task to a vwm.
 boolean sendMail(String who, String subject, String msg)
          Send mail, using this builder's email settings.
 boolean sendMail(String who, String to, String subject, String msg)
          Send mail, using this builder's email settings.
 void startVwms()
          Starts all vwms whose 'entries are related to the current server (entry in mmservers), and that are marked as 'active'.
 void startVwmsByField()
          Deprecated. Unused. Use startVwms() instead.
 
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, 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, notify, notify, preCommit, 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_INACTIVE

public static final int STATUS_INACTIVE
Status value for a VWM that it is inactive

See Also:
Constant Field Values

STATUS_ACTIVE

public static final int STATUS_ACTIVE
Status value for a VWM that it is active

See Also:
Constant Field Values

STATUS_REFRESH

public static final int STATUS_REFRESH
Status value for a VWM that it is being refreshed (?)

See Also:
Constant Field Values

vwm_cache

Hashtable<String,VwmInterface> vwm_cache
Cache of VWMs, by name.

Constructor Detail

Vwms

public Vwms()
Method Detail

init

public boolean init()
Initializes the vwms builder. Doesn't do anything, which is odd as you would expect it to read the emailXXX properties. This now happens in the sendMail(java.lang.String, java.lang.String, java.lang.String) method.

Overrides:
init in class MMObjectBuilder
Returns:
Always true.
See Also:
MMObjectBuilder.create()

getGUIIndicator

public String getGUIIndicator(String field,
                              MMObjectNode node)
Returns gui information for a field. Returns a descriptive value in the case of the 'status' field.

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

startVwmsByField

public void startVwmsByField()
Deprecated. Unused. Use startVwms() instead.

Starts all vwms whose 'wanted_cpu' field indicates they want to be run on this machine (either this particular one or all machines), and that are marked as 'active'. The builder tries to load the class (which should implement the VwmInterface), instantiate a vwms using that class, and initialize it. The vwm is also referred to as a 'bot'.


startVwms

public void startVwms()
Starts all vwms whose 'entries are related to the current server (entry in mmservers), and that are marked as 'active'. The builder tries to load the class (which should implement the VwmInterface), instantiate a vwms using that class, and initialize it.


putTask

public boolean putTask(String vwmname,
                       MMObjectNode node)
Passes a task to a vwm.

Parameters:
vwmname - the name of the vwm to pass the task
node - the node to apss as a task
Returns:
true if the task was passed, false if the vwm did not exist.

sendMail

public boolean sendMail(String who,
                        String subject,
                        String msg)
Send mail, using this builder's email settings. Passes its parameters,a s well as the field emailTo to the method that actually sends the mail. The field emailTo can be null when passed the first time, which means that the first call would always fail (?)

Parameters:
who - email address (?) of the sender
subject - subject of the message
msg - the message itself
Returns:
true if the mail was send, false otherwise

sendMail

public boolean sendMail(String who,
                        String to,
                        String subject,
                        String msg)
Send mail, using this builder's email settings.

Parameters:
who - email address (?) of the sender
to - email address of the receiver
subject - subject of the message
msg - the message itself
Returns:
true if the mail was send, false otherwise

getVwm

public VwmInterface getVwm(String vwmname)
Retrieve a currently active vwm by name.

Parameters:
vwmname - the name of the vwm to retrieve
Returns:
a VwmInterface object, or null if the vwm does not exist or is not active.

nodeRemoteChanged

public boolean nodeRemoteChanged(String machine,
                                 String number,
                                 String builder,
                                 String ctype)
Passes a remote change of a vwms node to the appropriate (active) vwm.

Specified by:
nodeRemoteChanged in interface MMBaseObserver
Overrides:
nodeRemoteChanged in class MMObjectBuilder
Parameters:
machine - Name of the machine that changed the node.
number - Number of the changed node as a String
builder - type of the changed node
ctype - command type, not very well documented
Returns:
always true

nodeLocalChanged

public boolean nodeLocalChanged(String machine,
                                String number,
                                String builder,
                                String ctype)
Passes a local change of a vwms node to the appropriate (active) vwm.

Specified by:
nodeLocalChanged in interface MMBaseObserver
Overrides:
nodeLocalChanged in class MMObjectBuilder
Parameters:
machine - Name of the machine that changed the node.
number - Number of the changed node as a String
builder - type of the changed node
ctype - command type, not very well documented
Returns:
always true


MMBase 2.0-SNAPSHOT - null