cgl.narada.protocol
Class ClientProtocolHandler

java.lang.Object
  extended by java.lang.Thread
      extended by cgl.narada.protocol.ClientProtocolHandler
All Implemented Interfaces:
Handler, ProtocolDebugFlags, Runnable

public class ClientProtocolHandler
extends Thread
implements ProtocolDebugFlags, Handler

This class serves to provide the client with an intermediary between the application layers and the transport layers. The purpose of this class is also to provide for


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface cgl.narada.protocol.ProtocolDebugFlags
BrokerLocatorCommunicator_Debug, ClientConnectionHandler_Debug, Connection_Debug, ConnectionPropagation_Debug, Destinations_Debug, DuplicateDetection_Debug, EventBuffer_Debug, EventRoutingProtocol_Debug, Gateway_Debug, GatewayInfo_Debug, GatewayPropagation_Debug, JmsProfilePropagation_Debug, LinkCostMatrix_Debug, NodeAdditionProtocol_Debug, NodeAddress_Debug, Path_Debug, PersistentEventRouting_Debug, ProfilePropagationProtocol_Debug, ProtocolException_Debug, ProtocolHandler_Debug, ProtocolID_Debug, ProtocolIDFactory_Debug, RoutingCache_Debug, RtpEventRoutingProtocol_Debug, RtpProfilePropagation_Debug, SecureMessageRouting_Debug, TagValueEventRoutingProtocol_Debug, TagValueProfilePropagation_Debug, XmlEventRoutingProtocol_Debug, XPathProfilePropagation_Debug
 
Constructor Summary
ClientProtocolHandler()
          Constructor for the Client Protocol Handler.
 
Method Summary
 void eventPropagationRequest(String server, String event, int minSize)
          This method is responsible for publishing an event to the system.
 short[] getLatencyArray()
           
 void handleData(byte[] data, String sender)
          This method is responsible for dealing with packets of messages that are received over a link, based on the protocol headers that are contained within the packets.
 void initializeLatencyArray(int size)
           
 boolean isClient()
          This method indicates that the node in question is a client
 void loadCommunicationsOfType(Properties props, String commType)
           
static void main(String[] args)
           
 void nodeAddressRequest(String server)
          This method is reponsible for issuing a node address request to the server in question.
 void persistentEventPropagationRequest(String server, String event, int minSize)
          This method is responsible for publishing a persistent event to the system.
 void printTestCaseDetails()
           
 void processEventReceived(String sender, byte[] receivedEventBytes)
          This method processes the packet that is received with the Protocol.EVENT header.
 void processNodeAddressResponse(String sender, byte[] addressResponse)
          Process the response that you have received from the server pertaining to the address request that was issued.
 void processPersistentEventReceived(String sender, byte[] receivedEventBytes)
          This method processes the packet that is received with the Protocol.EVENT header.
 void profilePropagationRequest(String server, String subscription)
          Propagates the interest in a subscription to the server in question.
 void run()
           
 void sendTo(String node, byte[] data)
          For communicating with a server node which hasn't been assigned a logical address so far
 void sendToNode(Gateway nodeAddress, byte[] data)
          This method send information over a specified hop.
 void setClientNode(ClientNode clientNode)
           
 void setLoopThroughMessageSizes(String reportFileName)
           
 void setPublishRate(int _pubRate)
           
 String setupLink(Properties props, String linkType)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClientProtocolHandler

public ClientProtocolHandler()
Constructor for the Client Protocol Handler. This initializes the transport handler interfaces and the message queues needed for communication.

Method Detail

setClientNode

public void setClientNode(ClientNode clientNode)

isClient

public boolean isClient()
This method indicates that the node in question is a client

Specified by:
isClient in interface Handler

handleData

public void handleData(byte[] data,
                       String sender)
This method is responsible for dealing with packets of messages that are received over a link, based on the protocol headers that are contained within the packets. The DataReceived object is the encapsulation of the data that is received by one of the ReceiverThreads within the transport layer. This handler is specifc to dealing with clients

Specified by:
handleData in interface Handler
Parameters:
_dataReceived - The data that is received by one of the ReceiverThreads

initializeLatencyArray

public void initializeLatencyArray(int size)

setLoopThroughMessageSizes

public void setLoopThroughMessageSizes(String reportFileName)

getLatencyArray

public short[] getLatencyArray()

setPublishRate

public void setPublishRate(int _pubRate)

printTestCaseDetails

public void printTestCaseDetails()

processEventReceived

public void processEventReceived(String sender,
                                 byte[] receivedEventBytes)
This method processes the packet that is received with the Protocol.EVENT header. This method is reponsible for unmarshalling the event stream and creating the event associated with the stream.

Parameters:
sender - The server from which we received this event.
receivedEventBytes - The byte stream representation of the event, including the protocol headers and other information

processPersistentEventReceived

public void processPersistentEventReceived(String sender,
                                           byte[] receivedEventBytes)
This method processes the packet that is received with the Protocol.EVENT header. This method is reponsible for unmarshalling the event stream and creating the event associated with the stream.

Parameters:
sender - The server from which we received this event.
receivedEventBytes - The byte stream representation of the event, including the protocol headers and other information

processNodeAddressResponse

public void processNodeAddressResponse(String sender,
                                       byte[] addressResponse)
Process the response that you have received from the server pertaining to the address request that was issued. The responses could be one of the following.

Parameters:
sender - - The server from which this response was received.
addressResponse - - The byte stream representation of the address response

nodeAddressRequest

public void nodeAddressRequest(String server)
This method is reponsible for issuing a node address request to the server in question.

Parameters:
server - The server to which this request is being issued.

profilePropagationRequest

public void profilePropagationRequest(String server,
                                      String subscription)
Propagates the interest in a subscription to the server in question. This method cannot be issued unitil the client has been assigned a logical address by the system.

Parameters:
server - The server to which this client is attached.
subscription - The subscription predicate for the client

eventPropagationRequest

public void eventPropagationRequest(String server,
                                    String event,
                                    int minSize)
This method is responsible for publishing an event to the system.

Parameters:
server - The server to which this request is being issued.
event - The event that is being published
minSize - Minimum Size of the event being published.

persistentEventPropagationRequest

public void persistentEventPropagationRequest(String server,
                                              String event,
                                              int minSize)
This method is responsible for publishing a persistent event to the system.

Parameters:
server - The server to which this request is being issued.
event - The event that is being published
minSize - Minimum Size of the event being published.

loadCommunicationsOfType

public void loadCommunicationsOfType(Properties props,
                                     String commType)
                              throws TransportException
Throws:
TransportException

setupLink

public String setupLink(Properties props,
                        String linkType)
                 throws TransportException
Throws:
TransportException

sendTo

public void sendTo(String node,
                   byte[] data)
For communicating with a server node which hasn't been assigned a logical address so far

Parameters:
node - The string identifier for the server node.
data - The byte stream containing the information.

sendToNode

public void sendToNode(Gateway nodeAddress,
                       byte[] data)
This method send information over a specified hop. The information maintained in the connectivity graph is just the level, and the node address at that level


run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

main

public static void main(String[] args)


For comments and suggestions please send e-mail to The NaradaBrokering Project