|
xmlBlaster 2.0.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.util.dispatch.DispatchManager
public final class DispatchManager
Manages the sending of messages and commands and does error recovery further we communicate with the dispatcher plugin if one is configured.
There is one instance of this class per queue and remote connection.
Field Summary | |
---|---|
private java.lang.Object |
ALIVE_TRANSITION_MONITOR
|
private long |
burstModeMaxBytes
|
private int |
burstModeMaxEntries
|
private long |
collectTime
If > 0 does burst mode |
private java.util.HashSet |
connectionStatusListeners
|
private DispatchConnectionsHandler |
dispatchConnectionsHandler
|
private boolean |
dispatcherActive
async delivery is activated only when this flag is 'true'. |
private boolean |
dispatchWorkerIsActive
|
private I_MsgErrorHandler |
failureListener
|
private Global |
glob
|
private boolean |
inAliveTransition
|
private boolean |
inDispatchManagerCtor
|
private boolean |
isShutdown
|
private boolean |
isSyncMode
|
private static java.util.logging.Logger |
log
|
java.lang.String |
ME
|
private I_MsgDispatchInterceptor |
msgInterceptor
|
private I_Queue |
msgQueue
|
private int |
notifyCounter
|
private I_MsgSecurityInterceptor |
securityInterceptor
|
private SessionName |
sessionName
|
private boolean |
shallCallToAliveSync
|
private DispatchWorker |
syncDispatchWorker
The worker for synchronous invocations |
private Timestamp |
timerKey
|
private long |
toAliveTime
|
private long |
toPollingTime
|
private boolean |
trySyncMode
|
private java.lang.String |
typeVersion
|
Constructor Summary | |
---|---|
DispatchManager(Global glob,
I_MsgErrorHandler failureListener,
I_MsgSecurityInterceptor securityInterceptor,
I_Queue msgQueue,
I_ConnectionStatusListener connectionStatusListener,
AddressBase[] addrArr,
SessionName sessionName)
|
Method Summary | |
---|---|
private void |
activateDispatchWorker()
Give the callback worker thread a kick to deliver the messages. |
boolean |
addConnectionStatusListener(I_ConnectionStatusListener connectionStatusListener)
|
boolean |
addConnectionStatusListener(I_ConnectionStatusListener connectionStatusListener,
boolean fireInitial)
|
private void |
callToAliveSync()
|
private boolean |
checkSending(boolean isPublisherThread)
|
java.util.ArrayList |
filterDistributorEntries(java.util.ArrayList entries,
java.lang.Throwable ex)
|
void |
finalize()
|
long |
getAliveSinceTime()
Get timestamp when we went to ALIVE state. |
long |
getBurstModeMaxBytes()
How many bytes maximum shall the callback thread take in one bulk out of the callback queue and deliver in one bulk. |
int |
getBurstModeMaxEntries()
How many messages maximum shall the callback thread take in one bulk out of the callback queue and deliver in one bulk. |
I_ConnectionStatusListener[] |
getConnectionStatusListeners()
|
DispatchConnectionsHandler |
getDispatchConnectionsHandler()
|
DispatchStatistic |
getDispatchStatistic()
|
java.lang.String |
getId()
For logging |
I_MsgDispatchInterceptor |
getMsgDispatchInterceptor()
|
I_MsgErrorHandler |
getMsgErrorHandler()
|
I_MsgSecurityInterceptor |
getMsgSecurityInterceptor()
|
int |
getNotifyCounter()
Counts how often a new entry was added since the current worker thread was started. |
long |
getPollingSinceTime()
Get timestamp when we went to POLLING state. |
I_Queue |
getQueue()
|
SessionName |
getSessionName()
|
java.lang.String |
getTypeVersion()
The name in the configuration file for the plugin |
private void |
givingUpDelivery(XmlBlasterException ex)
|
(package private) void |
handleSyncWorkerException(java.util.List<I_Entry> entryList,
java.lang.Throwable throwable)
Called by DispatchWorker if an Exception occured in sync mode Only on client side |
(package private) void |
handleWorkerException(java.util.List<I_Entry> entryList,
java.lang.Throwable throwable)
Called by DispatchWorker if an Exception occurred in async mode. |
private void |
initDispatcherActive(AddressBase[] addrArr)
Switch on/off the sending of messages. |
void |
internalError(java.lang.Throwable throwable)
Called locally and from TopicHandler when internal error (Throwable) occurred to avoid infinite looping |
boolean |
isAlive()
|
boolean |
isDead()
|
boolean |
isDispatcherActive()
|
boolean |
isPolling()
|
boolean |
isShutdown()
|
boolean |
isSyncMode()
|
void |
lostClientConnection()
Can be called when client connection is lost (NOT the callback connection). |
void |
notifyAboutNewEntry()
When somebody puts a new entry into the queue, we want to be notified about this after the entry is fed. |
boolean |
pingCallbackServer(boolean sync,
boolean connectionIsDown)
|
void |
postSendNotification(MsgQueueEntry entry)
|
void |
postSendNotification(MsgQueueEntry[] entries)
|
java.util.ArrayList |
prepareMsgsFromQueue(java.util.List<I_Entry> entryList)
Here we prepare messages which are coming directly from the queue. |
static java.util.ArrayList |
prepareMsgsFromQueue(java.lang.String logId,
java.util.logging.Logger log,
I_Queue queue,
java.util.List<I_Entry> entryList)
|
void |
putPost(I_QueueEntry queueEntry)
Called by I_Queue implementation before leaving put() and somebody has registered for such events. |
void |
putPost(I_QueueEntry[] queueEntries)
Called by I_Queue implementation before leaving put() and somebody has registered for such events. |
boolean |
putPre(I_QueueEntry queueEntry)
Called by I_Queue implementation when a put() is invoked and somebody has registered for such events |
boolean |
putPre(I_QueueEntry[] queueEntries)
Called by I_Queue implementation when a put() is invoked and somebody has registered for such events |
void |
reachedAliveSync(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection)
|
private void |
removeBurstModeTimer()
Remove the burst mode timer |
boolean |
removeConnectionStatusListener(I_ConnectionStatusListener connectionStatusListener)
Remove the given listener |
void |
removeFromQueue(MsgQueueEntry[] entries,
boolean postSendNotify)
Messages are successfully sent, remove them now from queue (sort of a commit()): We remove filtered/destroyed messages as well (which doen't show up in entryListChecked) |
boolean |
sendingFailedNotification(MsgQueueEntry[] entries,
XmlBlasterException ex)
Notify I_PostSendListener about problem. |
void |
setAddresses(AddressBase[] addr)
Set new callback addresses, typically after a session login/logout |
void |
setDispatcherActive(boolean dispatcherActive)
Inhibits/activates the delivery of asynchronous dispatches of messages. |
(package private) void |
setDispatchWorkerIsActive(boolean val)
The worker notifies us that it is finished, if messages are available it is triggered again. |
void |
shutdown()
Stop all callback drivers of this client. |
(package private) void |
shutdownFomAnyState(ConnectionStateEnum oldState,
XmlBlasterException ex)
Call by DispatchConnectionsHandler on state transition |
private void |
startWorkerThread(boolean fromTimeout)
|
void |
switchToASyncMode()
Switch back to asynchronous mode. |
void |
switchToSyncMode()
We register a QueuePutListener and all put() into the queue are intercepted - our put() is called instead. |
void |
timeout(java.lang.Object userData)
We are notified about the burst mode timeout through this method. |
(package private) void |
toAlive(ConnectionStateEnum oldState)
Call by DispatchConnectionsHandler on state transition NOTE: toAlive is called initially when a protocol plugin is successfully loaded but we don't know yet if it ever is able to connect |
void |
toDead(XmlBlasterException ex)
|
(package private) void |
toPolling(ConnectionStateEnum oldState)
Call by DispatchConnectionsHandler on state transition |
java.lang.String |
toXml(java.lang.String extraOffset)
Dump state of this object into a XML ASCII string. |
void |
trySyncMode(boolean trySyncMode)
Set behavior of dispatch framework. |
void |
updateProperty(CallbackAddress[] addressArr)
Reconfigure dispatcher with given properties. |
private boolean |
useBurstModeTimer()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final java.lang.String ME
private final Global glob
private static java.util.logging.Logger log
private final I_Queue msgQueue
private final DispatchConnectionsHandler dispatchConnectionsHandler
private final I_MsgErrorHandler failureListener
private final I_MsgSecurityInterceptor securityInterceptor
private final I_MsgDispatchInterceptor msgInterceptor
private java.util.HashSet connectionStatusListeners
private final java.lang.String typeVersion
private long collectTime
private long toAliveTime
private long toPollingTime
private boolean dispatchWorkerIsActive
private DispatchWorker syncDispatchWorker
private Timestamp timerKey
private int notifyCounter
private boolean isShutdown
private boolean isSyncMode
private boolean trySyncMode
private boolean inAliveTransition
private final java.lang.Object ALIVE_TRANSITION_MONITOR
private int burstModeMaxEntries
private long burstModeMaxBytes
private boolean dispatcherActive
private boolean shallCallToAliveSync
private boolean inDispatchManagerCtor
private SessionName sessionName
Constructor Detail |
---|
public DispatchManager(Global glob, I_MsgErrorHandler failureListener, I_MsgSecurityInterceptor securityInterceptor, I_Queue msgQueue, I_ConnectionStatusListener connectionStatusListener, AddressBase[] addrArr, SessionName sessionName) throws XmlBlasterException
msgQueue
- The message queue which i use (!!! TODO: this changes, we should pass it on every method where needed)connectionStatusListener
- The implementation which listens on connectionState events (e.g. XmlBlasterAccess.java), or nulladdrArr
- The addresses i shall connect to
XmlBlasterException
Method Detail |
---|
public SessionName getSessionName()
public boolean isSyncMode()
public void trySyncMode(boolean trySyncMode)
trySyncMode
- true: client side queue embedding, false: server side callback queue
defaults to falsepublic final void updateProperty(CallbackAddress[] addressArr) throws XmlBlasterException
addressArr
- The new configuration
XmlBlasterException
public void finalize()
finalize
in class java.lang.Object
public I_Queue getQueue()
public boolean addConnectionStatusListener(I_ConnectionStatusListener connectionStatusListener)
public boolean addConnectionStatusListener(I_ConnectionStatusListener connectionStatusListener, boolean fireInitial)
public boolean removeConnectionStatusListener(I_ConnectionStatusListener connectionStatusListener)
connectionStatusListener
-
public I_ConnectionStatusListener[] getConnectionStatusListeners()
public java.lang.String getTypeVersion()
public I_MsgSecurityInterceptor getMsgSecurityInterceptor()
public final DispatchConnectionsHandler getDispatchConnectionsHandler()
public final int getBurstModeMaxEntries()
public final long getBurstModeMaxBytes()
public final long getAliveSinceTime()
public final long getPollingSinceTime()
void toAlive(ConnectionStateEnum oldState)
public void reachedAliveSync(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
void toPolling(ConnectionStateEnum oldState)
public void toDead(XmlBlasterException ex)
ex
- void shutdownFomAnyState(ConnectionStateEnum oldState, XmlBlasterException ex)
private void givingUpDelivery(XmlBlasterException ex)
public void postSendNotification(MsgQueueEntry entry)
public void postSendNotification(MsgQueueEntry[] entries)
public boolean sendingFailedNotification(MsgQueueEntry[] entries, XmlBlasterException ex)
Typically XmlBlasterAccess is notified when message came asynchronously from queue
entryList
- ex
-
for explanation
void handleSyncWorkerException(java.util.List<I_Entry> entryList, java.lang.Throwable throwable) throws XmlBlasterException
XmlBlasterException
public void removeFromQueue(MsgQueueEntry[] entries, boolean postSendNotify) throws XmlBlasterException
postSendNotify
- TODO
XmlBlasterException
void handleWorkerException(java.util.List<I_Entry> entryList, java.lang.Throwable throwable) throws XmlBlasterException
XmlBlasterException
- should never happen but is possible during removing entries from queuepublic I_MsgErrorHandler getMsgErrorHandler()
public void switchToSyncMode()
private void callToAliveSync()
public void switchToASyncMode()
public boolean putPre(I_QueueEntry queueEntry) throws XmlBlasterException
I_QueuePutListener
putPre
in interface I_QueuePutListener
queueEntry
- Is guaranteed to never be null
XmlBlasterException
I_QueuePutListener.putPre(I_QueueEntry)
public boolean putPre(I_QueueEntry[] queueEntries) throws XmlBlasterException
I_QueuePutListener
putPre
in interface I_QueuePutListener
queueEntries
- Is guaranteed to never be null
XmlBlasterException
putPre(I_QueueEntry)
,
I_QueuePutListener.putPre(I_QueueEntry[])
public void putPost(I_QueueEntry queueEntry) throws XmlBlasterException
I_QueuePutListener
putPost
in interface I_QueuePutListener
queueEntry
- Is guaranteed to never be null
XmlBlasterException
I_QueuePutListener.putPost(I_QueueEntry)
public void putPost(I_QueueEntry[] queueEntries) throws XmlBlasterException
I_QueuePutListener
putPost
in interface I_QueuePutListener
queueEntries
- Is guaranteed to never be null
XmlBlasterException
putPost(I_QueueEntry)
,
I_QueuePutListener.putPost(I_QueueEntry[])
public java.util.ArrayList prepareMsgsFromQueue(java.util.List<I_Entry> entryList)
public static java.util.ArrayList prepareMsgsFromQueue(java.lang.String logId, java.util.logging.Logger log, I_Queue queue, java.util.List<I_Entry> entryList)
public void notifyAboutNewEntry()
Called by I_Queue.putPost()
public int getNotifyCounter()
private void activateDispatchWorker()
private boolean useBurstModeTimer()
private void removeBurstModeTimer()
private void startWorkerThread(boolean fromTimeout)
fromTimeout
- for logging onlypublic boolean isDead()
public boolean isPolling()
public boolean isAlive()
public void lostClientConnection()
public boolean pingCallbackServer(boolean sync, boolean connectionIsDown)
private boolean checkSending(boolean isPublisherThread)
isPublisherThread
- We take care that the publisher thread, coming through putPost()
does never too much work to return fast enough and avoid possible dead locks.
public void timeout(java.lang.Object userData)
timeout
in interface I_Timeout
userData
- You get bounced back your userData which you passed
with Timeout.addTimeoutListener()public I_MsgDispatchInterceptor getMsgDispatchInterceptor()
public void setAddresses(AddressBase[] addr) throws XmlBlasterException
XmlBlasterException
private void initDispatcherActive(AddressBase[] addrArr)
void setDispatchWorkerIsActive(boolean val)
public void internalError(java.lang.Throwable throwable)
public DispatchStatistic getDispatchStatistic()
public boolean isShutdown()
public void shutdown()
public java.lang.String getId()
public java.lang.String toXml(java.lang.String extraOffset)
extraOffset
- indenting of tags for nice output
public void setDispatcherActive(boolean dispatcherActive)
dispatcherActive
- public boolean isDispatcherActive()
public java.util.ArrayList filterDistributorEntries(java.util.ArrayList entries, java.lang.Throwable ex)
|
xmlBlaster 2.0.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |