cgl.narada.protocol
Class ProtocolHandler
java.lang.Object
java.lang.Thread
cgl.narada.protocol.ProtocolHandler
- All Implemented Interfaces:
- Handler, ProtocolDebugFlags, Runnable
public class ProtocolHandler
- extends Thread
- implements ProtocolDebugFlags, Handler
The ProtocolHandler provides the interface between the transport layer and
the protocol layer. It is also designed in a way to provide an interface
between the protocol layer and the application layer. This allows us to
decouple the transport aspects from the protocol layer. The protocol layer
thus deals only with the logical addresses associated with nodes, instead of
the various transport indentifiers (TCP,UDP Multicast
) associated with any given node.
| 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 |
|
Method Summary |
void |
closeCommunicationsTo(Object nodeId)
Ensures communication links to the specified node are all terminated |
void |
closeCommunicationsTo(String nodeId)
|
void |
closeLink(String linkId)
|
void |
connectionToBrokerLost(Object brokerConnectionId,
String _linkId)
|
void |
connectionToClientLost(Object clientIdentifier,
String linkId)
|
byte[] |
constructGatewaySetupRequest(String node,
int gatewayLevel)
|
byte[] |
constructNodeAdditionRequest(int[] levels,
boolean from)
This method is response for issuing a node addition request. |
void |
disableMonitoring()
|
boolean |
doSecurityChecks(NBEvent event)
Handler into the secure topics manager's function to validate the contents
of an NBEvent |
void |
enableMonitoring()
|
String[] |
enumerateLinks()
|
void |
garbageCollectLink(String node)
Responible for garbage collecting a certain link. |
void |
generateReport(String report)
Not been implemented so far, but will be soon and would aid as a
information gathering tool. |
NodeAddress |
getAssignedAddress()
Accessor function for retrieving the node address of the server node
hosting the connectivity graph. |
Destinations |
getNodeDestination()
Retreives the destination that has been assigned to this node. |
SignedSecurityToken |
getSecurityTokenForProfileId(Object key)
|
Hashtable |
getSupportedTransportProtocols()
|
ProtocolID |
getUniqueProtocolID()
This method provides us with access to the ProtocolIDFactory which
provides us with a list of unique protocol ID's |
void |
handleData(byte[] data,
String sender)
|
void |
initDiscoveryRequestForwardingService()
Initializes the Discovery Request forwarding service |
void |
initDiscoveryRequestTable(int size)
Initializes the Discovery Request Table with the specified size |
void |
initializeProtocolSuite()
This method is responsible for initializing the protocol suite. |
void |
initSecureTopicsManager(String keyStoreFileLocation)
|
boolean |
isClient()
This method indicates that the node in question is a broker |
boolean |
isNodeAddressAssigned()
shows whether node address is assigned |
void |
loadCommunicationsOfType(Properties props,
String commType)
|
void |
mapLinkToBrokerNode(String node,
Gateway _newAddress,
ProtocolID brokerConnectionId)
This method is used, when an unassigned node has been assigned logical
address by the system |
void |
mapLinkToClientNode(String node,
Gateway _newAddress,
Object clientIdentifier)
This method is used, when an unassigned client node has been assigned
logical address by the system |
void |
processBrokerDiscoveryRequest(byte[] discoBytes,
boolean mustBeForwarded)
Constructs and send a Broker Discovery Response Message |
void |
processData(byte[] data,
String sender)
This is the method which routes different protocol packets to the
appropriate protocols in the protocol suite. |
void |
propagateConnectionInformation(Connection createdConnection,
Gateway hop)
This is invoked by the node which is responsible for issuing the Node
setup response. |
void |
propagateProfilesAtSpecifiedLevel(Gateway hop,
int level)
Propagates profiles to a newly added node. |
void |
registerProfileSecurityToken(Object key,
byte[] token)
|
void |
routeMessageToClient(String reciever,
int clientId,
byte[] data)
|
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 |
setAsGatewayAtLevel(int level)
This designates this node as a gateway at level level. |
void |
setAssignedAddress(NodeAddress nodeAddress)
After a node address has been assigned, this method is responsible for
setting the node address for the connectivity graph. |
void |
setBrokerDiscoveryRequestResponsePolicyHandler(String handler)
Initializes the Broker Discovery Request response policy handler
If the specified class cannot be instantiated, the broker defaults to the
default policy (i.e. |
void |
setBrokerSystemEventListener(BrokerSystemEventListener brokerSystemEventListener)
|
void |
setServiceConfigurationLocation(String configFileLocation)
|
String |
setupLink(Properties props,
String linkType)
|
void |
shutdown()
|
void |
startMonitoringService()
|
boolean |
sysnopsisRepresentsSecureTopic(Object synopsis,
int type)
|
void |
unsetAsGatewayAtLevel(int level)
This designates this node as a gateway at level level. |
void |
unsetForwardingService()
|
boolean |
verifySignedSecurityToken(SignedSecurityToken sst)
|
| 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 |
startForwardingService
public boolean startForwardingService
ProtocolHandler
public ProtocolHandler()
ProtocolHandler
public ProtocolHandler(NodeAddress nodeAddress,
short[] connectionVector,
int concurrentConnectionLimit,
String ipDiscriminator,
GatewayInfo gatewayInfo)
- The protocol handler constructor.
- Parameters:
nodeAddress - The node address of the system.connectionVector - The number of active connections that are allowed at a time, at
each levelconcurrentConnectionLimit - The limit on the number of active concurrent connections
initiated by clients.ipDiscriminator - The discriminator used to determine if a node can be part of a
clustergatewayInfo - The connectivity graph of the hosting node.
setAssignedAddress
public void setAssignedAddress(NodeAddress nodeAddress)
- After a node address has been assigned, this method is responsible for
setting the node address for the connectivity graph.
- Parameters:
nodeAddress - The node address of the server node hosting the connectivity
graph
isNodeAddressAssigned
public boolean isNodeAddressAssigned()
- shows whether node address is assigned
getAssignedAddress
public NodeAddress getAssignedAddress()
- Accessor function for retrieving the node address of the server node
hosting the connectivity graph.
- Returns:
- The node address of the server node.
getNodeDestination
public Destinations getNodeDestination()
- Retreives the destination that has been assigned to this node. This is
simply a wrapper around the node address of the server node. This is very
useful in computing the destinations that have traversed by a message
packet.
- Returns:
- The destinations correspinding to the server node.
getUniqueProtocolID
public ProtocolID getUniqueProtocolID()
- This method provides us with access to the ProtocolIDFactory which
provides us with a list of unique protocol ID's
- Returns:
- The unique ID associated with a request/response. This is a unique
ID system wide.
setAsGatewayAtLevel
public void setAsGatewayAtLevel(int level)
- This designates this node as a gateway at level level.
unsetForwardingService
public void unsetForwardingService()
unsetAsGatewayAtLevel
public void unsetAsGatewayAtLevel(int level)
- This designates this node as a gateway at level level.
isClient
public boolean isClient()
- This method indicates that the node in question is a broker
- Specified by:
isClient in interface Handler
processData
public void processData(byte[] data,
String sender)
- This is the method which routes different protocol packets to the
appropriate protocols in the protocol suite. It does so by investigating
the headers in the packets that have been received by any of the receiver
threads. The different kind of protocol headers that this method can deal
with are contained in cgl.narada.protocol.Protocol.
- Parameters:
_dataReceived - The data that has been received.
garbageCollectLink
public void garbageCollectLink(String node)
- Responible for garbage collecting a certain link. This would involve
grabage collecting the resources associated with the link e.g. sockets,
queues and the sender/receiver threads associated with that socket.
- Parameters:
node - The string using which this node can communicate with a node
that hasn't been assigned a logical address so far
closeCommunicationsTo
public void closeCommunicationsTo(String nodeId)
closeCommunicationsTo
public void closeCommunicationsTo(Object nodeId)
- Ensures communication links to the specified node are all terminated
propagateConnectionInformation
public void propagateConnectionInformation(Connection createdConnection,
Gateway hop)
- This is invoked by the node which is responsible for issuing the Node
setup response. This method performs the following functions
- First it sends the serialized connection buffer over to the newly
added node/unit.
- Secondly, it adds the newly established connection to the
connectivity graph.
- Initiate a dissemination of the connection information through valid
sub systems of the system.
- Parameters:
createdConnection - The newly established connectionhop - The gateway over which this information needs to be sent over
initializeProtocolSuite
public void initializeProtocolSuite()
- This method is responsible for initializing the protocol suite.
loadCommunicationsOfType
public void loadCommunicationsOfType(Properties props,
String commType)
throws TransportException
- Throws:
TransportException
setupLink
public String setupLink(Properties props,
String linkType)
throws TransportException
- Throws:
TransportException
closeLink
public void closeLink(String linkId)
enumerateLinks
public String[] enumerateLinks()
shutdown
public void shutdown()
doSecurityChecks
public boolean doSecurityChecks(NBEvent event)
- Handler into the secure topics manager's function to validate the contents
of an NBEvent
- Parameters:
event - -
The event to verify
- Returns:
- TRUE if verified, FALSE otherwise
sysnopsisRepresentsSecureTopic
public boolean sysnopsisRepresentsSecureTopic(Object synopsis,
int type)
registerProfileSecurityToken
public void registerProfileSecurityToken(Object key,
byte[] token)
getSecurityTokenForProfileId
public SignedSecurityToken getSecurityTokenForProfileId(Object key)
verifySignedSecurityToken
public boolean verifySignedSecurityToken(SignedSecurityToken sst)
routeMessageToClient
public void routeMessageToClient(String reciever,
int clientId,
byte[] data)
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
mapLinkToBrokerNode
public void mapLinkToBrokerNode(String node,
Gateway _newAddress,
ProtocolID brokerConnectionId)
- This method is used, when an unassigned node has been assigned logical
address by the system
- Parameters:
node - The string identifier for the server node w/o the logical
address_newAddress - The newly assigned address for the node. Henceforth all
communication with the node would be carried out using its
logical address within the system
mapLinkToClientNode
public void mapLinkToClientNode(String node,
Gateway _newAddress,
Object clientIdentifier)
- This method is used, when an unassigned client node has been assigned
logical address by the system
- Parameters:
node - The string identifier for the client node w/o the logical
address_newAddress - The newly assigned address for the node. Henceforth all
communication with the node would be carried out using its
logical address within the system.clientIdentifier - The newly assigned identifier for the client
connectionToClientLost
public void connectionToClientLost(Object clientIdentifier,
String linkId)
connectionToBrokerLost
public void connectionToBrokerLost(Object brokerConnectionId,
String _linkId)
handleData
public void handleData(byte[] data,
String sender)
- Specified by:
handleData in interface Handler
run
public void run()
- Specified by:
run in interface Runnable- Overrides:
run in class Thread
generateReport
public void generateReport(String report)
- Not been implemented so far, but will be soon and would aid as a
information gathering tool. The information generated would be used for
further optimizations.
- Parameters:
report - The report being issued by various protocols. All the protocols
have a reference to the protocolHandler.
constructNodeAdditionRequest
public byte[] constructNodeAdditionRequest(int[] levels,
boolean from)
- This method is response for issuing a node addition request.
propagateProfilesAtSpecifiedLevel
public void propagateProfilesAtSpecifiedLevel(Gateway hop,
int level)
- Propagates profiles to a newly added node.
- Parameters:
hop - level -
constructGatewaySetupRequest
public byte[] constructGatewaySetupRequest(String node,
int gatewayLevel)
startMonitoringService
public void startMonitoringService()
throws TransportException
- Throws:
TransportException
enableMonitoring
public void enableMonitoring()
disableMonitoring
public void disableMonitoring()
setServiceConfigurationLocation
public void setServiceConfigurationLocation(String configFileLocation)
setBrokerSystemEventListener
public final void setBrokerSystemEventListener(BrokerSystemEventListener brokerSystemEventListener)
- Parameters:
brokerSystemEventListener - The brokerSystemEventListener to set.
initSecureTopicsManager
public void initSecureTopicsManager(String keyStoreFileLocation)
initDiscoveryRequestForwardingService
public void initDiscoveryRequestForwardingService()
- Initializes the Discovery Request forwarding service
initDiscoveryRequestTable
public void initDiscoveryRequestTable(int size)
- Initializes the Discovery Request Table with the specified size
- Parameters:
size - -
MAXIMUM number of entries permitted
setBrokerDiscoveryRequestResponsePolicyHandler
public void setBrokerDiscoveryRequestResponsePolicyHandler(String handler)
- Initializes the Broker Discovery Request response policy handler
If the specified class cannot be instantiated, the broker defaults to the
default policy (i.e. Respond to all requests)
- Parameters:
handler - -
String specifiying the class to load.
getSupportedTransportProtocols
public Hashtable getSupportedTransportProtocols()
processBrokerDiscoveryRequest
public void processBrokerDiscoveryRequest(byte[] discoBytes,
boolean mustBeForwarded)
- Constructs and send a Broker Discovery Response Message
- Parameters:
discoRequest - -
The bytes that make the BrokerDiscoveryRequestmustBeForwarded - -
If true, then use the BrokerDiscoveryRequest Forwarding service
to forward the discovery request to other possible brokers in
the network. If FALSE then we do not forward the request.
For comments and suggestions please send
e-mail to
The NaradaBrokering Project