Jumpi v1.2.0

org.jumpi.impl.controller.stateless
Class StatelessController

java.lang.Object
  |
  +--org.jumpi.impl.AbstractController
        |
        +--org.jumpi.impl.controller.stateless.StatelessController
All Implemented Interfaces:
Component, Configurable, Controller, Manageable, Status, Status

public class StatelessController
extends AbstractController
implements Status

The StatelessController provides a transparent Controller functionality, where messages are passed between client application and Connector layer without any flow control, concurrency support, ordering nor quality of service guarantees. Messages are handled opaquely, subject only to optional send transformation on send, and receive transformation when received. Any number of Connectors are supported. A message is sent to or received from a single Connector, which is the first to support the Destination's Url, determined in configuration order. Supports any Destination Url syntax which the Connectors support.

The Destination Urls supported are those of the configured Connectors, without alteration.

Essentially compatible with all Connectors, however since no concurrency or synchronization support is provided, it is the responsibility of the client application to make sure the concurrency and synchronization requirements of the Connection components used are met. For example if a Connector does not support multiple concurrent sends to the same Destination, then this must be guaranteed by the client application.


Field Summary
 
Fields inherited from class org.jumpi.impl.AbstractController
connectors_, joinFailInterval_, joinTestInterval_, jumpi_, name_, recvTransformer_, sendTransformer_, started_, stopping_
 
Fields inherited from interface org.jumpi.spi.Status
STATUS_RECEIVING, STATUS_SENDING
 
Fields inherited from interface org.jumpi.Status
STATUS_CANCELLED, STATUS_FAILURE, STATUS_SUCCESS, STATUS_TRANSIENT
 
Constructor Summary
StatelessController()
           
 
Method Summary
 void callbackRecv(Envelope env, boolean success, java.lang.String status)
           Callback called by Connector to signal completion of a Connector receive operation.
 void callbackSend(Envelope env, boolean success, java.lang.String status)
          Callback called by Connector to signal completion of a Connector send operation.
 void cancelRecv(Destination dest, Handle hdl)
           Cancel a pending receive operation.
 void cancelSend(Destination dest, Handle hdl)
           Cancel a pending send operation.
protected  boolean checkJoinCondition()
           Checks when the Controller has truly finished work after receiving a shutdown command.
 Handle recv(Destination dest, java.util.Hashtable clientProps)
           Receive a message from the Destination, providing no quality of service guarantees, ordering nor concurrency support.
 Handle send(Destination dest, java.lang.Object msg, java.util.Hashtable clientProps)
           Send the message to the Destination, providing no flow control, quality of service guarantees, ordering nor concurrency support.
protected  void shutdownState()
          Fail and remove any receive or send operations which are pending at the Connector layer.
 
Methods inherited from class org.jumpi.impl.AbstractController
configure, getDestination, getName, manage, transferInternalProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatelessController

public StatelessController()
Method Detail

shutdownState

protected void shutdownState()
Fail and remove any receive or send operations which are pending at the Connector layer.

Specified by:
shutdownState in class AbstractController

checkJoinCondition

protected boolean checkJoinCondition()

Checks when the Controller has truly finished work after receiving a shutdown command. If there are no pending send or receive operations then, since no new operations can be started, we have a clean shutdown criteria.

Specified by:
checkJoinCondition in class AbstractController
Returns:
true when no receive or send operations are pending, else false.

send

public Handle send(Destination dest,
                   java.lang.Object msg,
                   java.util.Hashtable clientProps)

Send the message to the Destination, providing no flow control, quality of service guarantees, ordering nor concurrency support. No message delivery guarantees are implemented over and above those provided by the Connector layer. Send operations are delegated to a single Connector which created the Destination in getDestination(). The StatelessController passes the message directly to the Connector after performing optional send transformation on the message. There is a 1:1 relationship between calls to send and those passed down to the Connector layer.

The message format required on entry is not defined since messages are handled as opaque objects, subject to send transformation once before passing to the Connector layer.

Potentially allows unlimited multiple concurrent send operations to the same Destination and different Destinations. Concurrency may be limited at the Connector layer.

Blocking or non blocking depending on the synchronization of the send method of the Connector. No synchronization nor flow control takes place in the Controller. The caller's thread is used to delegate to the Connection layer. Therefore send may block if the Connector's send method blocks. If the Connector's send method is synchronous, then the method only returns once the send has completed at the Connector.

The message is passed to the Connector and resides in the STATUS_SENDING transient state until either cancelSend is called by the client application or callbackSend is called by the Connector.

Specified by:
send in interface Controller
Overrides:
send in class AbstractController
Parameters:
dest - the Destination to which the msg is to be sent.
msg - the message.
clientProps - not used but delegated in the Envelope to the Connector.
Returns:
a Handle associated to the send operation.

callbackSend

public void callbackSend(Envelope env,
                         boolean success,
                         java.lang.String status)
Callback called by Connector to signal completion of a Connector send operation. The success status and status message are provided by the Connector. A Connector will always call callbackSend after completion unless a cancel has been performed for the Envelope at the Connector. Due to multithreading and synchronization, a Controller can expect callbackSend to be called whilst calling Connector.cancelSend. In this case, the pending Handle has already been removed from the list and a warning is logged.

Specified by:
callbackSend in interface Controller
Overrides:
callbackSend in class AbstractController
Parameters:
env - the Envelope used in Connector.send
success - true if successfully sent or false if a failure ocured.
status - a message giving more information to the status.

recv

public Handle recv(Destination dest,
                   java.util.Hashtable clientProps)

Receive a message from the Destination, providing no quality of service guarantees, ordering nor concurrency support. Receive operations are delegated to a single Connector which created the Destination in getDestination(). There is a 1:1 relationship between calls to receive and those passed down to the Connector layer.

The message format required on receive is not defined since messages are handled as opaque objects, subjected to receive transformation before passing to the client application in the Handle.

Potentially allows unlimited multiple concurrent receive operations to the same Destination and different Destinations. Concurrency may be limited at the Connector layer.

Blocking or non blocking depending on the synchronization of the receive method of the Connector. The caller's thread is used to delegate to the Connection layer. Therefore receive may block if the Connector's receive method blocks. If the Connector's receive method is synchronous, then the method only returns once the receive has completed at the Connector.

The message is passed to the Connector and resides in the STATUS_RECEIVING transient state until either cancelRecv is called by the client application or callbackRecv is called by the Connector.

Specified by:
recv in interface Controller
Overrides:
recv in class AbstractController
Parameters:
dest - the Destination from which to receive a message.
clientProps - not used but delegated in the Envelope to the Connector.
Returns:
a Handle associated to the recv operation.

callbackRecv

public void callbackRecv(Envelope env,
                         boolean success,
                         java.lang.String status)

Callback called by Connector to signal completion of a Connector receive operation. The success status and status message are provided by the Connector. A Connector will always call callbackRecv after completion unless a cancel has been performed for the Envelope at the Connector. Due to multithreading and synchronization, a Controller can expect callbackRecv to be called whilst calling Connector.cancelRecv.

If successfully completed, the Envelope must contain the message data on the Envelope's context stack with Envelope.popContext(), and the sender must be available with Envelope.getSender()

Specified by:
callbackRecv in interface Controller
Overrides:
callbackRecv in class AbstractController
Parameters:
env - the Envelope used in Connector.recv
success - true if successfully received or false if a failure ocured.
status - a message giving more information to the status.

cancelSend

public void cancelSend(Destination dest,
                       Handle hdl)

Cancel a pending send operation. The cancel method never blocks.

Specified by:
cancelSend in interface Controller
Overrides:
cancelSend in class AbstractController
Parameters:
dest - the Destination of the send operation associated to hdl.
hdl - the Handle associated with the send operation to cancel.

cancelRecv

public void cancelRecv(Destination dest,
                       Handle hdl)

Cancel a pending receive operation. The cancel method never blocks.

Specified by:
cancelRecv in interface Controller
Overrides:
cancelRecv in class AbstractController
Parameters:
dest - the Destination of the receive operation associated to hdl.
hdl - the Handle associated with the receive operation to cancel.

Jumpi v1.2.0

Copyright © 2003, Peter Jonathan Klauser.