xmlBlaster 2.1.0 API

org.xmlBlaster.engine.cluster
Interface I_LoadBalancer

All Known Implementing Classes:
RoundRobin

public interface I_LoadBalancer

Interface to the load balancing implementation.

See http://www.ddj.com/documents/s=921/ddj9804i/9804i.htm

Author:
xmlBlaster@marcelruff.info

Method Summary
 NodeMasterInfo getClusterNode(java.util.Set nodeMasterInfoSet)
          Your plugin should determine which xmlBlaster node to choose.
 void initialize(ServerScope glob, ClusterManager clusterManager)
          This is called after instantiation of the plugin
 

Method Detail

initialize

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

Parameters:
glob - The Global handle of this xmlBlaster server instance.
clusterManager - My manager

getClusterNode

NodeMasterInfo getClusterNode(java.util.Set nodeMasterInfoSet)
                              throws XmlBlasterException
Your plugin should determine which xmlBlaster node to choose.

You can access the necessary informations like this:

  Iterator it = clusterNodeSet.iterator();
  while (it.hasNext()) {
     NodeMasterInfo nodeMasterInfo = (NodeMasterInfo)it.Next();

     ... // Your load balancing code

     // Return the clusterNode if nodeMasterInfo is OK to handle the message:
     ClusterNode clusterNode = nodeMasterInfo.getClusterNode();
     return clusterNode;
  }
 
This corresponds to the following XML configuration:
  <!-- NodeMasterInfo.java contains the parsed: -->
  <master type='DomainToMaster' stratum='0'>
     <key domain='RUGBY'/>
     <key type='XPATH'>//STOCK</key>
  </master>
 

Parameters:
nodeMasterInfoSet - A set containing NodeMasterInfo objects, the possible xmlBlaster nodes. Is never null, but may have a size of 0. The set i guaranteed to be sorted after
   "available:stratum:nodeId"

   available := The connection state is: 0 connected, 1 polling
   stratum   := 0 master, 1 slave, 2 slaveOfSlave ...
   nodeId    := a unique counter (nodeMasterInfo.getCount())
  
The set contains only nodes marked as allowed (these are nodes we are connected to or polling for), not available nodes are filtered away already.
Returns:
The chosen nodeMasterInfo to handle the message or null to handle it locally You can access the master ClusterNode with nodeMasterInfo.getClusterNode() and the xmlBlasterConnection to the master node with nodeMasterInfo.getClusterNode().getXmlBlasterAccess()
Throws:
XmlBlasterException

xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.