All Packages Class Hierarchy This Package Previous Next Index
Class iBus.layers.PULL
java.lang.Object
|
+----iBus.ProtocolObject
|
+----iBus.layers.PULL
- public class PULL
- extends ProtocolObject
- implements Runnable
PULL: basic PULL layer.
PULL implements the dnPull method. On a dnPull request it waits
until at least one listener is available on the channel or until
a timeout occurs. Then
the request posting is multicast to
the channel. Now PULL blocks the dnPull call until either a reply
posting is received, until the last
listener is gone without having sent a reply, or until a timeout
occurs.
PARAMETERS:
-
timeout: int: > 0. Sets the pull timeout to the specified amount of
milliseconds. Default: 30.000.
POSITION IN STACK:
-
Atop a reliable multicast stack. PULL requires a membership object
beneath. PULL is part of the "Reliable" quality of service.
DESIGN:
-
PULL maintains a list of PULL_Outstanding objects. There is one such
object per pull request that has not completed yet. When a reply
comes in, PULL searches its PULL_Outstanding object and resumes
the thread that is blocked in the pull downcall.
-
PULL also maintains a hashtable with the most recent view of each channel
it is pulling from. This is needed for blocking dnPull until at least
one listener exists.
FAULT TOLERANCE:
-
If a pull is issued on a channel with no listeners, then pull waits
for for a reply until a timeout occurs. On a timeout the pull can
be issues again and again, until a server comes up, after which the
pull will succeed.
-
If the only listener crashes during a pull request without returning a
reply, then the client will eventually detect that and return 0
replies.
-
If there are more than one listeners on the channel, and some of the
listeners faild during the pull request, the client will still make
progress by returning the reply of any of the surviving listeners.
A pull succeeds if at least one listener survives the request.
EVENTS PRODUCED:
EVENTS HANDLED:
-
Event.evMessage: pull replies
-
Event.evView: view changes. To figure out when a server crashes
during a pull
EVENTS CONSUMED:
-
Event.evMessage: pull replies that come in too late
THREADS:
-
IMPORTANT: if you issue pull requests from different threads
then you need to ensure those threads have unique names.
The reason is that apparently the Thread.toString() string does not
include a unique thread ID.
-
PULL.pull suspends the issuing thread until a reply is received
-
PULL maintains one thread to detect time out of pending pull requests.
-
PULL()
- Create a PULL object by initializing the ProtocolObject base class
-
dnInit()
- Initialize the protocol object after the protocol stack has been
created.
-
dnPull(iBusURL, MessageEvent)
- Called by the object above to issue a blocking pull request.
-
dnPullReply(MessageEvent, PullContext, MessageEvent)
- Reply to a pull request.
-
dnTerminate()
- Terminate any threads in the protocol object.
-
dnUnregisterTalker(iBusURL)
- Called by the object above or by an iBus application to unregister
as a talker from a channel.
-
dnUnsubscribe(iBusURL)
- Called by the object above or by an iBus application to unsubscribe
from a certain channel.
-
getTimeout()
- Returns the value of the Timeout propery.
-
run()
- A thread to periodically check whether some outstanding request
has timed out.
-
setTimeout(int)
- Set the Timeout propery.
-
upHandleEvent(Event)
- Called by the protocol object beneath to pass an event up to me.
PULL
public PULL()
- Create a PULL object by initializing the ProtocolObject base class
dnInit
public synchronized void dnInit()
- Initialize the protocol object after the protocol stack has been
created. Also checks that the right parameters were given to the
protocol object.
- Overrides:
- dnInit in class ProtocolObject
dnTerminate
public void dnTerminate()
- Terminate any threads in the protocol object. The object is
unusable afterwards.
- Overrides:
- dnTerminate in class ProtocolObject
dnPull
public MessageEvent[] dnPull(iBusURL channel,
MessageEvent msg) throws CommException, NotRegistered
- Called by the object above to issue a blocking pull request.
- Parameters:
- channel - the destination channel of the posting
- msg - the request message to be sent
- Returns:
- an array of zero or more reply messages
- Throws: CommException
- on communication failure
- Throws: NotRegistered
- in case registerTalker was not called for
the channel
- Overrides:
- dnPull in class ProtocolObject
dnPullReply
public synchronized void dnPullReply(MessageEvent reply,
PullContext pctx,
MessageEvent request) throws CommException
- Reply to a pull request.
- Parameters:
- reply - the reply message to return
- pctx - the context of the associated pull request
- request - the request message
- Throws: CommException
- on communication failure
- Overrides:
- dnPullReply in class ProtocolObject
dnUnsubscribe
public synchronized void dnUnsubscribe(iBusURL channel) throws NotSubscribed, CommException
- Called by the object above or by an iBus application to unsubscribe
from a certain channel.
- Parameters:
- channel - the channel to unsubscribe from
- Throws: NotSubscribed
- if this stack is not subscribed
to the channel
- Throws: CommException
- in case of a communication
error
- Overrides:
- dnUnsubscribe in class ProtocolObject
dnUnregisterTalker
public synchronized void dnUnregisterTalker(iBusURL channel) throws NotRegistered, CommException
- Called by the object above or by an iBus application to unregister
as a talker from a channel.
- Parameters:
- channel - the channel to unregister from
- Throws: NotRegistered
- if this stack is not
registered with the channel
- Throws: CommException
- in case of a communication
error
- Overrides:
- dnUnregisterTalker in class ProtocolObject
upHandleEvent
public void upHandleEvent(Event event)
- Called by the protocol object beneath to pass an event up to me.
An event can be the arrival of a posting, the detection of a failure,
an acknowledgement, etc.
- Parameters:
- event - determines the type of event
- Overrides:
- upHandleEvent in class ProtocolObject
run
public void run()
- A thread to periodically check whether some outstanding request
has timed out.
getTimeout
public int getTimeout()
- Returns the value of the Timeout propery.
- Returns:
- the value of the Timeout propery (milliseconds)
setTimeout
public void setTimeout(int t)
- Set the Timeout propery.
- Parameters:
- t - the new value of the Timeout property (milliseconds)
All Packages Class Hierarchy This Package Previous Next Index