|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectdk.i1.diameter.node.Node
public class Node
A Diameter node. The Node class manages diameter transport connections and peers. It handles the low-level messages itself (CER/CEA/DPR/DPA/DWR/DWA). The rest is sent to the MessageDispatcher. When connections are established or closed the ConnectionListener is notified. Message can be sent and received through the node but no state is maintained per message.
Node is quite low-level. You probably want to use NodeManager
instead.
Node instances logs with the name "dk.i1.diameter.node", so you can get detailed logging (including hex-dumps of incoming and outgoing packets) by putting "dk.i1.diameter.node.level = ALL" into your log.properties file (or equivalent)
The Node instance uses two properties when deciding which transport-protocols to support:
NodeSettings.setUseTCP(java.lang.Boolean)
and NodeSettings.setUseSCTP(java.lang.Boolean)
.
dk.i1.diameter.node.jitter_prng=your favorite PRNG
The default value is SHA1PRNG. If set to bogus then the stack simply uses Random() instead. Doing so technically violates RFC3588->RFC3539->RFC1750
NodeManager
Constructor Summary | |
---|---|
Node(MessageDispatcher message_dispatcher,
ConnectionListener connection_listener,
NodeSettings settings)
Constructor for Node. |
|
Node(MessageDispatcher message_dispatcher,
ConnectionListener connection_listener,
NodeSettings settings,
NodeValidator node_validator)
Constructor for Node. |
Method Summary | |
---|---|
void |
addOurHostAndRealm(Message msg)
Add origin-host and origin-realm to a message. |
java.net.InetAddress |
connectionKey2InetAddress(ConnectionKey connkey)
Returns the IP-address of the remote end of a connection. |
Peer |
connectionKey2Peer(ConnectionKey connkey)
Returns the Peer on a connection. |
ConnectionKey |
findConnection(Peer peer)
Returns the connection key for a peer. |
void |
initiateConnection(Peer peer,
boolean persistent)
Initiate a connection to a peer. |
boolean |
isAllowedApplication(Message msg,
Peer peer)
Determine if a message is supported by a peer. |
boolean |
isConnectionKeyValid(ConnectionKey connkey)
Returns if the connection is still valid. |
String |
makeNewSessionId()
Generate a new session-id. |
String |
makeNewSessionId(String optional_part)
Generate a new session-id. |
int |
nextEndToEndIdentifier()
Returns an end-to-end identifier that is unique. |
int |
nextHopByHopIdentifier(ConnectionKey connkey)
Returns the next hop-by-hop identifier for a connection |
void |
sendMessage(Message msg,
ConnectionKey connkey)
Send a message. |
void |
start()
Start the node. |
int |
stateId()
Returns the node's state-id. |
void |
stop()
Stop the node. |
void |
stop(long grace_time)
Stop the node. |
void |
waitForConnection()
Wait until at least one connection has been established to a peer and capability-exchange has finished. |
void |
waitForConnection(long timeout)
Wait until at least one connection has been established or until the timeout expires. |
void |
waitForConnectionTimeout(long timeout)
Wait until at least one connection has been established or until the timeout expires. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Node(MessageDispatcher message_dispatcher, ConnectionListener connection_listener, NodeSettings settings)
message_dispatcher
- A message dispatcher. If null, a default dispatcher is used you. You probably dont want that one.connection_listener
- A connection observer. Can be null.settings
- The node settings.public Node(MessageDispatcher message_dispatcher, ConnectionListener connection_listener, NodeSettings settings, NodeValidator node_validator)
message_dispatcher
- A message dispatcher. If null, a default dispatcher is used you. You probably dont want that one.connection_listener
- A connection observer. Can be null.settings
- The node settings.node_validator
- a custom NodeValidator. If null then a DefaultNodeValidator
is used.Method Detail |
---|
public void start() throws java.io.IOException, UnsupportedTransportProtocolException
java.io.IOException
- Usually when a priviledge port is specified, system out of resoruces, etc.
UnsupportedTransportProtocolException
- If a transport-protocol has been specified as mandatory but could not be initialised.public void stop()
public void stop(long grace_time)
waitForConnection()
are woken.
Graceful connection close is not guaranteed in all cases.
grace_time
- Maximum time (milliseconds) to wait for connections to close gracefully.public void waitForConnection() throws InterruptedException
InterruptedException
public void waitForConnection(long timeout) throws InterruptedException
timeout
- The maximum time to wait in milliseconds.
InterruptedException
public void waitForConnectionTimeout(long timeout) throws InterruptedException, ConnectionTimeoutException
timeout
- The maximum time to wait in milliseconds.
ConnectionTimeoutException
- If the timeout expires without any connection established.
InterruptedException
public ConnectionKey findConnection(Peer peer)
public boolean isConnectionKeyValid(ConnectionKey connkey)
public Peer connectionKey2Peer(ConnectionKey connkey)
public java.net.InetAddress connectionKey2InetAddress(ConnectionKey connkey)
public int nextHopByHopIdentifier(ConnectionKey connkey) throws StaleConnectionException
StaleConnectionException
public void sendMessage(Message msg, ConnectionKey connkey) throws StaleConnectionException
msg
- The message to be sentconnkey
- The connection to use. If the connection has been closed in the meantime StaleConnectionException is thrown.
StaleConnectionException
public void initiateConnection(Peer peer, boolean persistent)
persistent
true then the peer is added to a list of
persistent peers and if the connection is lost it will automatically
be re-established. There is no way to change a peer from persistent
to non-persistent.
If/when the connection has been established and capability-exchange
has finished threads waiting in waitForConnection()
are woken.
You cannot initiate connections before the node has been started. Connection to peers specifying an unsupported transport-protocl are simply ignored.
peer
- The peer that the node should try to establish a connection to.persistent
- If true the Node wil try to keep a connection open to the peer.public boolean isAllowedApplication(Message msg, Peer peer)
msg
- The messagepeer
- The peer
public void addOurHostAndRealm(Message msg)
public int nextEndToEndIdentifier()
public String makeNewSessionId()
public String makeNewSessionId(String optional_part)
public int stateId()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |