|
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.dummy.DummyAsyncConnector
The DummyAsyncConnector simulates asynchronous send and receive operations without actually performing the operations on the network layer. This can be helpful for testing purposes. Send and receive operations handled sequentially by a separate thread from the caller. The caller returns immediately on send or receive unless flow control kicks in. There is a configurable delay to simulate real network transmission times. This delay can be modified on a per operation basis with the respective operation's client properties.
The UrlSyntax supported is general:
<protocolname>://[*]
Field Summary | |
static java.lang.String |
PROPERTY_DELAY
Property key for the operation delay. |
static java.lang.String |
PROPERTY_FAIL
Property key for failure simulation. |
static java.lang.String |
PROPERTY_RECV_MESSAGE
Property key for the message to receive. |
static java.lang.String |
PROPERTY_RECV_SENDER
Property key for the sender's Destination. |
static java.lang.String |
RECV_MESSAGE_DEFAULT
Default message to receive in the absence of a receive message property. |
static java.lang.String |
RECV_SENDER_URL_DEFAULT
Default Sender Url in the absence of a message sender property. |
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 | |
DummyAsyncConnector()
|
Method Summary | |
protected boolean |
checkJoinCondition()
Return true if the buffered receive and send queues are both empty. |
void |
configure(java.lang.String name,
Properties props)
Configure the DummyAsyncConnector. |
Destination |
getDestination(java.lang.String url,
java.util.Hashtable clientProps)
Any Urls are managed which have the configured protocol prefix. |
protected boolean |
onRecv(Envelope env)
Simulate receiving a message asynchronously from a Destination, providing configurable receive delay and failure opportunity. |
protected boolean |
onSend(Envelope env)
Simulate sending a message asynchronously to a Destination, providing configurable send delay and failure opportunity. |
protected void |
shutdownState()
Clear the buffered send and receive queues. |
Methods inherited from class org.jumpi.impl.AbstractConnector |
cancelRecv, cancelSend, getName, getTaskId, isLongRunning, isSchedulable, manage, recv, run, send |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String PROPERTY_RECV_MESSAGE
public static final java.lang.String RECV_MESSAGE_DEFAULT
public static final java.lang.String PROPERTY_RECV_SENDER
public static final java.lang.String RECV_SENDER_URL_DEFAULT
public static final java.lang.String PROPERTY_FAIL
public static final java.lang.String PROPERTY_DELAY
Constructor Detail |
public DummyAsyncConnector()
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:
senddelay - integer[0..MAX-INT] - optional[0].
The default time interval to delay the sending thread to simulate a real send.
recvdelay - integer[0..MAX-INT] - optional[0].
The default time interval to delay a receiving thread to simulate a real receive.
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.public Destination getDestination(java.lang.String url, java.util.Hashtable clientProps)
Any Urls are managed which have the configured protocol prefix. The syntax of supported Urls is defined as:
<protocol>://<uri> where <protocol> is the configured protocol and <uri> is any string.
getDestination
in interface Connector
getDestination
in class AbstractConnector
url
- the Destination Url.clientProps
- not used.
java.lang.IllegalArgumentException
- when url is null.protected boolean onSend(Envelope env) throws java.lang.Exception
Simulate sending a message asynchronously to a Destination, providing configurable send delay and failure opportunity.
The message format required on entry is determined by the send transformer. Since messages are not actually sent, the Connector does not require any specific message format.
Allows multiple concurrent send operations to the same Destination and different Destinations. The sends are however 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.
If the PROPERTY_FAIL is present, the operation will fail after the delay.
If the PROPERTY_DELAY is present, it overrides the time delay in milliseconds that has been configured to simulate network operations for the operation.
onSend
in class AbstractConnector
env
- the Envelope containing the Destination to send to and the
message.
java.lang.Exception
- if a failure condition occurs, or PROPERTY_FAIL
exists.protected boolean onRecv(Envelope env) throws java.lang.Exception
Simulate receiving a message asynchronously from a Destination, providing configurable receive delay and failure opportunity. Since no actual message is received from the network layer, the client application can provide a message to return and a sender. In the absence of the client application specifying these values, defaults are provided.
The message format required on reception is determined by the receive transformer. Since messages are not actually received, the receive transformer must handle the default message type, which is a String, or the type passed as the received message in the client properties.
Allows multiple concurrent receive operations to the same Destination and different Destinations. The receives are however processes sequentially by the instance's task working off the buffered receive queue.
Non blocking until the buffered receive queue has filled, at which time receive flow control prohibits further receives until there is space in the queue.
If the PROPERTY_FAIL is present, the operation will fail after the operation delay.
If the PROPERTY_DELAY is present, it overrides the time delay in milliseconds that has been configured to simulate network operations for the operation.
If the PROPERTY_RECV_MESSAGE is present, it will be used as the message received. If it is not present, then a default String message is received.
If the PROPERTY_RECV_SENDER is present, it will be used as the Url of the sender. If it is not present, then a default String Url is used as the Sender Url.
onRecv
in class AbstractConnector
env
- the Envelope containing the Destination to receive from.
java.lang.Exception
- if a failure condition occurs whilst receiving or
PROPERTY_FAIL set.protected boolean checkJoinCondition()
checkJoinCondition
in class AbstractConnector
protected void shutdownState()
shutdownState
in class AbstractConnector
|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |