org.mmbase.clustering
Class ClusterManager

java.lang.Object
  extended by org.mmbase.clustering.ClusterManager
All Implemented Interfaces:
Runnable, AllEventListener, EventListener
Direct Known Subclasses:
Multicast, Multicast, Unicast

public abstract class ClusterManager
extends Object
implements AllEventListener, Runnable

ClusterManager is a thread object that reads the receive queue and calls the objects (listeners) who need to know. The ClusterManager starts communication threads to handle the sending and receiving of messages.

Version:
$Id: ClusterManager.java 42844 2010-07-09 13:31:00Z michiel $
Author:
Nico Klasens, Michiel Meeuwissen, Ernst Bunders

Field Summary
protected  boolean compatible17
           
protected  int follownr
          Followup number of message
protected  Thread kicker
          Thread which processes the messages
protected  int lastRecievedMessage
           
protected  BlockingQueue<byte[]> nodesToSend
          Queue with messages to send to other MMBase instances
protected  BlockingQueue<byte[]> nodesToSpawn
          Queue with received messages from other MMBase instances
protected  Statistics receive
           
protected  Statistics send
           
protected  boolean spawnThreads
           
 
Constructor Summary
ClusterManager()
           
 
Method Summary
protected  byte[] createMessage(Event event)
           
protected  String createMessage(String machine, int nodenr, String tableName, String type)
          Creates MMBase 1.7 parseable message.
protected  void handleEvent(Event event)
           
 void notify(Event event)
           
protected  Event parseMessage(byte[] message)
           
protected  NodeEvent parseMessageBackwardCompatible(String message)
           
protected  void readConfiguration(Map<String,String> configuration)
           
 void run()
           
 void shutdown()
           
protected  void start()
          Starts the Changer Thread.
protected abstract  void startCommunicationThreads()
          Subclasses should start the communication threads in this method
protected abstract  void stopCommunicationThreads()
          Subclasses should stop the communication threads in this method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

receive

protected final Statistics receive

send

protected final Statistics send

nodesToSend

protected final BlockingQueue<byte[]> nodesToSend
Queue with messages to send to other MMBase instances


nodesToSpawn

protected final BlockingQueue<byte[]> nodesToSpawn
Queue with received messages from other MMBase instances


kicker

protected Thread kicker
Thread which processes the messages


spawnThreads

protected boolean spawnThreads

compatible17

protected boolean compatible17

follownr

protected int follownr
Followup number of message


lastRecievedMessage

protected int lastRecievedMessage
Constructor Detail

ClusterManager

public ClusterManager()
Method Detail

shutdown

public final void shutdown()

readConfiguration

protected void readConfiguration(Map<String,String> configuration)

startCommunicationThreads

protected abstract void startCommunicationThreads()
Subclasses should start the communication threads in this method


stopCommunicationThreads

protected abstract void stopCommunicationThreads()
Subclasses should stop the communication threads in this method


notify

public void notify(Event event)
Specified by:
notify in interface AllEventListener

start

protected void start()
Starts the Changer Thread.


createMessage

protected byte[] createMessage(Event event)

createMessage

protected String createMessage(String machine,
                               int nodenr,
                               String tableName,
                               String type)
Creates MMBase 1.7 parseable message. This is simple String, which is prefixed before the actual 1.8 message.

Parameters:
machine - MMBase 'machine name'.
nodenr - node number
tableName - node type (tablename)
type - command type
Returns:
message

parseMessage

protected Event parseMessage(byte[] message)

parseMessageBackwardCompatible

protected NodeEvent parseMessageBackwardCompatible(String message)

run

public void run()
Specified by:
run in interface Runnable
See Also:
Runnable.run()

handleEvent

protected void handleEvent(Event event)
Parameters:
event -
Javadoc:


MMBase 2.0-SNAPSHOT - null