org.mmbase.module.builders.vwms
Class ImageMaster

java.lang.Object
  extended by org.mmbase.module.builders.vwms.Vwm
      extended by org.mmbase.module.builders.vwms.ImageMaster
All Implemented Interfaces:
Runnable, VwmInterface, VwmProbeInterface, VwmServiceInterface, MMBaseObserver

public class ImageMaster
extends Vwm
implements MMBaseObserver, VwmServiceInterface

A VWM that manages image 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 'images'. Available subservices are 'main' and 'mirror'. Requests for file copy are checked periodically. The result is one or more requests for a 'mirror' service, which then result in a file copy request, which is handled in a separate thread. Before copying, images are retrieved from Icache and converted to an 'asis' file (this is the file that actually gets copied).

Version:
$Id: ImageMaster.java 35335 2009-05-21 08:14:41Z michiel $
Author:
Daniel Ockeloen, Pierre van Rooden (javadocs)

Field Summary
(package private)  Vector<aFile2Copy> files
          List of files to transfer.
(package private)  boolean first
           
(package private)  Hashtable properties
           
(package private)  ImagePusher pusher
          The background thread that takes care of of the files scheduled for transfer.
(package private)  Object syncobj
           
 
Fields inherited from class org.mmbase.module.builders.vwms.Vwm
clients, kicker, name, probe, sleeptime, Vwms, wvmnode
 
Constructor Summary
ImageMaster()
          Constructor for ImageMaster
 
Method Summary
 boolean doMainRequest(MMObjectNode filenode)
          Handles a main subservice on an image.
 boolean fileChange(String number, String ctype)
          Handles a service-request on a file, registered in the netfiles builder.
 boolean fileChange(String service, String subservice, String filename)
          Schedules a service-request on a file.
 ByteFieldContainer getCkeyNode(ImageCaches bul, String ckey)
          Return a @link{ ByteFieldContainer} containing the bytes and object number for the cached image with a certain ckey, or null, if not cached.
 String getProperty(String key)
          Retrieves a named property of a server.
 boolean handleMain(MMObjectNode filenode, int status, String ctype)
          Handles a images/main service request.
 void handleMainCheck(String service, String subservice, String filename)
          Schedules a netfile object to be send to its mirror sites.
 boolean handleMirror(MMObjectNode filenode, int status, String ctype)
          Handles an images/mirror service request.
 boolean nodeChanged(String machine, String number, String builder, String ctype)
          Called when a local or remote node is changed.
 boolean nodeLocalChanged(String machine, String number, String builder, String ctype)
          Called when a local node is changed.
 boolean nodeRemoteChanged(String machine, String number, String builder, 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
 

Field Detail

properties

Hashtable properties

first

boolean first

syncobj

Object syncobj

files

Vector<aFile2Copy> files
List of files to transfer. The filelist is periodically cleared by ImagePusher (which purges duplicate files and handles the remaining transfers).


pusher

ImagePusher pusher
The background thread that takes care of of the files scheduled for transfer.

Constructor Detail

ImageMaster

public ImageMaster()
Constructor for ImageMaster

Method Detail

probeCall

public boolean probeCall()
Performs general periodic maintenance. This routine handles alle open images/main and images/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 (?)
Very similar to probeCall().

Specified by:
probeCall in interface VwmProbeInterface
Overrides:
probeCall in class Vwm
Returns:
true if maintenance was performed, false otherwise

nodeRemoteChanged

public boolean nodeRemoteChanged(String machine,
                                 String number,
                                 String builder,
                                 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(String machine,
                                String number,
                                String builder,
                                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(String machine,
                           String number,
                           String builder,
                           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(String service,
                          String subservice,
                          String filename)
Schedules a service-request on a file. Only "images/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(String number,
                          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

getCkeyNode

public ByteFieldContainer getCkeyNode(ImageCaches bul,
                                      String ckey)
Return a @link{ ByteFieldContainer} containing the bytes and object number for the cached image with a certain ckey, or null, if not cached.

Parameters:
ckey - teh ckey to search for
Returns:
null, or a @link{ ByteFieldContainer} object

handleMirror

public boolean handleMirror(MMObjectNode filenode,
                            int status,
                            String ctype)
Handles an images/mirror service request. Converts images to an asis file format, then places the asis file in the files list, so it will be sent to a mirror site by the ImagePusher.

Parameters:
filenode - 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,
                          String ctype)
Handles a images/main service request. Schedules requests to mirror the file using doMainRequest(org.mmbase.module.core.MMObjectNode)

Parameters:
filenode - 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 an image. The image 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(String service,
                            String subservice,
                            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. (actually, it creates one mirrornode for a vpro-server, but this should be altered).

Parameters:
service - the service to be performed
subservice - the subservice to be performed
filename - the filename to service

getProperty

public String getProperty(String key)
Retrieves a named property of a server. Should use the same system as PageMaster (retrieve data from MSMerver).

Parameters:
key - name of the property to retrieve
Returns:
the property value


MMBase 2.0-SNAPSHOT - null