org.mmbase.module.builders.vwms
Class PageMaster

java.lang.Object
  |
  +--org.mmbase.module.builders.vwms.Vwm
        |
        +--org.mmbase.module.builders.vwms.PageMaster
All Implemented Interfaces:
MMBaseObserver, java.lang.Runnable, VwmInterface, VwmProbeInterface, VwmServiceInterface

public class PageMaster
extends Vwm
implements MMBaseObserver, VwmServiceInterface

A VWM that manages the files by scheduling them to be send to one or more mirror sites. Requests for scheduling is done in the netfile builder. This VWM handles those netfile requests whose service is 'pages'. Available subservices are 'main' and 'mirror'. Requests for file copy are checked periodically. This results in one or more requests for a 'mirror' service, which then result in a file copy request, which is handled in a separate thread. This VWM also has methods for recalculating pages and handling page changes (which in turn result in a request for file copy.) Entry point for these requests are the FileChange methods from the VwmServiceInterface.

Version:
9 Apr 2001
Author:
Daniel Ockeloen, Pierre van Rooden (javadocs)

Fields inherited from class org.mmbase.module.builders.vwms.Vwm
name, probe, sleeptime, Vwms, wvmnode
 
Constructor Summary
PageMaster()
          Constructor for the PageMaster VWM.
 
Method Summary
 void calcPage(java.lang.String url)
          Recalculate a page.
 boolean doMainRequest(MMObjectNode filenode)
          Handles a main subservice on a page.
 boolean fileChange(java.lang.String number, java.lang.String ctype)
          Handles a service-request on a file, registered in the netfiles builder.
 boolean fileChange(java.lang.String service, java.lang.String subservice, java.lang.String filename)
          Schedules a service-request on a file.
 java.util.Vector getMirrorNodes(java.lang.String service)
          Retrieves a list of Mirror Servers.
 java.lang.String getProperty(java.lang.String machine, java.lang.String key)
          Retrieves a named property of a server.
 boolean handleMain(MMObjectNode filenode, int status, java.lang.String ctype)
          Handles a pages/main service request.
 void handleMainCheck(java.lang.String service, java.lang.String subservice, java.lang.String filename)
          Schedules a netfile object to be send to its mirror sites.
 boolean handleMirror(MMObjectNode filenode, int status, java.lang.String ctype)
          Handles a pages/mirror service request.
 boolean nodeChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Called when a local or remote node is changed.
 boolean nodeLocalChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Called when a local node is changed.
 boolean nodeRemoteChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Called when a remote node is changed.
 boolean probeCall()
          Performs general periodic maintenance.
 
Methods inherited from class org.mmbase.module.builders.vwms.Vwm
addClient, claim, debug, failed, getName, getVwmNode, init, parseProperties, performed, performTask, putTask, releaseClient, rollback, run, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mmbase.module.builders.vwms.VwmInterface
addClient, init, releaseClient
 

Constructor Detail

PageMaster

public PageMaster()
Constructor for the PageMaster VWM.
Method Detail

probeCall

public boolean probeCall()
Performs general periodic maintenance. This routine handles alle open pages/main and pages/mirror file service requests. These requests are obtained from the netfiles builder. For each file that should be serviced, the filechange method is called. This routine handles a maximum of 10 page/main, and 50 page/mirror service calls each time it is called. The first time this method is call, nothing happens (?)
Overrides:
probeCall in class Vwm
Returns:
true if maintenance was performed, false otherwise

nodeRemoteChanged

public boolean nodeRemoteChanged(java.lang.String machine,
                                 java.lang.String number,
                                 java.lang.String builder,
                                 java.lang.String ctype)
Called when a remote node is changed.
Specified by:
nodeRemoteChanged in interface MMBaseObserver
Overrides:
nodeRemoteChanged in class Vwm
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, 'c'=changed, 'd'=deleted', 'r'=relations changed, 'n'=new
Returns:
true

nodeLocalChanged

public boolean nodeLocalChanged(java.lang.String machine,
                                java.lang.String number,
                                java.lang.String builder,
                                java.lang.String ctype)
Called when a local node is changed.
Specified by:
nodeLocalChanged in interface MMBaseObserver
Overrides:
nodeLocalChanged in class Vwm
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, 'c'=changed, 'd'=deleted', 'r'=relations changed, 'n'=new
Returns:
true

nodeChanged

public boolean nodeChanged(java.lang.String machine,
                           java.lang.String number,
                           java.lang.String builder,
                           java.lang.String ctype)
Called when a local or remote node is changed. Does not take any action.
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, 'c'=changed, 'd'=deleted', 'r'=relations changed, 'n'=new
Returns:
true

fileChange

public boolean fileChange(java.lang.String service,
                          java.lang.String subservice,
                          java.lang.String filename)
Schedules a service-request on a file. Only "pages/main" services are handled. The service-request is later handled through the probeCall() method.
Specified by:
fileChange in interface VwmServiceInterface
Parameters:
service - the service to be performed
subservice - the subservice to be performed
filename - the filename to service
Returns:
true if maintenance was performed, false otherwise

fileChange

public boolean fileChange(java.lang.String number,
                          java.lang.String ctype)
Handles a service-request on a file, registered in the netfiles builder. Depending on the subservice requested, this routine calls handleMirror(org.mmbase.module.core.MMObjectNode, int, java.lang.String) or handleMain(org.mmbase.module.core.MMObjectNode, int, java.lang.String).
Specified by:
fileChange in interface VwmServiceInterface
Parameters:
number - Number of the node in the netfiles buidler than contain service request information.
ctype - the type of change on that node ("c" : node was changed)
Returns:
true

handleMirror

public boolean handleMirror(MMObjectNode filenode,
                            int status,
                            java.lang.String ctype)
Handles a pages/mirror service request. Places a page in the file2copy queue, so it will be sent to a mirror site by the FileCopier.
Parameters:
node - the filenet node that contains the service request
status - the current status of the node
ctype - the type of change on that node ("c" : node was changed)
Returns:
true

handleMain

public boolean handleMain(MMObjectNode filenode,
                          int status,
                          java.lang.String ctype)
Handles a pages/main service request. The events handled are:
- requests for handling: schedules requests to mirror this page using {@l;ink #doMainRequest}
- changed: page is scheduled to be recalculated
- recaculate" page is recaclcutated and scheduled to be handled
Parameters:
node - the filenet node that contains the service request
status - the current status of the node
ctype - the type of change on that node ("c" : node was changed)
Returns:
true

doMainRequest

public boolean doMainRequest(MMObjectNode filenode)
Handles a main subservice on a page. The page is scheduled to be sent to all appropriate mirrorsites for this service, by setting the request status in the associated mirror nodes. If no mirror nodes are associated with this page, nothing happens.
Parameters:
filenode - the netfiles node with the original (main) request

handleMainCheck

public void handleMainCheck(java.lang.String service,
                            java.lang.String subservice,
                            java.lang.String filename)
Schedules a netfile object to be send to its mirror sites. The routine searches the appropriate netfile node, and sets its status to 'request'. If a node does not exits, a new node is created. In the latter case, the system also creates mirrornodes for each mirrorsite associated with this service.
Parameters:
service - the service to be performed
subservice - the subservice to be performed
filename - the filename to service

getProperty

public java.lang.String getProperty(java.lang.String machine,
                                    java.lang.String key)
Retrieves a named property of a server.
Parameters:
machine - name of the server
key - name of the property to retrieve
Returns:
the property value

calcPage

public void calcPage(java.lang.String url)
Recalculate a page. Invokes the SCAN parser (which will re-cache the page through the scancache module) Only works for SCAN.
Parameters:
the - url of the page to cache

getMirrorNodes

public java.util.Vector getMirrorNodes(java.lang.String service)
Retrieves a list of Mirror Servers. This is done by obtaining a fileserver node and retrieving associated mmserver nodes. This method should be renamed and moved to the netfilesrv builder.
Parameters:
service - preseumably the service to query for. Unused.
Returns:
a Vector containing mmserver nodes that act as mirror server for this service


MMBase 2001