All Packages Class Hierarchy This Package Previous Next Index
Class iBus.layers.DISPATCH
java.lang.Object
|
+----iBus.ProtocolObject
|
+----iBus.layers.DISPATCH
- public class DISPATCH
- extends ProtocolObject
DISPATCH: DISPATCH buffers incoming events and provides
a selection of thread policies to dispatch events:
Single thread, thread-per-request, thread pool.
Simple applications should rely on the single-threaded policy, which
is the default.
The performance of servers that carry out time consuming
queries can be improved considerably by using the threadPerRequest
policy, at the cost of giving up FIFO ordering, however, because
postings that arrive on the same channel are dispatched concurrently.
The threadPool policy works much like thread-per-request
but imposes a maximum on the number of dispacher threads that
are created to run concurently.
Finally, the threadPerChannel policy provides a certain level of
concurrency but also ensures that postings that arrive on a channel
are dispatched in the same order they were sent.
PARAMETERS:
-
threadPerRequest: int: 1|0. Whether a dispatcher thread is
created per request. Note that with threadPerRequest
the FIFO ordering property is lost, i.e. it is no longer
guaranteed that postings are dispatched in the same
order they were pushed to the channel.
Default: 0 (Single threaded).
-
threadPool: int: 1|0. Whether a pool of threads is to be used for
dispatching requests. Note that with threadPool
the FIFO ordering property is lost, i.e. it is no longer
guaranteed that postings are dispatched in the same
order they were pushed to the channel.
Default: 0.
-
threadPerChannel: int: 1|0. Whether a dispatcher thread is
created per subscribed channel. It is guaranteed that
postings that arrive on a channel are dispatched
always by the same thread. Postings arriving on
different channel are disptached concurrently.
Default: 0 (Single threaded).
-
poolSize: int: > 0. The size of the thread pool.
Default: 5.
-
prio: String: min, norm or max. The priority level of the dispatcher
threads.
Default: norm.
POSITION IN STACK:
-
Atop PULL in the "Reliable" stack. Atop "TCP" in the "Point-to-point"
stack.
DESIGN:
-
A FIFOQueue object is used to hold
events that arrive via upHandleEvent(). One or more dispatcher threads
pop events off the queue and pass them up the stack.
EVENTS PRODUCED:
EVENTS HANDLED:
-
events are passed up the stack unmodified.
EVENTS CONSUMED:
THREADS:
-
According to the policy in use (single, per-request, or pool).
Incoming events are buffered in a FIFOQueue and picked up by a
dispatcher thread. The dispatcher threads run in their own thread group
which is aggessible via DISPATCH.getThreadGroup().
-
DISPATCH()
- Create an DISPATCH protocol object
-
createQueue(iBusURL)
- Create a new queue.
-
dnFlush()
- Flush the protocol object.
-
dnInit()
- Initialize the protocol object after the protocol stack is
created.
-
dnSubscribe(iBusURL)
- Called by the object above to subscribe to a channel.
-
dnUnsubscribe(iBusURL)
- Called by the object above or by an iBus application to unsubscribe
from a certain channel.
-
getMaxPendingEvents()
- Return the maxPendingEvents property
-
getPoolSize()
- Get the poolSize property.
-
getQueue(iBusURL)
- Obtain the event queue for a given channel.
-
getThreadGroup()
- Obtain the thread group of the dispatcher threads.
-
isThreadPerRequest()
- Get the threadPerRequest property.
-
isThreadPool()
- Get the threadPool property.
-
isThrottling()
- Return the throttling property.
-
removeQueue(iBusURL)
- Remove a queue.
-
setMaxpendingEvents(int)
- Set the maxPendingEvents property
-
setThrottling(boolean)
- Set the throttling property.
-
upHandleEvent(Event)
- Called by the protocol object beneath to pass an event up to me.
DISPATCH
public DISPATCH()
- Create an DISPATCH protocol object
dnInit
public synchronized void dnInit()
- Initialize the protocol object after the protocol stack is
created. Also checks whether the right parameters were given to the
protocol object.
- Overrides:
- dnInit in class ProtocolObject
dnFlush
public void dnFlush()
- Flush the protocol object. Deliver any buffered messages.
- Overrides:
- dnFlush in class ProtocolObject
dnSubscribe
public synchronized void dnSubscribe(iBusURL channel) throws AlreadySubscribed, CommException
- Called by the object above to subscribe to a channel.
- Parameters:
- channel - the channel to subscribe to
- Throws: AlreadySubscribed
- if this stack is already
subscribed to the channel
- Throws: CommException
- in case of a communication
error
- Overrides:
- dnSubscribe 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
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
getMaxPendingEvents
public int getMaxPendingEvents()
- Return the maxPendingEvents property
- Returns:
- the maxPendingEvents property
setMaxpendingEvents
public void setMaxpendingEvents(int m)
- Set the maxPendingEvents property
- Parameters:
- m - the maxPendingEvents property
getThreadGroup
public ThreadGroup getThreadGroup()
- Obtain the thread group of the dispatcher threads.
- Returns:
- the thread group of the dispatcher threads
isThreadPerRequest
public boolean isThreadPerRequest()
- Get the threadPerRequest property.
- Returns:
- the threadPerRequest property
isThreadPool
public boolean isThreadPool()
- Get the threadPool property.
- Returns:
- the threadPool property
getPoolSize
public int getPoolSize()
- Get the poolSize property.
- Returns:
- the poolSize property
createQueue
protected synchronized FIFOQueue createQueue(iBusURL channel)
- Create a new queue.
- Parameters:
- channel - the channel of the queue
- Returns:
- the new queue
removeQueue
protected synchronized void removeQueue(iBusURL channel)
- Remove a queue.
- Parameters:
- channel - the channel of the queue
getQueue
protected synchronized FIFOQueue getQueue(iBusURL channel)
- Obtain the event queue for a given channel. This is needed by
threadPerChannel.
- Parameters:
- channel - the channel
- Returns:
- the event queue for the channel
setThrottling
protected void setThrottling(boolean t)
- Set the throttling property.
- Parameters:
- t - the new value of the throttling property
isThrottling
protected boolean isThrottling()
- Return the throttling property.
- Returns:
- the throttling property
All Packages Class Hierarchy This Package Previous Next Index