ch.epfl.lsr.apex
Class APEXRelayManager

java.lang.Object
  extended bych.epfl.lsr.apex.APEXManager
      extended bych.epfl.lsr.apex.APEXRelayManager

public class APEXRelayManager
extends APEXManager

The APEXRelayManager is called from a instanciated from a relay process (implementing APEXRelayProcess). As soon as the constructor is called, a listener on the specified port is created.

Author:
Marc Stoecklin

Field Summary
 
Fields inherited from class ch.epfl.lsr.apex.APEXManager
application, lockedIdentifiers, messageTable, port, PROCESSTYPE_ENDPOINT, PROCESSTYPE_RELAY, SERVICEPRIORITIES, services, SERVICETABLE, transactionTable
 
Constructor Summary
APEXRelayManager(APEXRelayProcess application, String relayConfigurationFile, String serviceConfigurationFile)
          Creates an APEXRelayManager object using the well-known TCP port number 912 assigned by the IANA.
 
Method Summary
 int attachEndpoint(APEXAttachMessage aam, Object receivingChannelID)
          is called when an attach element is received a status code (for the reply is returned)
 int bindRelay(APEXBindMessage abm, Object receivingChannelID)
          is called when an bind element is received a status code (for the reply is returned)
 String getMainAdministrativeDomain()
          Returns the main administrative domain of this relay
 void handleIncomingMessage(APEXMessage message, Object receivingChannelID)
          When a message has been received on a connection it calls its manager's ' handleIncomingMessage' method.
 void messageDiscarded(APEXDataMessage message, int code, String reason)
          This mesthod is called when a connection wasn't able to send an 'APEXMessage', say a (where x !
 void messageSent(APEXDataMessage message, APEXReply reply)
          This mesthod is called when an 'APEXDataMessage' is successfully sent on a connection, say an element has been received.
 int sendAPEXDataMessage(APEXDataMessage message)
           Sends an APEXDataMessage to the recipients specified within the object.
 int terminate(APEXTerminateMessage atm, Object receivingChannelID)
          Is called when an terminate element is received a status code (for the reply is returned).
 
Methods inherited from class ch.epfl.lsr.apex.APEXManager
addTransaction, debug, getApplication, getFromTable, getFromTableAndLock, getTransaction, notification, parsePort, putToTable, putToTableAndUnlock, removeAllTransactions, removeFromTable, removeTransaction, sortOptions, unlockTable, validatePort
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

APEXRelayManager

public APEXRelayManager(APEXRelayProcess application,
                        String relayConfigurationFile,
                        String serviceConfigurationFile)
                 throws APEXException
Creates an APEXRelayManager object using the well-known TCP port number 912 assigned by the IANA.

Parameters:
application - An APEXRelayProcess used for call-backs.
serviceConfigurationFile - File name of a service configuration file (null or empty if no configuration file should be processed)
relayConfigurationFile - File name of a relay configuration file
Throws:
APEXException - If the relay configuration file cannot be found or a parsing error appears
Method Detail

attachEndpoint

public int attachEndpoint(APEXAttachMessage aam,
                          Object receivingChannelID)
is called when an attach element is received a status code (for the reply is returned)

Parameters:
aam - The received attach message
receivingChannelID - Associated channel identifier

bindRelay

public int bindRelay(APEXBindMessage abm,
                     Object receivingChannelID)
is called when an bind element is received a status code (for the reply is returned)

Parameters:
abm - The received bind message
receivingChannelID - The associated channel identifier

terminate

public int terminate(APEXTerminateMessage atm,
                     Object receivingChannelID)
Is called when an terminate element is received a status code (for the reply is returned). This method terminates the transaction if it exists

Specified by:
terminate in class APEXManager
Parameters:
atm - Associated APEXTerminateMessage for operation to terminate.
receivingChannelID - A channel identifier for the channel which received the operation
Returns:
a three-digit code for the operation

sendAPEXDataMessage

public int sendAPEXDataMessage(APEXDataMessage message)

Sends an APEXDataMessage to the recipients specified within the object. This method regroups the recipients by administrative domains in order to optimize the performance.

In a second step it translates the address of the next hop according the routing points by means of the translateToRoutingPoint method.

Specified by:
sendAPEXDataMessage in class APEXManager
Parameters:
message - Data message to be sent. If no recipients are specified, no action is taken.
Returns:
A three-digit status reply code for the message.

handleIncomingMessage

public void handleIncomingMessage(APEXMessage message,
                                  Object receivingChannelID)
                           throws APEXException
When a message has been received on a connection it calls its manager's ' handleIncomingMessage' method.
This method decides according the message type how to proceed, say if it is an

messageDiscarded

public void messageDiscarded(APEXDataMessage message,
                             int code,
                             String reason)
This mesthod is called when a connection wasn't able to send an 'APEXMessage', say a (where x != 250) is received or the next hop is not responding. All applicable services are called by there method 'handleDiscarded'.

Specified by:
messageDiscarded in class APEXManager
Parameters:
message - The message which wasn't sent
code - The error code of this message
reason - A textual reason

messageSent

public void messageSent(APEXDataMessage message,
                        APEXReply reply)
This mesthod is called when an 'APEXDataMessage' is successfully sent on a connection, say an element has been received. All applicable services are called by there method 'handleSent'

Specified by:
messageSent in class APEXManager
Parameters:
message - The message which has successfully been sent
reply - The reply object received of the next hop

getMainAdministrativeDomain

public String getMainAdministrativeDomain()
Returns the main administrative domain of this relay

Returns:
The main administrative domain