|
xmlBlaster 1.6.2 API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.xmlBlaster.util.dispatch.plugins.prio.PriorizedDispatchPlugin
This dispatcher plugin allows to control how messages are sent to the remote side.
We subscribe to a status message which describes the current connection to the remote side. Depending on a status message we pick messages with specific priorities and send only these.
This allows for example to send all messages if a 2MBit connection is up, and send only high priority messages when the line drops to 64kBit.
The class ConfigurationParser Javadoc has an xml example of the configuration
This plugin class has only one instance per typeVersion for each Global scope. The xmlBlaster client used to subscribe to the status messages is a singleton (in Global.instance() scope).
Note that two status sources exist:
ConfigurationParser,
TestPriorizedDispatchPlugin,
the dispatch.control.plugin requirement| Field Summary | |
static java.lang.String |
CONFIG_PROPERTY_KEY
|
private java.lang.String |
currMsgStatus
|
private StatusConfiguration |
currMsgStatusConfiguration
This is the configuration for the current status of the last received status message: |
private java.util.Map |
dispatchManagerEntryMap
|
private Global |
glob
|
private boolean |
hasDefaultActionOnly
|
private boolean |
hasSpecificConf
|
private boolean |
isShutdown
|
private static java.util.logging.Logger |
log
|
private java.lang.String |
ME
|
private ConfigurationParser |
parser
|
DispatchAction |
QUEUE_ACTION
|
private java.lang.String |
specificConfigPropertyKey
|
private XmlBlasterNativeClient |
xmlBlasterClient
|
| Constructor Summary | |
PriorizedDispatchPlugin()
|
|
| Method Summary | |
void |
addDispatchManager(DispatchManager dispatchManager)
This is called once for each dispatch manager using this plugin. |
private DispatchManagerEntry |
changeManagerState(DispatchManager dispatchManager,
ConnectionStateEnum newState,
boolean flush)
|
boolean |
doActivate(DispatchManager dispatchManager)
Called when new messages are available. |
private void |
flushHoldbackQueue(DispatchManagerEntry managerEntry)
All entries from our holdback queue are flushed to the official queues of the DispatchManager |
private DispatchAction |
getDispatchAction(DispatchManagerEntry managerEntry,
MsgQueueEntry entry)
Lookup the corresponding DispatchAction object this message priority. |
private DispatchManagerEntry |
getDispatchManagerEntry(DispatchManager dispatchManager)
|
private DispatchManagerEntry[] |
getDispatchManagerEntryArr()
|
java.lang.String |
getType()
Enforced by I_Plugin |
java.lang.String |
getVersion()
Enforced by I_Plugin |
java.util.ArrayList |
handleNextMessages(DispatchManager dispatchManager,
java.util.ArrayList entries)
Enforced by I_MsgDispatchInterceptor. |
void |
init(Global glob,
PluginInfo pluginInfo)
Enforced by I_Plugin |
void |
initialize(Global glob,
java.lang.String typeVersion)
Is called by DispatchPluginManager after the instance is created. |
boolean |
isShutdown()
|
void |
onDispatchWorkerException(DispatchManager dispatchManager,
java.lang.Throwable ex)
Not doing anything in this method since no Exception handling is done. |
void |
postHandleNextMessages(DispatchManager dispatchManager,
MsgUnit[] processedEntries)
Not doing anything in this method since no cleanup needed. |
void |
propertyChanged(PropertyChangeEvent ev)
Invoked when the configuration PriorizedDispatchPlugin/config has changed. |
private void |
putToHoldbackQueue(DispatchManagerEntry managerEntry,
MsgQueueEntry entry)
|
void |
shutdown()
Shutdown the implementation, sync with data store |
void |
shutdown(DispatchManager dispatchManager)
Deregister a dispatch manager. |
void |
statusChanged(java.lang.String status)
Changing the status of the dispatch strategy. |
private void |
subscribeStatusMessages()
Subscribe to messages according to the current configuration. |
void |
toAlive(DispatchManager dispatchManager,
ConnectionStateEnum oldState)
Call by DispatchConnectionsHandler on state transition. |
void |
toDead(DispatchManager dispatchManager,
ConnectionStateEnum oldState,
java.lang.String errorText)
Call by DispatchConnectionsHandler on state transition Enforced by interface I_ConnectionStatusListener |
void |
toPolling(DispatchManager dispatchManager,
ConnectionStateEnum oldState)
Call by DispatchConnectionsHandler on state transition Enforced by interface I_ConnectionStatusListener |
java.lang.String |
toXml(java.lang.String extraOffset)
|
java.lang.String |
usage()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private java.lang.String ME
private Global glob
private static java.util.logging.Logger log
private ConfigurationParser parser
public static final java.lang.String CONFIG_PROPERTY_KEY
private java.lang.String specificConfigPropertyKey
private boolean hasSpecificConf
private StatusConfiguration currMsgStatusConfiguration
private java.lang.String currMsgStatus
private boolean hasDefaultActionOnly
private XmlBlasterNativeClient xmlBlasterClient
private java.util.Map dispatchManagerEntryMap
private boolean isShutdown
public DispatchAction QUEUE_ACTION
| Constructor Detail |
public PriorizedDispatchPlugin()
| Method Detail |
public void initialize(Global glob,
java.lang.String typeVersion)
throws XmlBlasterException
initialize in interface I_MsgDispatchInterceptorXmlBlasterExceptionI_MsgDispatchInterceptor.initialize(Global, String)public void addDispatchManager(DispatchManager dispatchManager)
addDispatchManager in interface I_MsgDispatchInterceptorpublic void propertyChanged(PropertyChangeEvent ev)
propertyChanged in interface I_PropertyChangeListener
private void subscribeStatusMessages()
throws XmlBlasterException
XmlBlasterException
public void init(Global glob,
PluginInfo pluginInfo)
init in interface I_PluginI_Plugin.init(org.xmlBlaster.util.Global, PluginInfo)public java.lang.String getType()
getType in interface I_Pluginpublic final java.lang.String getVersion()
getVersion in interface I_Pluginpublic final void statusChanged(java.lang.String status)
Enforced by I_Notify
On initialize: addPropertyChangeListener(this.CONFIG_PROPERTY_KEY, "startup", this); an initial event is fired an calls this method to initialize all attributes here
statusChanged in interface I_Notify
private final DispatchAction getDispatchAction(DispatchManagerEntry managerEntry,
MsgQueueEntry entry)
public final boolean doActivate(DispatchManager dispatchManager)
doActivate in interface I_MsgDispatchInterceptorI_MsgDispatchInterceptor.doActivate(DispatchManager)
public final java.util.ArrayList handleNextMessages(DispatchManager dispatchManager,
java.util.ArrayList entries)
throws XmlBlasterException
NOTE: When copying entries from one queue to another one we have to take care that the reference counter in msgUnitStore is not temporary zero (and is garbage collected). This is avoided by a peek() and later remove() - which is necessary for persistent messages anyhow to ensure 100% crash safety.
handleNextMessages in interface I_MsgDispatchInterceptorentries - null: Take messages yourself from queue (async mode) XmlBlasterExceptionI_MsgDispatchInterceptor.handleNextMessages(DispatchManager, ArrayList)private DispatchManagerEntry getDispatchManagerEntry(DispatchManager dispatchManager)
private void putToHoldbackQueue(DispatchManagerEntry managerEntry,
MsgQueueEntry entry)
throws XmlBlasterException
XmlBlasterExceptionprivate void flushHoldbackQueue(DispatchManagerEntry managerEntry)
public final void toAlive(DispatchManager dispatchManager,
ConnectionStateEnum oldState)
toAlive in interface I_ConnectionStatusListener
public final void toPolling(DispatchManager dispatchManager,
ConnectionStateEnum oldState)
toPolling in interface I_ConnectionStatusListener
public final void toDead(DispatchManager dispatchManager,
ConnectionStateEnum oldState,
java.lang.String errorText)
toDead in interface I_ConnectionStatusListener
private DispatchManagerEntry changeManagerState(DispatchManager dispatchManager,
ConnectionStateEnum newState,
boolean flush)
private DispatchManagerEntry[] getDispatchManagerEntryArr()
public void shutdown(DispatchManager dispatchManager)
throws XmlBlasterException
shutdown in interface I_MsgDispatchInterceptorXmlBlasterExceptionI_MsgDispatchInterceptor.shutdown(DispatchManager)
public void shutdown()
throws XmlBlasterException
I_MsgDispatchInterceptor
shutdown in interface I_MsgDispatchInterceptorXmlBlasterExceptionpublic boolean isShutdown()
isShutdown in interface I_MsgDispatchInterceptorpublic java.lang.String usage()
usage in interface I_MsgDispatchInterceptorpublic java.lang.String toXml(java.lang.String extraOffset)
toXml in interface I_MsgDispatchInterceptorextraOffset - Indent the dump with given ASCII blanks
I_MsgDispatchInterceptor.toXml(String)
public void postHandleNextMessages(DispatchManager dispatchManager,
MsgUnit[] processedEntries)
throws XmlBlasterException
postHandleNextMessages in interface I_MsgDispatchInterceptordispatchManager - The used dispatch manager.processedEntries - The entries which have been previously processed.
XmlBlasterException
public void onDispatchWorkerException(DispatchManager dispatchManager,
java.lang.Throwable ex)
onDispatchWorkerException in interface I_MsgDispatchInterceptordispatchManager - ex -
|
xmlBlaster 1.6.2 API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||