xmlBlaster 2.2.0 API

org.xmlBlaster.engine.cluster.simpledomain
Class DomainToMaster

java.lang.Object
  extended by org.xmlBlaster.engine.cluster.simpledomain.DomainToMaster
All Implemented Interfaces:
I_MapMsgToMasterId, I_Plugin

public final class DomainToMaster
extends java.lang.Object
implements I_Plugin, I_MapMsgToMasterId

Finds the master of a message depending on the domain attribute of the message key tag.

This is a simple demo implementation for clustering, the plugin can be loaded depending on the mime type of a message, we register it here for all messages, see getMessages().

Switch on logging with '-trace[cluster] true'

Since:
0.79e
Author:
xmlBlaster@marcelruff.info

Field Summary
private  ServerScope glob
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
 
Constructor Summary
DomainToMaster()
           
 
Method Summary
 NodeMasterInfo getMasterId(NodeMasterInfo nodeMasterInfo, MsgUnit msgUnit)
          Find out who is the master of the provided message.
 java.lang.String[] getMimeExtended()
          Get the content MIME version number for which this plugin applies
 java.lang.String[] getMimeTypes()
          Get the content MIME type for which this plugin applies
 java.lang.String getName()
          Get a human readable name of this implementation
 java.lang.String getType()
          Return plugin type for Plugin loader
 java.lang.String getVersion()
          Return plugin version for Plugin loader
 void init(Global glob, PluginInfo pluginInfo)
          This method is called by the PluginManager (enforced by I_Plugin).
 void initialize(ServerScope glob, ClusterManager clusterManager)
          This is called after instantiation of the plugin
 void reset()
          Is called when new configuration arrived, notify the plugin to empty its cache or do whatever it needs to do.
 void shutdown()
          Cleans up the resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private java.lang.String ME

glob

private ServerScope glob

log

private static java.util.logging.Logger log
Constructor Detail

DomainToMaster

public DomainToMaster()
Method Detail

initialize

public void initialize(ServerScope glob,
                       ClusterManager clusterManager)
This is called after instantiation of the plugin

Specified by:
initialize in interface I_MapMsgToMasterId
Parameters:
glob - The Global handle of this xmlBlaster server instance.

reset

public void reset()
Is called when new configuration arrived, notify the plugin to empty its cache or do whatever it needs to do.

Specified by:
reset in interface I_MapMsgToMasterId

init

public void init(Global glob,
                 PluginInfo pluginInfo)
This method is called by the PluginManager (enforced by I_Plugin).

Specified by:
init in interface I_Plugin
See Also:
I_Plugin.init(org.xmlBlaster.util.Global,org.xmlBlaster.util.plugin.PluginInfo)

getType

public java.lang.String getType()
Return plugin type for Plugin loader

Specified by:
getType in interface I_Plugin
Returns:
"SimpleDomainToMasterMapper"

getVersion

public java.lang.String getVersion()
Return plugin version for Plugin loader

Specified by:
getVersion in interface I_Plugin
Returns:
"1.0"

getMimeTypes

public java.lang.String[] getMimeTypes()
Get the content MIME type for which this plugin applies

Specified by:
getMimeTypes in interface I_MapMsgToMasterId
Returns:
"*" This plugin handles all mime types

getMimeExtended

public java.lang.String[] getMimeExtended()
Get the content MIME version number for which this plugin applies

Specified by:
getMimeExtended in interface I_MapMsgToMasterId
Returns:
"1.0" (this is the default version number)

getName

public java.lang.String getName()
Get a human readable name of this implementation

Specified by:
getName in interface I_MapMsgToMasterId
Returns:
"SimpleDomainToMasterMapper"

getMasterId

public NodeMasterInfo getMasterId(NodeMasterInfo nodeMasterInfo,
                                  MsgUnit msgUnit)
                           throws XmlBlasterException
Find out who is the master of the provided message.
   <clusternode id='heron'>
   <master type='DomainToMaster' version='0.9'>
     <![CDATA[
       <key type='DOMAIN' domain='RUGBY'/>
       <key type='XPATH'>//GAME</key>
     ]]>
     <filter type='ContentLength'>
       8000
     </filter>
     <filter type='ContainsChecker' version='7.1' xy='true'>
       rugby
     </filter>
   </master>
   </clusternode>
 
If the attribute domain='RUGBY' and the meta informations contains the tag <GAME> and the message is shorter 8000 bytes and the message content contains a token 'rugby' the cluster node 'heron' is chosen as the master of the message.

Specified by:
getMasterId in interface I_MapMsgToMasterId
Parameters:
msgUnit - The message
nodeMasterInfo - The mapping rule to find the master
Returns:
The nodeMasterInfo (same as you passed as parameter) it this is a possible master or null if not suitable.
You can access the master ClusterNode with nodeMasterInfo.getClusterNode() and the xmlBlasterConnection to the master node with nodeMasterInfo.getClusterNode().getXmlBlasterAccess()
Throws:
XmlBlasterException

shutdown

public void shutdown()
              throws XmlBlasterException
Description copied from interface: I_Plugin
Cleans up the resource.

Specified by:
shutdown in interface I_Plugin
Throws:
XmlBlasterException - if an exception occurs. The exception is handled by the RunLevelManager depending on how the plugin has been configured with the action:

<action do='STOP' onShutdownRunlevel='2' sequence='5' onFail='resource.configuration.pluginFailed'> If onFail is defined to something, the RunLevelManager will stop.


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.