|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jumpi.impl.AbstractConnector | +--org.jumpi.impl.connector.udp.UdpConnector
The UdpConnector sends and receives packets over unicast UDP. A UdpTransceiver instance continuously receives packets from a local configured port. Receive operations define a Destination filter through which packets must match before being dispatched to the Controller layer. If packets are received where no receive Destination is defined, then the packet is simply discarded. Wildcard destinations are used to match any host, any port or the combination of both. Sending can take place to any UdpDestination.
<protocolname>://[<ipaddress>|*]:[<port>|*]
Field Summary |
Fields inherited from class org.jumpi.impl.AbstractConnector |
cancelledRecvs_, cancelledSends_, controller_, joinFailInterval_, joinTestInterval_, jumpi_, maxRecvBacklog_, maxSendBacklog_, name_, protocol_, recvQueue_, recvTransformer_, sendQueue_, sendTransformer_, started_, stopping_, taskId_, url_format_, url_prefix_ |
Constructor Summary | |
UdpConnector()
|
Method Summary | |
void |
cancelRecv(Envelope env)
Remove the receive Destination from the specific or wildcard receive filters, such receive matching cannot take place for the Destination. |
protected boolean |
checkJoinCondition()
The clean shutdown condition is reached when there are no pending send operations and both wildcard and specific receive Destination filters are empty. |
void |
configure(java.lang.String name,
Properties props)
Configure the UdpConnector. |
Destination |
getDestination(java.lang.String url,
java.util.Hashtable clientProps)
Return a Destination corresponding to the Url if the Url matches the UdpDestination syntax. |
void |
manage(Component root,
Component parent,
java.lang.String operation,
java.util.Hashtable parameters)
Perform a recursive management operation through the Jumpi component tree, using the parameters provided. |
void |
onReceive(java.net.DatagramPacket pack)
Callback used by the UdpTransceiver to deliver received DatagramPackets to the UdpConnector. |
protected boolean |
onRecv(Envelope env)
Does nothing since there is no synchronous receiving. |
protected boolean |
onSend(Envelope env)
Send a message to a UdpDestination. |
void |
recv(Envelope env)
Receive a message from a UdpDestination. |
protected void |
shutdownState()
Clears the pending send operation queue and receive filters. |
Methods inherited from class org.jumpi.impl.AbstractConnector |
cancelSend, getName, getTaskId, isLongRunning, isSchedulable, run, send |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.jumpi.spi.component.Task |
getTaskId, isLongRunning, isSchedulable |
Methods inherited from interface java.lang.Runnable |
run |
Constructor Detail |
public UdpConnector()
Method Detail |
public void configure(java.lang.String name, Properties props) throws java.lang.Exception
The following configuration attributes are defined in addition to those of the superclass:
transceiver - instance - optional[default + org.jumpi.impl.connector.udp.UdpTransceiver].
The transceiver subcomponent's name suffix.
configure
in interface Configurable
configure
in class AbstractConnector
name
- the fully qualified instance name.props
- the read-only properties to configure the instance with.
java.lang.Exception
- when configuration is unsuccessful.protected boolean checkJoinCondition()
checkJoinCondition
in class AbstractConnector
protected void shutdownState()
shutdownState
in class AbstractConnector
public void manage(Component root, Component parent, java.lang.String operation, java.util.Hashtable parameters) throws java.lang.Exception
manage
in interface Manageable
manage
in class AbstractConnector
root
- the Jumpi instance at the root of the component tree.parent
- the immediate parent of the component.operation
- the operation.parameters
- the operation parameters.
java.lang.Exception
- if any failure to perform management occurs.public Destination getDestination(java.lang.String url, java.util.Hashtable clientProps)
UdpDestination
syntax. The empty Uri, i.e. <protocol>://
represents the UdpConnector's UdpTransceiver.
getDestination
in interface Connector
getDestination
in class AbstractConnector
url
- specific or wildcard UdpDestination Url.clientProps
- not used.
java.lang.IllegalArgumentException
- when url is null.public void recv(Envelope env) throws java.lang.Exception
Receive a message from a UdpDestination. The UdpDestination of the receive is placed in a UdpDestination filter. When the UdpTransceiver receives a DatagramPacket which matches the UdpDestination, this will be passed up as the response to the receive operation. For best performance, use specific UdpDestinations without wildcards, or few wildcard Destinations.
The format of the data provided by the UdpTransceiver is a byte[]. This is given directly as the received data to the Controller in absence of a receive transformer. If a receive transformer is configured, then this is given the byte[] and it gives the transformed message to the Controller layer.
Allows multiple concurrent receive operations to different Destinations but not the same Destination. There is no limit to the number of different Destinations which can simultaneously be received from.
Non blocking always.
recv
in interface Connector
recv
in class AbstractConnector
env
- the Envelope containing the Destination to receive from.
java.lang.Exception
- if a failure condition occurs.
java.lang.IllegalArgumentException
- if env is null.
java.lang.IllegalStateException
- if not started or stopping.Controller.callbackRecv(org.jumpi.spi.Envelope, boolean, java.lang.String)
protected boolean onRecv(Envelope env) throws java.lang.Exception
onRecv
in class AbstractConnector
env
- not used.
java.lang.Exception
- never.public void cancelRecv(Envelope env)
cancelRecv
in interface Connector
cancelRecv
in class AbstractConnector
env
- the operation to cancel.
java.lang.IllegalArgumentException
- when env is null.protected boolean onSend(Envelope env) throws java.lang.Exception
Send a message to a UdpDestination.
The message format required for sending via the UdpTransceiver is a byte[]. If a send transformer is configured then this must map the input data to a byte[], otherwise the byte[] must be supplied by the Controller. The UdpTransceiver does not modify the data for sending via Udp at all. The operation may fail or truncate data if the length of the data is greater than that which can be sent by the operating system.
Allows multiple concurrent send operations to any Destinations. The sends are processes sequentially by the instance's task working off the buffered send queue.
Non blocking until the buffered send queue has filled, at which time send flow control prohibits further sending until there is space in the queue.
onSend
in class AbstractConnector
env
- the Envelope containing the Destination to send to and the
message.
java.lang.Exception
- if a failure condition occurs.public void onReceive(java.net.DatagramPacket pack)
pack
- a DatagramPacket received from the UdpTransceiver.UdpTransceiver.run()
|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |