eaLib API Docs
Last Modified : January 7 2002

mss.ea.al
Class MessageBroker

java.lang.Object
  |
  +--mss.ea.al.MessageBroker
All Implemented Interfaces:
MessageRecipient, java.lang.Runnable

public class MessageBroker
extends java.lang.Object
implements MessageRecipient, java.lang.Runnable

Message broker for delivering messages to flow elements.

Since:
0.2
Version:
$Revision: 1.4 $ $Date: 2001/12/21 09:47:05 $
Author:
Andreas Rummler

Field Summary
protected  java.util.HashMap channelMap
          Mappings from flow elements to their message channels.
protected  java.util.HashMap lockMap
          Mapping from flow elements to their locks.
protected  Sync mainSync
          Lock for this broker.
protected  java.lang.String name
          Name of this broker.
protected  java.util.LinkedList notificationQueue
          Queue with notifications about incoming messages.
protected  java.util.HashSet operatorSet
          Set of operators that are not sources or sinks.
protected  java.util.HashSet sinkSet
          Set of sink elements.
protected  java.util.HashSet sourceSet
          Set of source elements.
protected  java.util.HashMap stateMap
          Mappings from flow elements to their state.
 
Constructor Summary
MessageBroker()
          Constructor.
 
Method Summary
 void acquireChannel(java.lang.Object sender)
          Acquires a message channel.
protected  boolean checkElementsForState(ElementState state)
          Checks for a specific state of the all elements.
protected  boolean checkForKillCompletion()
          Checks if all operators have reached the state DEAD.
protected  boolean checkForSetupCompletion()
          Checks if all operators have completed their setup.
protected  boolean checkForSinkOverflow()
          Checks if all sinks have reached the OVERFLOW state.
protected  boolean checkForState(ElementState state)
          Checks for a specific state of the all elements.
protected  boolean checkSinksForState(ElementState state)
          Checks for a specific state of the all sink elements.
protected  boolean checkSourcesForState(ElementState state)
          Checks for a specific state of the all source elements.
 void invokeSources()
          Invokes the sources elements.
 void killOperators()
          Kills all operators.
protected  void printStateMap()
          Prints the state map for debugging.
protected  void processMessages()
          Processes incoming messages.
 void register(FlowElement element)
          Registers a flow element at this broker.
 void run()
          Runs this broker.
 void setupOperators()
          Sets up all operators.
 java.lang.String toString()
          Returns a string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
Name of this broker.

lockMap

protected java.util.HashMap lockMap
Mapping from flow elements to their locks.

stateMap

protected java.util.HashMap stateMap
Mappings from flow elements to their state.

channelMap

protected java.util.HashMap channelMap
Mappings from flow elements to their message channels.

sourceSet

protected java.util.HashSet sourceSet
Set of source elements.

operatorSet

protected java.util.HashSet operatorSet
Set of operators that are not sources or sinks.

sinkSet

protected java.util.HashSet sinkSet
Set of sink elements.

notificationQueue

protected java.util.LinkedList notificationQueue
Queue with notifications about incoming messages.

mainSync

protected Sync mainSync
Lock for this broker.
Constructor Detail

MessageBroker

public MessageBroker()
Constructor.
Method Detail

register

public void register(FlowElement element)
Registers a flow element at this broker.
Parameters:
element - flow element

acquireChannel

public void acquireChannel(java.lang.Object sender)
Acquires a message channel. This puts the sender into the notification queue and releases the main sync.
Specified by:
acquireChannel in interface MessageRecipient
Parameters:
sender - sender of the notification

setupOperators

public void setupOperators()
Sets up all operators. This creates the threads for all flow elements, starts them and waits for setup completion.

invokeSources

public void invokeSources()
Invokes the sources elements.

processMessages

protected void processMessages()
Processes incoming messages.

killOperators

public void killOperators()
Kills all operators. This sends a HANGUP to all operators and waits for kill confirmation.

checkForState

protected boolean checkForState(ElementState state)
Checks for a specific state of the all elements.
Parameters:
state - state to check for
Returns:
true if all operators are in the given state

checkSourcesForState

protected boolean checkSourcesForState(ElementState state)
Checks for a specific state of the all source elements.
Parameters:
state - state to check for
Returns:
true if all source elements are in the given state

checkSinksForState

protected boolean checkSinksForState(ElementState state)
Checks for a specific state of the all sink elements.
Parameters:
state - state to check for
Returns:
true if all sink elements are in the given state

checkElementsForState

protected boolean checkElementsForState(ElementState state)
Checks for a specific state of the all elements.
Parameters:
state - state to check for
Returns:
true if all operators are in the given state

checkForSetupCompletion

protected boolean checkForSetupCompletion()
Checks if all operators have completed their setup.
Returns:
true if setup was completed

checkForSinkOverflow

protected boolean checkForSinkOverflow()
Checks if all sinks have reached the OVERFLOW state.
Returns:
true if all sink are in state OVERFLOW

checkForKillCompletion

protected boolean checkForKillCompletion()
Checks if all operators have reached the state DEAD.
Returns:
true if all operators are in state DEAD

run

public void run()
Runs this broker.
Specified by:
run in interface java.lang.Runnable

printStateMap

protected void printStateMap()
Prints the state map for debugging.

toString

public java.lang.String toString()
Returns a string representation.
Overrides:
toString in class java.lang.Object
Returns:
string representation

eaLib API Docs
Last Modified : January 7 2002

Copyright © 2000-2001 Technical University of Ilmenau, Department ESS