galaxy.server
Class DataInBroker

java.lang.Object
  |
  +--galaxy.server.DataInBroker
All Implemented Interfaces:
java.lang.Runnable

public abstract class DataInBroker
extends java.lang.Object
implements java.lang.Runnable

This class represents the consumer of a brokering connection. Subclasses of this class try to establish a connection to specified outgoing broker (i.e., the data supplier), receive the brokered data, and process the data.


Field Summary
protected  Environment env
          The call environment of the server dispatch function that created this broker.
protected  FrameDispatcher frameDispatcher
          Frame dispatcher of the Server that started this broker
protected  Server server
          The Server that created this broker.
 
Constructor Summary
DataInBroker(Server server, java.net.InetAddress ip, int port, GFrame frame)
          Constructor.
DataInBroker(Server server, java.lang.String hostName, int port, GFrame frame)
          Constructor.
 
Method Summary
protected  void abortReceived()
          This method is called when this broker catches and unexpected exception while receiving brokered data.
protected  void cleanup()
          This cleanup method is called when this broker is preparing to stop.
protected  void disconnectReceived()
          This method is called when this broker receives a disconnect message from the outgoing broker (indicates all data has been received).
 Server getServer()
          Returns the reference to the Server that created this broker.
 boolean isStopped()
          Indicates if this broker is stopped.
abstract  void receivedBinary(GBinary bin)
          Executed when a GBinary is read by this incoming broker.
abstract  void receivedFloat(java.lang.Float floatObject)
          Executed when a Float is read by this incoming broker.
abstract  void receivedFloat32(Float32 float32)
          Executed when a Float32 is read by this incoming broker.
abstract  void receivedFloat64(Float64 float64)
          Executed when a Float64 is read by this incoming broker.
abstract  void receivedFrame(GFrame frame)
          Executed when a GFrame is read by this incoming broker.
abstract  void receivedInt16(Int16 int16)
          Executed when an Int16 is read by this incoming broker.
abstract  void receivedInt32(Int32 int32)
          Executed when an Int32 is read by this incoming broker.
abstract  void receivedInt64(Int64 int64)
          Executed when an Int64 is read by this incoming broker.
abstract  void receivedInteger(java.lang.Integer integerObject)
          Executed when an Integer is read by this incoming broker.
abstract  void receivedList(GVector list)
          Executed when a GVector is read by this incoming broker.
abstract  void receivedString(java.lang.String str)
          Executed when a String is read by this incoming broker.
abstract  void receivedSymbol(Symbol symbol)
          Executed when a Symbol is read by this incoming broker.
 void registerWithServer()
          Registers this broker with the Server that started it.
 void run()
          The thread routine for this broker.
 void start()
          Performs the broker client side of the handshake and starts the broker thread, assuming the handshake succeeded.
 void stop()
          Marks this broker's thread as being stopped.
 void unregisterFromServer()
          Unregisters this broker from the Server that started it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

protected Server server
The Server that created this broker.

env

protected Environment env
The call environment of the server dispatch function that created this broker.

frameDispatcher

protected FrameDispatcher frameDispatcher
Frame dispatcher of the Server that started this broker
Constructor Detail

DataInBroker

public DataInBroker(Server server,
                    java.net.InetAddress ip,
                    int port,
                    GFrame frame)
             throws java.lang.Exception
Constructor.
Parameters:
server - the Server that created this broker
ip - the IP address of the server that manages access to the outgoing broker to which this broker wishes to connect
port - the "listener" port of the target server
frame - a GFrame that contains the call id of the outgoing broker to which this broker wishes to connect

DataInBroker

public DataInBroker(Server server,
                    java.lang.String hostName,
                    int port,
                    GFrame frame)
             throws java.lang.Exception
Constructor.
Parameters:
server - the Server that created this broker
hostName - the host name of the server that manages access to the outgoing broker to which this broker wishes to connect
port - the "listener" port of the target server
frame - a GFrame that contains the call id of the outgoing broker to which this broker wishes to connect
Method Detail

getServer

public Server getServer()
Returns the reference to the Server that created this broker.
Returns:
the server reference

isStopped

public boolean isStopped()
Indicates if this broker is stopped.
Returns:
true if stopped, false otherwise

start

public void start()
Performs the broker client side of the handshake and starts the broker thread, assuming the handshake succeeded.

run

public void run()
The thread routine for this broker. While this broker's socket connection is open, data is read off the connection and processed. by the various received methods defined by subclasses of this class.
Specified by:
run in interface java.lang.Runnable

stop

public void stop()
Marks this broker's thread as being stopped.

cleanup

protected void cleanup()
This cleanup method is called when this broker is preparing to stop. This is called before the socket connection is closed. Override this method to provide your own customized cleanup routine. The generic DataInBroker cleanup will still take place.

disconnectReceived

protected void disconnectReceived()
This method is called when this broker receives a disconnect message from the outgoing broker (indicates all data has been received). Override this method to provide your own customized finalization routine. This broker is stopped after this method is called.

abortReceived

protected void abortReceived()
This method is called when this broker catches and unexpected exception while receiving brokered data. Override this method to provide your own customized error handling routine. This broker is stopped after this method is called.

registerWithServer

public void registerWithServer()
Registers this broker with the Server that started it. At the moment, this will cause this broker to be stopped if the server loses its connection to the Hub.

unregisterFromServer

public void unregisterFromServer()
Unregisters this broker from the Server that started it.

receivedString

public abstract void receivedString(java.lang.String str)
Executed when a String is read by this incoming broker.
Parameters:
str - the string received

receivedBinary

public abstract void receivedBinary(GBinary bin)
Executed when a GBinary is read by this incoming broker.
Parameters:
bin - the binary object received

receivedFrame

public abstract void receivedFrame(GFrame frame)
Executed when a GFrame is read by this incoming broker.
Parameters:
frame - the frame received

receivedList

public abstract void receivedList(GVector list)
Executed when a GVector is read by this incoming broker.
Parameters:
list - the list received

receivedInt16

public abstract void receivedInt16(Int16 int16)
Executed when an Int16 is read by this incoming broker.
Parameters:
int16 - the 16-bit integer array received

receivedInt32

public abstract void receivedInt32(Int32 int32)
Executed when an Int32 is read by this incoming broker.
Parameters:
int32 - the 32-bit integer array received

receivedInt64

public abstract void receivedInt64(Int64 int64)
Executed when an Int64 is read by this incoming broker.
Parameters:
int64 - the 64-bit integer array received

receivedFloat32

public abstract void receivedFloat32(Float32 float32)
Executed when a Float32 is read by this incoming broker.
Parameters:
float32 - the 32-bit floating point number array received

receivedFloat64

public abstract void receivedFloat64(Float64 float64)
Executed when a Float64 is read by this incoming broker.
Parameters:
float64 - the 64-bit floating point number array received

receivedInteger

public abstract void receivedInteger(java.lang.Integer integerObject)
Executed when an Integer is read by this incoming broker.
Parameters:
integerObject - the integer received

receivedFloat

public abstract void receivedFloat(java.lang.Float floatObject)
Executed when a Float is read by this incoming broker.
Parameters:
floatObject - the float received

receivedSymbol

public abstract void receivedSymbol(Symbol symbol)
Executed when a Symbol is read by this incoming broker.
Parameters:
symbol - the symbol received